Skip to content

fix(cli): scope scan-resources to its own surface (#221)#254

Merged
hello-args merged 3 commits into
MCP-Audit:mainfrom
maxime2476:fix/221-scan-resources-instruction-discovery
Jun 11, 2026
Merged

fix(cli): scope scan-resources to its own surface (#221)#254
hello-args merged 3 commits into
MCP-Audit:mainfrom
maxime2476:fix/221-scan-resources-instruction-discovery

Conversation

@maxime2476

Copy link
Copy Markdown
Contributor

Closes #221

What was wrong

mcts scan-resources is documented as "Scan MCP resources only", but it was reporting prompt/instruction findings. The shared _surface_scan helper hardcoded discover_instructions=True, so instruction discovery still walked SKILL.md / prompt manifests on every surface scan. On repos that ship skill documentation, a resource-only scan surfaced skill_md / prompt_injection findings and polluted resource-only CI gates with prompt-surface noise.

The fix

Instead of a flat True, discover_instructions is now derived from the surfaces being scanned:

discover_instructions=not _INSTRUCTION_DISCOVERY_SURFACES.isdisjoint(surfaces)
  • scan-prompts (prompt, instruction) → discovery stays on
  • scan-instructions (instruction) → discovery stays on
  • scan-resources (resource) → discovery turns off

Driving the flag from the surface set keeps the three subcommands correct by construction, so a future surface command can't silently reintroduce the leak.

Tests

Added test_scan_resources_excludes_prompt_surface_findings, which seeds a repo with an injection-laden SKILL.md, then asserts:

  • scan-resources emits no prompt-surface analyzers (prompt_injection, prompt_defense, skill_md)
  • scan-prompts still picks the skill doc up (the doc is genuinely a prompt surface)

Confirmed the test fails on main (leaked prompt-surface findings: ['skill_md']) and passes with the fix. ruff check is clean on the touched files.

maxime2476 and others added 3 commits June 11, 2026 18:51
scan-resources is documented as "Scan MCP resources only" but the shared
_surface_scan helper hardcoded discover_instructions=True. Instruction
discovery then walked SKILL.md / prompt manifests, so resource-only scans
reported prompt-surface findings (e.g. skill_md, prompt_injection) and
polluted resource CI gates on repos that ship skill documentation.

Derive discover_instructions from the requested surfaces: it stays on for
prompt/instruction scans (which need it) and turns off for resource-only
scans. Driving it from the surface set keeps the three subcommands correct
by construction and avoids drift if new surface commands are added.
Merge main and document that resource-only surface scans no longer
walk SKILL.md / prompt instruction files.
@hello-args hello-args merged commit 2bbaa16 into MCP-Audit:main Jun 11, 2026
8 checks passed
@hello-args

Copy link
Copy Markdown
Collaborator

Thanks @maxime2476!

Nice catch on this one. The explanation, fix, and regression test all make sense, and I really like the approach of deriving instruction discovery from the selected surfaces rather than hardcoding behavior.

Appreciate you taking the time to track it down and put together a clean fix. Thanks for the contribution!

@maxime2476

Copy link
Copy Markdown
Contributor Author

Thanks for the review and the feedback!

Glad the fix was helpful. Happy to contribute, and I’ll be around for future issues as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] scan-resources should not include prompt-surface findings

2 participants