Introducing a new way to review your PRs.

Read the announcement

affaan-m / agentshield

AI agent security scanner. Detect vulnerabilities in agent configurations, MCP servers, and tool permissions. Available as CLI, GitHub Action, ECC plugin, and GitHub App integration. 🛡️

View on GitHub

20 documents · Updated Sep 11, 2026

docs / supply-chain-verification

Supply-chain verification

Supply-chain verification turns package references found in agent integrations and package files into a reviewable security report. It identifies the package source and version, checks local and optional registry signals, preserves the reason for each risk, and presents the result for people or automation.

Verification boundary

The verification boundary is the set of package references that can affect an MCP server or its installation. It joins integration configuration with package metadata so that the same review can cover a package invoked at run time and a package declared for installation.

Package reference inputs

The extractor reads MCP and settings JSON files, plus package.json and package-lock.json files marked as package-manager configuration. It recognizes npm-style references from npx, direct server commands, and Node paths. It also recognizes GitHub Git URLs in server arguments.

Each extracted record keeps the package name, an optional version, its source form, and the server or file that supplied it. Manifest ranges are reduced to an exact version only when the text is an exact semantic version. Lockfiles provide installed versions when their package entries include one.

References: src/…/extract.ts• L11-17 src/…/extract.ts• L35-53 src/…/extract.ts• L83-159 src/…/types.ts• L5-12

Reference normalization

Normalization makes different input forms comparable without hiding meaningful differences. The extractor ignores malformed JSON and invalid server shapes, skips flags when it seeks package arguments, and keeps Git references separate from npm package specs.

The final list removes duplicate records by source, name, version, Git URL, and Git reference. Two references to the same package can still remain separate when their source or revision differs. This preserves the distinction between an unpinned Git source and the same repository pinned to a commit.

References: src/…/extract.ts• L18-32 src/…/extract.ts• L55-81 src/…/extract.ts• L220-227 src/…/extract.ts• L249-305

Package verification

Package verification evaluates each normalized reference against known threat data and provenance rules. It produces one package result for each extracted record, then combines those results into counts that support review and enforcement.

Local risk checks

Offline checks do not need a network request. They compare package names and versions with known malicious or compromised packages, compare server packages with known vulnerable MCP entries, look for names close to trusted packages, and flag Git URLs that do not use a commit hash.

The verifier assigns a severity to each matching risk. A package receives the highest severity among its risks. A package with no risk receives info, which means that the checks found no issue rather than that the package is proven safe.

References: src/…/verify.ts• L21-107 src/…/verify.ts• L110-138 src/…/cve-database.ts• L615-663

Registry enrichment

Online mode adds npm registry metadata for non-Git packages. The metadata can show the latest version, publication time, weekly downloads, maintainer count, deprecation, and whether the latest version has a postinstall script.

These fields add context signals. They can produce medium, low, or other package risks for deprecation, automatic install scripts, one maintainer, very low downloads, or recent publication. Registry lookup is optional. A failed package lookup leaves the local result intact, and a failed download-count lookup leaves that one field absent.

References: src/…/verify.ts• L76-82 src/…/verify.ts• L217-271 src/…/verify.ts• L274-328

Provenance assessment

Provenance records how a package is identified and how stable that identity is. Exact npm versions and Git commit hashes count as pinned references. Ranges, tags, latest, missing versions, and branch-like Git refs count as unpinned.

The result also records whether the package name is in the known-good list and whether its supporting metadata came from offline rules, the npm registry, or a Git URL. The report summarizes these values across all package results so a reviewer can see both risk and evidence coverage.

References: src/…/verify.ts• L136-187 src/…/types.ts• L37-43 src/…/types.ts• L74-81

Result model

The result model keeps package identity, evidence, risk, and summary data together. This lets terminal output and machine-readable output describe the same assessment without rebuilding decisions in each consumer.

Package result

Each PackageVerification contains the extracted package, its PackageProvenance, optional registry metadata, a list of PackageRisk entries, and the package's overall severity. A risk has a type, severity, description, and optional evidence such as a package match, CVE list, or Git URL.

The risk types cover malicious or vulnerable packages, typosquatting, Git pinning, and registry health signals. The type identifies why the package needs review; the severity identifies how strongly the result affects the report and any gate.

References: src/…/types.ts• L16-61 src/…/verify.ts• L34-96

Supply-chain report

SupplyChainReport is the aggregate output of verification. It contains every package result and counts total packages, risky packages, critical results, and high results. Its provenance summary counts npm and Git sources, pinned and unpinned references, known-good names, and packages with registry metadata.

An empty input produces a valid report with zero counts. This gives callers a clear “nothing detected” state instead of requiring a special result type.

References: src/…/types.ts• L63-81 src/…/verify.ts• L99-107

Report rendering

Rendering converts one supply-chain report into human-readable terminal text or structured JSON. Both renderers consume the typed report, so the output reflects the same risk and provenance decisions used by the action and other callers.

Terminal report

The terminal report starts with package and provenance counts. It then places risky packages before clean packages so review starts with the items that need action. Risky entries show the package, integration or file source, overall severity, each risk, and available evidence. Registry details appear when online metadata exists.

Package names, versions, server names, risk descriptions, evidence, and registry values are escaped before terminal output. This prevents control bytes in untrusted package data from changing the terminal display.

References: src/…/render.ts• L3-5 src/…/render.ts• L7-67 src/…/render.ts• L70-121

Machine-readable report

The JSON renderer serializes the full SupplyChainReport with indentation. It retains package records, provenance, risk types, evidence, registry metadata, and aggregate counts for downstream tools such as action summaries or policy gates.

References: src/…/render.ts• L108-113 src/…/types.ts• L29-81

Verification flow

The verification flow moves from discovered scan inputs to normalized references, then to package-level decisions and shared output. This diagram shows where local intelligence and optional external metadata enter the process.

flowchart LR
    A[Discovered MCP and package files] --> B[Extracted package references]
    B --> C[Deduplicated normalized records]
    C --> D[Local threat and pin checks]
    C --> E[Optional npm registry metadata]
    D --> F[Typed package results]
    E --> F
    F --> G[Supply-chain report]
    G --> H[Terminal or JSON output]

The public supply-chain module exposes extraction, verification, rendering, and the shared result types through one boundary. This keeps callers aligned on the same package record and report contract.

References: src/…/index.ts• L1-14 src/…/extract.ts• L15-32 src/…/verify.ts• L24-107 src/…/render.ts• L9-12

  • Supply-chain security explains how this verification phase fits the wider supply-chain risk model and CI gate.
  • Threat intelligence explains the local CVE and package knowledge used by the local risk checks.

Change checklist

When these files or sections are changed, remember to consider these:

  • Keep supported MCP command forms aligned with the ConfigFileType values that can reach extraction. A new discovered file type does not enter verification unless extraction accepts it.
  • Keep extraction identity fields aligned with deduplication. Changing source, version, or Git reference semantics can merge distinct package records or hide a changed revision.
  • Keep risk types and severity values aligned with PackageRisk, aggregate report counts, and any downstream gate that uses critical or high counts.
  • Keep provenance pin rules aligned with the package locator shown to reviewers. A new version or Git reference form can silently change whether a dependency is treated as stable.
  • Keep registry metadata failure behavior optional. External lookup errors must not remove local package or threat results.
  • Keep terminal and JSON renderers aligned with the report model so new evidence remains available to both human review and automation.

Important failure modes

TriggerConsequenceGuard
A dependency uses an input form outside the extractor's supported MCP, manifest, or lockfile formsThe dependency is absent from the report and receives no package-level checkConfirm the analyzed package count and add support for the input form at the extraction boundary
A lockfile entry does not provide an installed versionA compromised version-specific package entry may not match local threat dataTreat the result as incomplete provenance and supply an exact installed version through the lockfile
A Git URL uses a branch or tag instead of a commit hashLater installs can receive changed repository content and the package receives high unpinned-Git riskPin the source to a commit hash
Online registry lookup failsRegistry-only signals are missing, but local verification still returns a resultRead the metadata source and do not treat missing registry data as proof of safety
A package has several risks with different severitiesThe package is summarized at the worst risk severityReview the individual risk list when the aggregate severity drives a gate or remediation choice
Untrusted package text contains terminal control bytesTerminal output can be altered or misleadingUse the terminal renderer's escaped output rather than writing package fields directly

Key files

FileWhy to read it
src/…/extract.tsDefines the package and Git reference forms that enter verification and the rules that remove duplicates.
src/…/verify.tsConnects extracted references to local threat checks, provenance decisions, optional registry data, and report counts.
src/…/types.tsDefines the shared package, risk, provenance, and report concepts used by all output paths.
src/…/render.tsShows how the typed report becomes safe terminal text or JSON.
src/…/index.tsShows the public boundary for the complete verification capability.
src/…/cve-database.tsProvides the known malicious package and vulnerable server lookups used during verification.
tests/…/extract.test.tsDemonstrates the supported configuration, manifest, lockfile, npm, and Git input forms.
tests/…/verify.test.tsDemonstrates local risks, provenance results, online enrichment, and failure-tolerant lookup behavior.
tests/…/render.test.tsDemonstrates the terminal and JSON output contracts, including safe handling of untrusted text.