SkillSpector icon indicating copy to clipboard operation
SkillSpector copied to clipboard

fix(mcp): treat allowed-tools as a permission declaration for LP3

Open CharmingGroot opened this issue 5 months ago • 1 comments

Fixes #15.

While reading the MCP least-privilege path I confirmed the reported false positive. LP3 flags standard-compliant skills, and the cause is a field-name mismatch between SkillSpector and the Agent Skills standard.

What this fixes

LP3 ("no declared permissions but code capabilities were detected") fired on skills that declare capabilities through allowed-tools, the field defined by the Agent Skills standard. Two things combined to cause it:

  1. _parse_manifest only extracted permissions and dropped allowed-tools, so the field never reached the analyzer.
  2. mcp_least_privilege only read permissions, so a skill declaring e.g. allowed-tools: [Bash, Read] was treated as having no declaration at all.

_parse_manifest now parses and preserves allowed-tools (both the list form [Bash, Read] and the comma-separated string form Bash, Read), and LP3 treats a non-empty allowed-tools as a valid declaration. LP1/LP4 continue to use the explicit permissions list only, so this change stays scoped to the LP3 false positive in the issue.

Scanning a skill that declares allowed-tools: [Bash, Read] with shell/file-read code no longer reports LP3.

Testing

  • ruff check src/ tests/ and ruff format --check src/ tests/ pass.
  • pytest -m 'not integration' passes (605 passed, 11 skipped). The integration suite needs an LLM endpoint and is unaffected.
  • Added regression tests: allowed-tools parsing in build_context (list, comma-string, and malformed-value forms) and LP3 not firing when allowed-tools is declared. The existing "no declaration" test still asserts LP3 fires.

CharmingGroot avatar Jun 12 '26 01:06 CharmingGroot

Thanks for the thorough review — the asymmetry you flagged is real and the suggested fix was the right call.

_TOOL_TO_CAPABILITY now maps Agent Skills tool names (Bash, Read, Write, WebFetch, etc.) to capability categories, and _map_allowed_tools_to_categories() converts the declared tool list into a category set. The LP1 guard was expanded to has_declaration = (permissions present) OR (allowed_tools non-empty), with both sources unioned into declared_categories before the coverage loop runs. LP4 also gets a (permissions or []) guard to prevent a TypeError when only allowed-tools is set.

Two regression tests added to TestLP3AllowedTools:

  • allowed-tools: [Read] + shell code → LP3 suppressed, LP1 fires HIGH for shell
  • allowed-tools: [Bash] + shell-only code → no LP1

All 14 tests pass. Ready for re-review.

CharmingGroot avatar Jun 23 '26 04:06 CharmingGroot