SkillSpector icon indicating copy to clipboard operation
SkillSpector copied to clipboard

fix(analyzers): rely on runner for example filtering in E5 and TM4 (close executable bypass)

Open CharmingGroot opened this issue 5 months ago • 1 comments

Summary

The SC7 review (#224) established that calling is_code_example() inside an analyzer with an unconditional continue lets a nearby example marker suppress findings in executable files — the shared runner already filters examples in non-executable docs and only downweights executables, so the analyzer-level call is redundant and opens an attacker-controlled bypass. E5 (#218) and TM4 (#220), both merged, use the same pattern. This applies the same fix.

Changes

  • static_patterns_data_exfiltration.py (E5): drop the is_code_example call and import; rely on the runner's file-type-aware handling.
  • static_patterns_tool_misuse.py (TM4): same.
  • Tests: TM4's analyze-level doc-exclusion test is replaced with an executable-evasion test (# for example next to privileged: true still fires); an equivalent E5 regression is added.

Why this is safe

Detection is unchanged — the runner still suppresses non-executable docs and downweights executables. Only the bypass is closed: a # for example near s3.put_object(...) or privileged: true in a .sh/.py no longer evades E5/TM4. anti_refusal already uses a confidence penalty (not a skip), so it is intentionally left as-is.

Testing

make format and make lint pass; the full suite reports 1256 passed, 0 failed. A re-scan confirms detection is preserved (E5 ×2, TM4 ×6 still fire on the same fixtures).

Follows up on the review in #224.

CharmingGroot avatar Jun 30 '26 13:06 CharmingGroot

Fix linting please @CharmingGroot

rng1995 avatar Jul 10 '26 20:07 rng1995

@CharmingGroot - Please address review comments and resolve merge conflicts.

rng1995 avatar Aug 14 '26 20:08 rng1995

Rebased onto current main — conflict in src/skillspector/nodes/analyzers/static_patterns_data_exfiltration.py resolved by keeping main's expanded common imports minus is_code_example (removed by this PR). No remaining is_code_example call sites in E5/TM4.

The mcp_least_privilege.py format failure was fixed on main and cleared with the rebase. make lint / make format-check pass, unit suite 2187 passed / 16 skipped. Ready to merge.

CharmingGroot avatar Aug 18 '26 13:08 CharmingGroot