feat(analyzer): implement MCP rug-pull detection (RP1-RP3)#125
Open
tcconnally wants to merge 1 commit into
Open
feat(analyzer): implement MCP rug-pull detection (RP1-RP3)#125tcconnally wants to merge 1 commit into
tcconnally wants to merge 1 commit into
Conversation
Replaces the mcp_rug_pull analyzer stub with full RP1-RP3 detection. RP1: Unpinned MCP server references — detects npx, uvx, pip install, and docker commands that reference MCP servers/packages without version pinning (@Version, ==version, :tag, @sha256:). RP2: Permission pre-staging — detects manifest language suggesting future permission/capability expansion (rug-pull pre-staging). RP3: Version unpinned — detects wildcard/broad version constraints in manifest version field allowing silent major-version updates. Includes 8 unit tests covering all three rules. Previously tracked as TODO(SADD B.3.3) stub. Signed-off-by: Perseus Computing <51974392+tcconnally@users.noreply.github.com>
rng1995
approved these changes
Jun 21, 2026
rng1995
left a comment
Collaborator
There was a problem hiding this comment.
APPROVE — implements RP1–RP3 in place of the previous stub, with 8 passing unit tests. The RP1 (unpinned npx/uvx/pip/docker references) and RP3 (unpinned/broad skill version) logic is sound, the version-pin guard works, and the node returns Finding objects consistent with the rest of the pipeline.
A few non-blocking suggestions (one worth fixing before merge):
- Likely lint failure: in
_check_rp1,line_startis assigned in the npx/uvx/pip loops but never used (_find_line()computes the line). Unused locals trip the default Pyflakes/ruffF841rule — please remove them. - Manifest RP1 has no pin guard: the file-content loops skip pinned references via
_VERSION_PIN_RE, but the_RP1_NPX_CMD.finditer(manifest_text)block does not, so a properly pinnednpx ...@1.2.3in the manifest would still be flagged. Consider applying the same guard for consistency. - RP2 is broader than its docstring: the docstring describes detecting permissions that exceed current code usage, but the implementation just regex-matches the presence of a
permissionsarray (0.60) or expansion-language, so it will fire on essentially any manifest that declares permissions. Either narrow the pattern or align the docstring with the actual behavior. - Labeling:
npx/uvx/dockermatches are reported as "MCP server referenced without pinned version" even for non-MCP commands (only thepippath filters onmcp). Unpinned external commands are a legitimate rug-pull signal, but the wording could be more generic to avoid mislabeling.
None of these block the core detection, which is a clear improvement over the stub.
Collaborator
|
Please resolve the merge conflicts. |
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.
Summary
Implements the MCP rug-pull analyzer that was previously a TODO stub (
mcp_rug_pull.py— SADD B.3.3). Adds three detection rules for supply-chain rug-pull risks in agent skills.New Detection Rules
RP1: Unpinned MCP Server References (MEDIUM)
Detects MCP server/package references without version pinning:
npx @scope/server(no@version)uvx package-name(no==version)pip install mcp-server(no==version)docker run org/image(no:tagor@sha256:)Uses a two-step approach: find command references, then check line context for version pinning indicators. This avoids the backtracking false positives that simpler regex-only approaches produce.
RP2: Permission Pre-Staging (LOW)
Detects manifest language suggesting future permission/capability expansion — a common pre-staging tactic for rug-pull attacks.
RP3: Version Unpinned (LOW)
Detects wildcard (
*,latest,any) or broad (>=,^) version constraints in manifest metadata that allow silent major-version updates.Testing
tests/test_mcp_rug_pull.pyDesign Notes
@scope/mcp-server@1.2.3.versionkey directly from manifest dict rather than regex onstr()output, which is more robust against different dict serialization formats.