feat(analyzer): add agent snooping detector (AS1/AS2/AS3)#96
Open
Shrotriya-lalit wants to merge 1 commit into
Open
feat(analyzer): add agent snooping detector (AS1/AS2/AS3)#96Shrotriya-lalit wants to merge 1 commit into
Shrotriya-lalit wants to merge 1 commit into
Conversation
No existing analyzer flags skills that read the agent's own config directories, access MCP server config files, or enumerate other installed skills. All three vectors let a malicious skill discover API keys, tool definitions, and peer-skill prompts it has no legitimate need to see. Add static_patterns_agent_snooping with three rule IDs: AS1 – Agent config directory access (.claude/, .codex/, .gemini/) AS2 – MCP config file access (mcp.json / mcp_config.json) AS3 – Skill enumeration (listing or reading other skills' files) Register the new node in ANALYZER_NODE_IDS / ANALYZER_NODES (21 total), add AGENT_SNOOPING category and full AS1-AS3 entries to pattern_defaults, update the registry test, and add an integration test class covering true-positive and safe-content (false-positive) cases. Closes NVIDIA#75 Signed-off-by: Lalit Shrotriya <shrotriya.lalit@outlook.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem / Gap
No existing analyzer flagged skills that attempt to read the agent's own
configuration directories, access MCP server config files, or enumerate other
installed skills. All three vectors give a malicious skill knowledge it has
no legitimate need for:
.claude/,.codex/,.gemini/, or.continue/exposes API keys, system prompts, and custominstructions stored there.
mcp.json/mcp_config.jsoncontainsthe full list of MCP servers, their endpoints, and their authentication
tokens.
source files learns the full tool surface of the agent and can craft targeted
follow-on attacks.
Solution
New static analyzer
static_patterns_agent_snoopingwith 21 patterns acrossthree rule IDs, registered as analyzer node #21 (position 12, after
static_patterns_rogue_agent).AS1 patterns (confidence 0.85–0.9)
open(.claude/…)/Path(".claude/…")os.path.join/exists/isfilewith agent config directoriescat,find,grep) targeting~/.claude/etc.AS2 patterns (confidence 0.85–0.9)
mcp.json/mcp_config.json.claude/mcp.jsonAS3 patterns (confidence 0.7–0.85)
os.listdir/glob/Path.globon skill directoriesls/findtargeting skills folderFiles Changed
src/skillspector/nodes/analyzers/static_patterns_agent_snooping.pyanalyze(),node())src/skillspector/nodes/analyzers/pattern_defaults.pyPatternCategory.AGENT_SNOOPING, AS1–AS3 explanations, remediations, pattern namessrc/skillspector/nodes/analyzers/__init__.pyANALYZER_NODE_IDSandANALYZER_NODEStests/nodes/analyzers/test_static_patterns.pyTestRunStaticPatternsAgentSnooping(5 tests)tests/nodes/analyzers/test_registry.pyEXPECTED_ANALYZER_NODE_IDSTests
test_as1_agent_config_dir_access_python— Pythonopen()call targeting.claude/test_as1_codex_config_dir_access—Path(".codex/config.json")constructtest_as2_mcp_config_access— directmcp.jsonreadtest_as3_skill_enumeration—os.listdiron skills directorytest_safe_content_no_agent_snooping— clean content produces no findings (false-positive guard)All 626 existing tests continue to pass.
Closes #75
Checklist
make lintpasses (ruff check src/ tests/)python -m pytest tests/ -x --ignore=tests/integration)git commit -s)