Repository navigation
fix(scanner): ramparts scan fails closed on garbled tools.json or scan error - #674
Conversation
Deploying mcpproxy-docs with
|
| Latest commit: |
ca59f70
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://93c9f4b1.mcpproxy-docs.pages.dev |
| Branch Preview URL: | https://fix-mcp-2443-ramparts-fail-c.mcpproxy-docs.pages.dev |
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
📦 Build ArtifactsWorkflow Run: View Run Available Artifacts
How to DownloadOption 1: GitHub Web UI (easiest)
Option 2: GitHub CLI gh run download 27536483444 --repo smart-mcp-proxy/mcpproxy-go
|
14dc421 to
9fc68ab
Compare
…n error The Ramparts scanner reported a broken run as a clean, zero-finding scan (fail-open), defeating the security gate: - mcp-replay.py served `[]` tools when /scan/source/tools.json was missing/empty/garbled/wrong-shape, letting Ramparts emit a spurious clean report. - entrypoint.sh masked the ramparts exit code (`|| true`) and accepted any non-empty file as success, so a failed scan that wrote a non-empty *error* JSON was treated as a clean report. The Go runner ignores the container exit code, so a non-zero exit alone never marked the scan failed. Fix (fail CLOSED): - mcp-replay.py: raise ToolsLoadError and exit non-zero (serving no frames) on unreadable/empty/invalid/wrong-shape tools.json or zero usable tools, so Ramparts sees a dead endpoint instead of an empty tool list. - entrypoint.sh: validate the captured output is a genuine Ramparts report (top-level security_issues object + yara_results array, the shape isRampartsOutput() probes). On failure, DELETE the report so the engine finds no output and records the scanner as failed. A non-zero ramparts exit with a valid report (findings/offline-LLM) is kept. Adds runnable tests: mcp-replay_test.py fail-closed cases and a new entrypoint_test.sh that stubs ramparts to cover every report/exit combo. Docs updated in docs/features/scanner-images.md. Related MCP-2443
9fc68ab to
b651be5
Compare
|
codex review (gpt-5.5) → REQUEST_CHANGES (independently re-verified) Blocking bug: the fail-closed gate in Fix: require |
Re-review (MCP-2443) found the fail-closed gate checked
`security_issues is None` — presence only, not type. An error payload like
{"security_issues":"scan failed","yara_results":[]} has the key present but
the wrong type, so it passed the gate as a clean scan = fail-open survives.
entrypoint.sh now requires `security_issues` to be an object (dict) and
`yara_results` an array, matching the real Ramparts report schema
({security_issues{tool_issues,...}, yara_results[]}). Anything else fails
CLOSED (report deleted -> scanner marked failed).
Adds entrypoint_test.sh cases: a string `security_issues` and a string
`yara_results` payload both assert the scan is marked failed, not clean.
Related MCP-2443
Co-Authored-By: Paperclip <[email protected]>
Re-review fix pushed (type-confusion gap closed)Thanks — confirmed real. The fail-closed gate was presence-only ( Fix ( TDD: Verification: entrypoint 9/9, shim 11/11, shellcheck clean. Pushed to the same branch; CI + review re-trigger. QA re-dispatched at head |
Problem (MCP-2443, [SEC] HIGH)
The Ramparts docker scanner failed OPEN: a broken/garbled input or a ramparts failure was reported as a clean, zero-finding scan, silently defeating the security gate.
Two root causes:
mcp-replay.pyreturned[]tools when/scan/source/tools.jsonwas missing / empty / garbled / wrong-shape → Ramparts completed a handshake against an empty tool list and emitted a "clean" report.entrypoint.shmasked the ramparts exit code (|| true) and accepted any non-empty file ([ -s REPORT ]) as success → a failed scan that wrote a non-empty error JSON was treated as a successful report.Compounding it: the Go runner ignores the container exit code (
docker.goRunScannerreturnsnilfor a non-zero exit) and marks a scan failed only when no readable report exists. Soexit 1alone is not enough — the engine reads whatever report file is present.Fix — fail CLOSED
mcp-replay.py:load_tools()now raisesToolsLoadErrorand the shim exits non-zero serving no frames whentools.jsonis unreadable / empty / invalid JSON / wrong-shape / yields zero usable tools. Ramparts then sees a dead endpoint instead of an empty tool list. A partially-garbled file with ≥1 real tool still scans.entrypoint.sh: captures the ramparts exit code, then validates the output is a genuine Ramparts report (top-levelsecurity_issuesobject +yara_resultsarray — the same shapeisRampartsOutput()probes). On any failure it deletes the report so the engine finds no output and records the scanner as failed, instead of parsing a stale/error payload as 0 findings. A non-zero ramparts exit with a valid report is kept (findings/offline-LLM signal that way — discarding it would lose real detections).Acceptance
tools.json→ non-zero exit, scan failed (not clean)mcp-replay_test.py:test_{empty_file,garbled_json,wrong_shape,empty_tool_list,missing_tools_file}_fails_closedentrypoint_test.sh:error_payload_nonzero_fails,error_payload_rc0_fails,empty_report_fails,garbled_report_failstools.jsonwith a real finding still scans + reportsmcp-replay_test.py:test_partial_garble_with_real_tool_still_scans;entrypoint_test.sh:valid_*_keptVerification (local)
Docs updated:
docs/features/scanner-images.md(fail-closed section).Notes
COPYs onlyentrypoint.sh/mcp-replay.py, so the new*_test.sh/*_test.pyfiles don't enter the image.mcp-replay_test.py+entrypoint_test.shintoscanner-images.ymlCI (they currently run locally only).Related MCP-2443