Snyk Agent Scan

repository·main·Indexed 25 days ago

https://github.com/snyk/agent-scan

An agent supply chain security scanner designed to discover and scan agent components, including harnesses, MCP servers, and skills, for vulnerabilities such as prompt injections, tool poisoning, and malware payloads. It provides a CLI for scanning specific configurations or performing full machine scans, with capabilities to detect toxic flows and destructive operations.

Tokens
14.9K
Snippets
21
Records
101
Agent score
84%

What's inside snyk-agent-scan

  1. Access Agent Scan documentation

    main

    The docs/ directory contains detailed technical documentation for Agent Scan. Use the following guides for specific tasks:

    • CLI reference: Detailed information on all commands, flags, options, environment variables, and exit codes.
    • Scanning: Explanations of how scanning works and practical usage examples.
    • JSON output: Information regarding the JSON schema, how to integrate with CI, and how to perform programmatic parsing of results.
    • Issue Codes: A comprehensive reference for all security issues, warnings, toxic flows, and system codes detected by the tool.
  2. Understand Agent Scan modes: Scan vs. Background (MDM)

    main

    Agent Scan operates in two distinct modes:

    1. Scan Mode: A CLI-driven mode where snyk-agent-scan scans the local machine and outputs a report for the user to review immediately.
    2. Background Mode (MDM): A continuous monitoring mode where Agent Scan runs at regular intervals in the background and reports results to a Snyk Evo instance. This is intended for security teams to monitor the company-wide agent supply chain. Setup requires contacting Snyk.
  3. Security issues demonstrated by the Small MCP Demo Server

    main

    The Small MCP Demo Server is a testing tool containing intentional security anti-patterns for mcp-scan detection. Warning: Do not use this server in production.

    Demonstrated issues include:

    • Prompt Injection: Malicious instructions embedded in tool descriptions.
    • Rug Pull: The multiply tool changes its behavior after its first execution.
    • Toxic Flows: Combinations of tools that could lead to sensitive data leaks.
    • Destructive Operations: Capabilities for file deletion.
    • Data Exfiltration: Email sending capabilities with external access.
  4. Scan specific MCP configurations, skills, or directories

    main

    You can target specific files or directories instead of performing a full machine scan:

    • Scan an MCP configuration file: Provide the path to the JSON configuration.
    • Scan a single agent skill: Provide the path to the skill file (e.g., a .md file).
    • Scan all Claude skills: Provide the directory containing Claude skills.
    • Scan MCP only: Use the --no-skills flag to skip skill analysis.
    # scan an MCP configuration
    uvx snyk-agent-scan@latest ~/.vscode/mcp.json
    
    # scan a single agent skill
    uvx snyk-agent-scan@latest ~/path/to/my/SKILL.md
    
    # scan all claude skills
    uvx snyk-agent-scan@latest ~/.claude/skills
    
    # MCP only (skip skills)
    uvx snyk-agent-scan@latest --no-skills
  5. Integrate snyk-agent-scan in CI/CD

    main

    For CI/CD pipelines, it is recommended to use the built-in --ci mode rather than manual jq parsing of the JSON output.

    To use --ci with MCP servers, you must also include --dangerously-run-mcp-servers.

    Exit Codes:

    • 0: Clean (no remaining issues or failures).
    • 1: Issues or unignored runtime failures present.
    • 2: Invalid flags (e.g., --ci used without --dangerously-run-mcp-servers).

    You can ignore specific issue codes in CI using --ignore-issues-codes CODE1,CODE2. Ignored codes are removed from the JSON payload before the exit check.

    uvx snyk-agent-scan@latest \
      --ci \
      --dangerously-run-mcp-servers \
      --json \
      ~/.claude/skills
  6. Check for policy violations in JSON output

    main

    Once inspection succeeds, check the issues array for findings:

    • E prefix: Error — high-severity security finding (e.g., E001).
    • W prefix: Warning — lower-severity or informational finding (e.g., W001).

    Note on Internal Warnings: The codes W003, W004, W005, and W006 are legacy internal hints. They are included in JSON output but are hidden in the default CLI text report. If you want your JSON processing to match the CLI's default behavior, filter these out.

  7. Quick Start with `snyk-agent-scan`

    main

    To perform a full scan of your machine, which automatically discovers agents, MCP servers, and skills (including Claude Code/Desktop, Cursor, Gemini CLI, and Windsurf), use the uvx command. This scan checks for vulnerabilities in servers, skills, tools, prompts, and resources.

    uvx snyk-agent-scan@latest
  8. Verify standalone binary integrity

    main

    To ensure the authenticity of downloaded binaries, use GPG to verify the signed checksums file.

    1. Download assets: Get the binary and sha256sums.txt.asc from GitHub Releases.
    2. Import public key: Download the GPG public key and import it:
      gpg --import snyk-code-signing-public.pgp
    3. Verify signature:
      gpg --verify sha256sums.txt.asc
      Ensure the output contains: gpg: Good signature from "Snyk Limited <code-signing@snyk.io>".
    4. Verify binary checksum:
      • Linux (or macOS with coreutils):
        grep agent-scan-<version>-<os>-<arch> sha256sums.txt.asc | sha256sum -c -
      • macOS (default shasum):
        grep agent-scan-<version>-<os>-<arch> sha256sums.txt.asc | shasum -a 256 -c -
  9. Run Agent Scan via standalone binary (uvx)

    main

    You can run the Agent Scan tool directly using uvx.

    Common patterns:

    • Default scan: uvx snyk-agent-scan@latest (scans machine/skills).
    • MCP only: Use --no-skills to skip skill scanning.
    • Specific targets: Provide a path to an MCP config or skill directory.
    • CI Mode: Use --ci for non-interactive environments. Use --dangerously-run-mcp-servers to allow MCP server execution in CI.
    • JSON Output: Use --json for programmatic parsing.
    # Full machine scan
    uvx snyk-agent-scan@latest
    
    # MCP only, no skills
    uvx snyk-agent-scan@latest --no-skills
    
    # Specific config or skill directory
    uvx snyk-agent-scan@latest ~/.cursor/mcp.json
    uvx snyk-agent-scan@latest ~/.claude/skills
    
    # Inspect without analysis
    uvx snyk-agent-scan@latest inspect
    
    # JSON for CI parsing
    uvx snyk-agent-scan@latest --json ./my-skill
    
    # CI pipeline (non-interactive)
    uvx snyk-agent-scan@latest --ci --dangerously-run-mcp-servers --json
    
    # CI with ignored warnings
    uvx snyk-agent-scan@latest --ci --dangerously-run-mcp-servers \
      --ignore-issues-codes W001,W015
    
    # All users on a shared machine
    uvx snyk-agent-scan@latest --scan-all-users
    
    # Enterprise upload with push key
    export SNYK_TOKEN=... 
    uvx snyk-agent-scan@latest scan \
      --control-server "https://api.snyk.io/hidden/mcp-scan/push?version=2025-08-28" \
      --control-server-H "x-client-id: <push-key>" \
      --control-identifier "$(hostname)"