M15: Flag Unpinned MCP Packages (UNPINNED-MCP-PACKAGE) Instead of Guessing Latest Version¶
- Task ID:
M15 - Priority:
P2(Master Rank#4, Track A — Product & Customer Value) - Status:
Done - Dependencies:
M7,M8,M11 - Target Repository:
/Users/ivan/Project/3t.tools.intellij/verityredteam-free(verity-redteam-core) - GitHub Project #5: Verity RedTeam Free Task Board
1. Context & Problem Statement¶
In src/verity/discovery/matcher.py, HybridDiscoveryMatcher.match_static_config() currently computes:
matched_v = target_version or (
matched_spec.versions[-1].version if matched_spec.versions else "1.0.0"
)
confidence_score=0.85. ConsolidatedSecurityAuditor.audit_server() (src/verity/discovery/auditor.py) then passes that guessed matched_ver into VulnerabilityLookupEngine.query(identifier=matched_pkg, version=matched_ver):
- When a developer configures an unpinned MCP server such as npx -y mcp-remote or npx -y @modelcontextprotocol/server-github (or @latest), Verity silently assumes the newest catalog version (versions[-1].version or "1.0.0").
- This creates two problems:
1. Supply-chain blind spot: Floating npx/uvx executions fetch and run remote code on every client start (typosquatting / package-takeover risk), yet Verity emits no warning.
2. Inaccurate OSV attribution: Querying OSV with a guessed version can either hide CVEs affecting older versions or emit false-positive CVEs for a version the user did not pin.
2. Requirements & Target Files¶
- Preserve Unpinned State in Matcher (
src/verity/discovery/matcher.py): - In
HybridDiscoveryMatcher.match_static_config(), whentarget_versionisNone(or explicitly"latest"), returnmatched_version=None(or"unpinned"consistently withFingerprintMatchResulttyping) and lowerconfidence_score(e.g.0.65) instead of substitutingmatched_spec.versions[-1].version/"1.0.0". - Keep exact pinned specifiers (
mcp-remote@0.1.15,pkg==1.2.3) returning the exacttarget_versionwithconfidence_score=0.85. - Emit
SEC-STATIC-UNPINNED-PACKAGE/UNPINNED-MCP-PACKAGEAdvisory (src/verity/discovery/auditor.py): - When a server is launched via a floating package runner (
npx,uvx,pipx,bunx) without an exact pinned version (or with@latest), emit a structuredSecurityAuditFinding:issue_id="SEC-STATIC-UNPINNED-PACKAGE"(severityMEDIUM, CWECWE-1104/CWE-829),- clear remediation instructing the user to pin an exact version (e.g.,
mcp-remote@0.1.16or local audited path).
- Do not query OSV with a fabricated
"1.0.0"/versions[-1]version when unpinned; only run version-specific OSV correlation when a concrete version is pinned or observed via live fingerprint match. - Update Existing Matcher / Auditor Tests (
tests/unit/): - Audit existing tests that relied on the old
versions[-1]fallback and update expectations cleanly so there are zero unintended regressions.
3. Automated Tests to Verify¶
Unit & Integration Tests (tests/unit/test_unpinned_package_detection.py)¶
- Unpinned
npx -y mcp-remote(No@version): - Assert
match_static_config()returnsmatched=True,matched_version is None(not"1.0.0"orversions[-1]), andaudit_server()emitsSEC-STATIC-UNPINNED-PACKAGE(MEDIUM) without fabricated version-specific CVE false positives. - Floating
@latest(npx -y mcp-remote@latest): - Assert
@latestis treated as unpinned and triggersSEC-STATIC-UNPINNED-PACKAGE. - Pinned Vulnerable
npx -y mcp-remote@0.1.15: - Assert
match_static_config()returnsmatched_version == "0.1.15",audit_server()does not emitSEC-STATIC-UNPINNED-PACKAGE, and still emitsVULN-CVE-2025-6514. - Pinned Python
uvx mcp-server-fetch==1.2.0vs. Unpinneduvx mcp-server-fetch: - Assert pinned passes without unpinned warning, while unpinned triggers
SEC-STATIC-UNPINNED-PACKAGE. - Local Absolute Binary/Script (
python3 /opt/mcp/server.py,node /app/index.js): - Assert local pinned paths do not trigger
SEC-STATIC-UNPINNED-PACKAGE(zero false positives). - CLI End-to-End (
verity scan --config-file ... --format json --fail-on-findings): - Verify
SEC-STATIC-UNPINNED-PACKAGEappears cleanly interminal,json,markdown, andhtmlreports with exit code1.
4. Acceptance Scenario with a Real MCP Package in Clean Container¶
Verify against real npm/Python MCP packages inside tests/e2e_containers/ (customer-full-workstation):
- Container Config Setup (
tests/e2e_containers/verify_all_scenarios.sh): - Configure three real server entries in
~/.cursor/mcp.json:mcp-remote-pinned:npx -y mcp-remote@0.1.15 https://remote.example.com/sse(pinned vulnerable real npm package -> must reportVULN-CVE-2025-6514and NOTSEC-STATIC-UNPINNED-PACKAGE).mcp-remote-unpinned:npx -y mcp-remote https://remote.example.com/sse(unpinned real npm package -> must reportSEC-STATIC-UNPINNED-PACKAGE).local-clean-server:python3 /opt/fixtures/clean_stdio_mcp.py(local script -> must report neither).
- Acceptance Command:
- Acceptance Assertions:
- Exits
1. mcp-remote-pinnedproducesVULN-CVE-2025-6514(no unpinned warning).mcp-remote-unpinnedproducesSEC-STATIC-UNPINNED-PACKAGEwith remediation advice.local-clean-serverproduces0findings.- Full
INSTALL_SOURCE=wheel ./tests/e2e_containers/run_e2e.shpasses across all 4 containers.
5. Verification Commands¶
cd /Users/ivan/Project/3t.tools.intellij/verityredteam-free
uv run ruff check src tests
uv run pytest tests/unit/test_unpinned_package_detection.py -v
uv run pytest tests/
INSTALL_SOURCE=wheel ./tests/e2e_containers/run_e2e.sh
6. Acceptance Criteria¶
- [ ]
HybridDiscoveryMatcher.match_static_config()no longer fabricatesversions[-1].versionor"1.0.0"for unpinned packages. - [ ]
ConsolidatedSecurityAuditoremitsSEC-STATIC-UNPINNED-PACKAGE(MEDIUM) for floatingnpx/uvx/@latestconfigs and skips guessed-version OSV queries. - [ ] Pinned packages (
@0.1.15,==1.2.0) and local script paths (python3 /path/...) produce zero false positives. - [ ]
tests/unit/test_unpinned_package_detection.py, fullpytest tests/,ruff check src tests, andtests/e2e_containers/run_e2e.shall pass cleanly.