Security Developer Tools 33 vues

Pantheon-Security/medusa: AI-First Security Scanner for 40,000+ Threat Patterns

M
Mohamed IDBRAHIM
Auteur
Pantheon-Security/medusa: AI-First Security Scanner for 40,000+ Threat Patterns

Pantheon-Security/medusa: AI-First Security Scanner for 40,000+ Threat Patterns

Developers integrating AI assistants, LLM agents, and MCP servers into their workflows face a growing attack surface that traditional security tools barely touch. Poisoned editor configurations, leaked API keys in chat histories, and supply-chain compromises targeting AI coding tools are now practical, documented risks—not theoretical concerns. Pantheon-Security/medusa addresses this gap directly. It's an AI-first security scanner with 40,000+ detection patterns that works out of the box, requiring no external tool installation. Whether you're vetting a GitHub repo before cloning, auditing your own AI chat history for leaked credentials, or hardening an LLM application against prompt injection and MCP tool poisoning, medusa provides concrete, actionable detection.

What is Pantheon-Security/medusa?

Pantheon-Security/medusa is an open-source security scanner maintained by Pantheon Security, licensed under GNU Affero General Public License v3.0. The project has accumulated 937 GitHub stars and 153 forks as of its last commit on June 24, 2026. Written primarily in Python↗ Bright Coding Blog (3.10+), it installs via PyPI as medusa-security and runs natively on Windows, macOS, and Linux.

The tool occupies a distinct position in the security tooling landscape: it combines traditional static application security testing (SAST) capabilities with specialized coverage for AI/ML threats that most scanners ignore. Its 40,000+ patterns span prompt injection, jailbreak payloads, MCP server compromise, RAG pipeline poisoning, and weaponized AI editor configurations—alongside conventional vulnerabilities like SQL injection, XSS, and command injection. The scanner auto-detects external linters (Bandit, ESLint, ShellCheck, and others) if installed, but functions fully without them.

Medusa's relevance stems from timing. The 2025-2026 period has seen rapid proliferation of AI coding assistants (Claude Code, Cursor, GitHub Copilot, Gemini CLI) and the Model Context Protocol (MCP) ecosystem. Each introduces new trust boundaries and attack vectors. Medusa's maintainers have tracked this evolution closely, releasing native Rust and PHP↗ Bright Coding Blog security rules in v2026.7 and adding Claude Code compromise detection that vets .claude/ hooks, permissions, and skills before repository cloning.

Key Features

AI Supply-Chain Scanning via medusa scan --git — The --git flag clones and scans any GitHub repository for AI-specific supply chain attacks, including repo poisoning, prompt injection, and MCP tool poisoning. It accepts full URLs or user/repo shorthand and detects 28+ AI editor configuration file types known to be attack vectors.

Secrets Detection in AI Chat Histories — medusa secrets scan finds API keys, tokens, and private keys leaked into Claude Code, Cursor, Copilot, Zed, Gemini chat histories, plus shell histories (bash, zsh, fish, psql, mysql↗ Bright Coding Blog, Python REPL). It covers 21 issuer types including Anthropic, OpenAI, PyPI, GitHub PATs, AWS, GCP, Stripe, and Slack tokens. The companion medusa secrets purge command provides interactive [y/n/s/a/q] redaction with mandatory byte-identical backups and JSONL-safe markers.

40,000+ Detection Patterns — The pattern library covers AI/ML applications, LLM agents, MCP servers, RAG pipelines, and traditional code. This includes 800+ prompt injection patterns, 400+ MCP server security checks, 150+ repo poisoning rules, 300+ RAG security patterns, and 1,400+ traditional SAST rules.

200 CVE Detections — Documented coverage includes Log4Shell, Spring4Shell, XZ Utils backdoor, LangChain RCE, MCP-Remote RCE, and React2Shell (CVE-2025-55182).

Zero-Setup Operation — Works immediately after pip install. No server, no database, no configuration file required for basic operation. Smart caching (content-hash keyed, CI-correct) and parallel multi-core processing provide 10-40× speedups over sequential scanning.

Multiple Output Formats — JSON, HTML, Markdown↗ Smart Converter, SARIF, and JUnit exports for CI/CD integration and reporting workflows.

Use Cases

Pre-Clone Repository Vetting — Before adopting a dependency or contributing to an unfamiliar project, run medusa scan --git <URL> to detect weaponized AI editor configurations. The scanner identifies critical-risk files like .cursorrules, .cursor/mcp.json, .clinerules/, .claude/ hooks with curl|bash or base64→exec patterns, and over-broad permissions like Bash(*) or bypassPermissions. This catches documented attacks including Clinejection, CurXecute (CVE-2025-54135), IDEsaster (CVE-2025-64660), and ToxicSkills before code reaches your machine.

Credential Hygiene for AI-Assisted Development — Developers routinely paste API keys into AI assistant conversations—"deploy this with pypi-AgEI...", "use my ghp_... to push." These assistants store conversations in plaintext on disk. Medusa's secrets scanner audits these locations, finds exposed credentials, and redacts them with verifiable safety properties: local-only operation (no telemetry), byte-identical backups, atomic writes via os.replace, and refusal to proceed if source files drift between scan and purge.

LLM Application Security Assessment — Teams building production RAG pipelines, agent orchestration systems, or MCP servers can use medusa to detect prompt injection vulnerabilities in data files (.jsonl, .csv), invisible Unicode/bidi attacks (Trojan Source, CVE-2021-42574), and agent-specific risks like excessive agency, memory poisoning, and HITL bypass. The always-on AI attack-signature scanner added in v2026.7 closes a false-negative gap by catching jailbreak payloads regardless of LLM-context confidence scoring.

CI/CD Security Gates — The --fail-on flag (critical, high, medium, low) enables non-zero exit codes for pipeline enforcement. SARIF output integrates with GitHub Advanced Security and similar platforms. No external tool installation means the scanning step remains deterministic and fast.

Multi-Language Codebase Auditing — With 79 scanner types covering 46+ file types across Python, JavaScript↗ Bright Coding Blog/TypeScript, Go, Rust, PHP, Java, infrastructure-as-code (Terraform, Kubernetes, CloudFormation), and more, medusa serves as a unified entry point for heterogeneous projects.

Installation & Setup

Install medusa via pip in a virtual environment:

# Create and activate virtual environment
python3 -m venv medusa-env
source medusa-env/bin/activate  # Windows: medusa-env\Scripts\activate

# Install MEDUSA
pip install medusa-security

# Verify installation
medusa scan .

Platform-specific notes from the documentation:

  • Windows: Use py -m medusa if the medusa command is not found after installation
  • macOS/Linux: Should work out of the box with standard Python installations

Optional AI tool installation for ML model scanning:

medusa install --ai-tools

This installs modelscan for detecting vulnerabilities in serialized ML models (pickle, PyTorch, TensorFlow, etc.). External linters are no longer managed by medusa as of v2026.2+; install Bandit, ESLint, ShellCheck, or others via your system package manager if desired. Medusa auto-detects and uses any installed linters without configuration.

Initialize project-specific configuration:

medusa init

This creates .medusa.yml with sensible defaults, auto-detects your IDE, and generates integration files for Claude Code, Gemini CLI, GitHub Copilot, Cursor, or OpenAI Codex as selected.

Real Code Examples

Scanning a Remote Repository for AI Supply-Chain Risks

# Full URL or shorthand syntax
medusa scan --git https://github.com/org/repo

# Equivalent shorthand
medusa scan --git org/repo

# Specific branch
medusa scan --git https://github.com/org/repo/tree/main

The --git flag performs a shallow clone, scans for AI-specific attack vectors in editor configs and MCP definitions, then cleans up. This is particularly valuable for evaluating open-source tools that integrate with AI assistants—compromised configurations in these repositories can propagate to every user who clones them.

Finding and Redacting Leaked Secrets

# Scan all default sources (AI chats + shell histories)
medusa secrets scan

# Scan only AI assistant histories
medusa secrets scan --source ai-chats

# Scan only shell histories
medusa secrets scan --source shell

# Interactive purge with per-finding confirmation
medusa secrets purge

Example output from a secrets scan:

Scanning 118 file(s)...

── claude-code ──────────────────────────────────────────────
/home/ross/.claude/history.jsonl  (13 finding(s))
[CRITICAL] Anthropic API key (anthropic)
    /home/ross/.claude/history.jsonl:1005:13
    sk-ant-api03***...***
[CRITICAL] PyPI API token (pypi)
    /home/ross/.claude/history.jsonl:125:94
    pypi-AgEIc***...***
...
Total: 13 credentials across 1 file(s).
Report:  /home/ross/.medusa/secrets-scan/secrets-20260519-074452.json

The purge operation presents each finding with [y/n/s/a/q/?] options (yes, no, skip, all, quit, help). Every redaction is preceded by a byte-identical backup under ~/.medusa/secrets-scan/backups/. The redaction marker format [REDACTED-MEDUSA-...-<run-id>] is unique per run and JSONL-safe.

Basic Scan with Severity-Based Failure

# Scan current directory, exit non-zero on HIGH or above
medusa scan . --fail-on high

# Quick scan using cached results for unchanged files
medusa scan . --quick

# Force full rescan ignoring cache
medusa scan . --force

# Generate HTML report
medusa scan . --format html

CI/CD Integration

# .github/workflows/security.yml
name: Security Scan
on: [push, pull_request]

jobs:
  medusa:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-python@v4
        with:
          python-version: '3.11'
      - run: pip install medusa-security
      - run: medusa scan . --fail-on high

No tool installation step is required—medusa's built-in rules execute immediately.

Advanced Usage & Best Practices

Cache Strategy for Large Codebases — Medusa's content-hash keyed caching correctly handles CI environments where git metadata may not reflect file modification times. For repositories with thousands of files, the quick scan mode (--quick) typically reduces subsequent scans to seconds. The cache is stored per-project and can be disabled with --no-cache if needed.

Worker Tuning — By default, medusa auto-detects optimal worker counts based on CPU cores, memory pressure, and system load. Manual override (--workers N) is available but generally unnecessary; the scanner reduces workers automatically when high CPU usage is detected.

Rule-Level Diagnostics — Version 2026.7 adds --trace-rules for per-rule firing logs and timing data, output to rule-trace.jsonl and slow_rules.csv. This helps identify rules causing performance degradation or unexpected behavior. The maintainers used this capability to discover and fix a real catastrophic-backtracking ReDoS in their own rule set.

Configuration Management — The .medusa.yml file supports project-specific exclusions, scanner enable/disable lists, IDE integration settings, and failure thresholds. Version-control this file to ensure consistent scanning behavior across team members and CI environments.

Safety with Secrets Purge — The purge command implements defense-in-depth: atomic writes prevent partial corruption, drift detection refuses to operate if files change between scan and purge, and mandatory backups allow recovery. Reports are written with mode 0o600 and never leave the local machine. These properties make it suitable for use on developer workstations handling production credentials.

Comparison with Alternatives

Aspect Pantheon-Security/medusa Bandit Semgrep SonarQube
Primary Focus AI/ML + traditional security Python security Multi-language pattern matching Multi-language analysis platform
Setup Complexity pip install, zero config pip install, requires Python toolchain Rule configuration often needed Server/database required
AI-Specific Coverage 40,000+ patterns including MCP, RAG, agent security None Community rules limited Limited
Secrets in AI Chats Built-in, 21 issuer types No No No
Repo Poisoning Detection 28+ AI editor config types No No No
Execution Model CLI, local-only CLI, local CLI/CI Server + CI
License AGPL-3.0 Apache-2.0 LGPL/Commercial Commercial/Community
Cost Free Free Free tier limits Free Community Edition

Medusa's trade-off is scope specificity versus breadth. It excels at AI-adjacent threats and developer-workflow security but does not replace dedicated infrastructure scanners or runtime application protection platforms. Teams with existing SonarQube or Semgrep deployments may find medusa complementary rather than substitutive—particularly for pre-merge AI supply-chain checks and developer-machine secrets hygiene.

FAQ

Q: What Python versions are supported? A: Python 3.10 and above.

Q: Does medusa send code or findings to external services? A: No. All scanning is local-only with no telemetry.

Q: Can I use medusa in CI/CD without installing external linters? A: Yes. The 40,000+ built-in patterns work without any external tools.

Q: What happens if a secrets purge is interrupted? A: Atomic writes via os.replace ensure either the original file remains or the complete redaction lands—no partial states.

Q: Is the AGPL-3.0 license compatible with commercial use? A: Yes for internal use. Modifications or SaaS deployments require releasing derivative works under AGPL-3.0. Commercial licensing is available via support@pantheonsecurity.io.

Q: How does medusa handle false positives? A: 514+ FP filter patterns with documented 96.8% reduction rate; --trace-rules helps identify noisy rules.

Q: Can medusa scan private repositories with --git? A: The README documents GitHub URL scanning; authentication for private repos is not explicitly detailed—test with standard git credential helpers.

Conclusion

Pantheon-Security/medusa fills a genuine gap in developer security tooling: the intersection of AI-assisted development workflows and practical threat detection. Its 40,000+ patterns, zero-setup operation, and concrete safety properties for secrets management make it immediately usable for individual developers and CI/CD pipelines alike. The tool is best suited for teams adopting Claude Code, Cursor, Copilot, or custom LLM agents who need supply-chain vetting and credential hygiene without operational complexity.

The project shows active maintenance with regular feature releases and responsive security updates. While not a replacement for comprehensive application security platforms, medusa provides focused, high-value coverage where most existing tools have blind spots.

Get started at https://github.com/Pantheon-Security/medusa or install directly with pip install medusa-security.


For related coverage on securing AI development workflows, see [INTERNAL_LINK: MCP server security best practices].

Commentaires 0

Aucun commentaire pour l'instant. Soyez le premier à réagir !

Laisser un commentaire