fix(mcp): reject local targets over HTTP transport - #196
Conversation
rng1995
left a comment
There was a problem hiding this comment.
Approving — solid, fail-closed hardening: HTTP transport sets allow_local_targets=False and _is_local_target() rejects file://, absolute/drive, and UNC paths before the graph runs, while remote schemes pass through. Test coverage is thorough (local/file:// rejected, remote allowed, UNC + relative-path classification, transport policy stdio=allow/http=disallow, and default-compat).
Non-blocking notes:
_is_local_target()callsPath(target).expanduser().exists()for the relative/no-scheme case, i.e. an unauthenticated HTTP caller can make the serverstat()arbitrary relative paths (a minor file-existence oracle). The read itself is still blocked, so impact is low, but consider dropping the.exists()probe and classifying unknown bare strings as non-local.- Touches
mcp_server.pyalongside #204, and the README note in #193 documents this behavior — expect a merge-order/rebase with those.
rng1995
left a comment
There was a problem hiding this comment.
[Automated SkillSpector Review]
Re-review: approved. The HTTP local-target guard remains unchanged from the prior approved head. The only subsequent commit is formatter-only normalization of static_runner.py and three tests, with no semantic change to the MCP security behavior.
7222a95 to
aaeceb1
Compare
rng1995
left a comment
There was a problem hiding this comment.
[Automated SkillSpector Review]
Re-review: requesting changes. The HTTP local-target guard itself remains sound, but the rebased exact head has four failing MCP tests. The new cases still patch mcp_server.resolve_provider_credentials, which no longer exists after main switched this path to is_llm_available; each fails with AttributeError before exercising the guard. Update those tests to patch the current availability seam (for example is_llm_available) and restore the focused suite to green before approval. Exact-head result: 4 failed, 17 passed.
Signed-off-by: Rod Boev <rod.boev@gmail.com>
Signed-off-by: Rod Boev <rod.boev@gmail.com>
Signed-off-by: Rod Boev <rod.boev@gmail.com>
aaeceb1 to
73b0ac4
Compare
Summary
HTTP MCP callers can currently pass local filesystem targets to
scan_skill, and the server forwards those paths into the normal scan graph. This adds an MCP transport guard so routable HTTP use rejects local paths andfile://targets before the graph can read them, while CLI and stdio MCP scans keep their existing local-path behavior.Closes #191
Root cause
scan_skillforwards the caller-providedtargettorun_scanwithout transport context. The input resolver then treats local files and directories as valid scan targets, which is correct for trusted local use but too broad for unauthenticated HTTP exposure.Diff Notes
build_server()construction fail closed until a trusted transport explicitly enables local targets.run_scanuse.Scope
This does not add MCP authentication, change the generic input resolver, or alter report output. PR #193 covers the documentation warning slice; this PR covers the code guard.
Verification
python -m pytest tests/unit/test_mcp_server.py -q-> 26 passeduv run ruff check src/ tests/-> passeduv run ruff format --check src/ tests/-> passedgit diff --check-> passedLint & Test (Python 3.12),Lint & Test (Python 3.13), andDCO Check-> pending maintainer approvalNotes
mainata818f50f541ab2bbb4751e3c2490778f7a1b7c2b; the final diff remains limited to the two MCP guard files.