deep-code-security
Multi-language SAST and AI-powered fuzzing MCP server for Claude Code integration, enabling static and dynamic security analysis of code.
README
deep-code-security
Multi-language SAST tool with agentic verification and AI-powered fuzzing. Two analysis modes:
- Static Analysis (SAST) - Uses Semgrep with tree-sitter fallback for deterministic AST parsing, sandbox-verified exploit PoCs, and structured remediation guidance
- Dynamic Analysis (Fuzzing) - AI-powered fuzzer with coverage-guided feedback, crash deduplication, and corpus management
Exposes all functionality via an MCP server for Claude Code integration.
Quick Start
# Install (basic)
pip install -e ".[dev]"
# Install with fuzzing support
pip install -e ".[dev,fuzz]"
# Static analysis via CLI
dcs hunt /path/to/project
dcs hunt /path/to/project --ignore-suppressions
dcs verify --finding-ids <id1> <id2>
# Dynamic analysis (fuzzing) via CLI
dcs fuzz /path/to/target.py
dcs replay /path/to/corpus
dcs corpus /path/to/corpus
dcs fuzz-plugins
dcs report /path/to/output
# Integrated SAST-to-Fuzz pipeline
dcs hunt-fuzz /path/to/project
# Enable C fuzzing (in addition to Python)
export DCS_FUZZ_ALLOWED_PLUGINS=python,c
# Build the C fuzzer sandbox (Podman required)
make build-fuzz-c-sandbox
# Fuzz a C target with SAST-to-Fuzz bridge
dcs hunt-fuzz /path/to/c_project --consent
# Run via MCP server
python -m deep_code_security.mcp
Architecture
Static Analysis (SAST)
Target Codebase
|
v
HUNTER scanner backend (Semgrep/tree-sitter) → source/sink match → taint track
| Output: RawFinding[] (JSON, paginated)
v
AUDITOR PoC generation → sandbox execution → confidence scoring
| Output: VerifiedFinding[] (JSON) [Exploit = 10% bonus only]
v
ARCHITECT context gather → guidance generation → dependency analysis
Output: RemediationGuidance[] (JSON)
Dynamic Analysis (Fuzzing)
Target Function
|
v
FUZZER LLM-guided input generation → sandboxed execution →
crash detection → corpus management → coverage tracking
Output: CrashReport[] (JSON, with reproducer inputs)
Supported Languages (v1)
- Python (Flask, Django patterns; SAST + fuzzing)
- Go (net/http, database/sql patterns; SAST only)
- C (command injection, buffer overflow, format string, memory corruption
patterns; SAST + fuzzing). C fuzzing requires
DCS_FUZZ_ALLOWED_PLUGINS=python,cand AI-powered harness generation with AddressSanitizer and gcov instrumentation.
Suppression Files
You can suppress specific findings by creating a .dcs-suppress.yaml file
in your project root. This is useful for marking false positives, accepted
risks, or findings that will be addressed later.
Basic usage:
# .dcs-suppress.yaml
version: 1
suppressions:
- rule: CWE-22
file: "src/config/*.py"
reason: "Config paths are admin-controlled"
- rule: CWE-89
file: "src/legacy/db.py"
line: 145
reason: "Legacy code scheduled for refactor in Q2"
CLI flags:
- By default, suppressions are applied during
dcs hunt,dcs full-scan, anddcs hunt-fuzzcommands - Use
--ignore-suppressionsto bypass the suppression file and show all findings
Notes:
- Suppression files only affect SAST findings, not fuzzer crashes
- The file must be named
.dcs-suppress.yamland located in the project root - All formatters (text, JSON, SARIF, HTML) show suppression statistics in their output
Installation
# Clone
git clone https://github.com/your-org/deep-code-security.git
cd deep-code-security
# Install with dev dependencies
pip install -e ".[dev]"
# Install with fuzzing support (requires anthropic SDK)
pip install -e ".[dev,fuzz]"
# Build sandbox images (requires Docker or Podman)
make build-sandboxes # Build auditor/architect sandbox images
make build-fuzz-sandbox # Build Python fuzzer sandbox image (Podman only)
make build-fuzz-c-sandbox # Build C fuzzer sandbox image (Podman only)
MCP Configuration
Add to ~/.claude/settings.json:
{
"mcpServers": {
"deep-code-security": {
"command": "python",
"args": ["-m", "deep_code_security.mcp"],
"cwd": "/path/to/deep-code-security",
"env": {
"DCS_REGISTRY_PATH": "/path/to/deep-code-security/registries",
"DCS_ALLOWED_PATHS": "/path/to/projects",
"DCS_CONTAINER_RUNTIME": "auto",
"ANTHROPIC_API_KEY": "your-api-key-here"
}
}
}
}
Optional Environment Variables
For advanced tuning, additional variables are available:
Static Analysis:
| Variable | Default | Description |
|---|---|---|
DCS_SCANNER_BACKEND |
auto |
Scanner backend: semgrep, treesitter, or auto (prefer semgrep if available) |
DCS_SEMGREP_TIMEOUT |
120 |
Maximum seconds for Semgrep subprocess |
DCS_SEMGREP_RULES_PATH |
<registry>/semgrep |
Path to DCS Semgrep rule files |
DCS_MAX_RESULTS |
100 |
Max findings returned per hunt operation |
DCS_MAX_VERIFICATIONS |
50 |
Max findings to verify in auditor phase |
DCS_SANDBOX_TIMEOUT |
30 |
Per-exploit timeout in seconds |
DCS_MAX_FILES |
10000 |
Max files per scan |
DCS_MAX_CONCURRENT_SANDBOXES |
2 |
Concurrency limit for sandbox execution |
DCS_QUERY_TIMEOUT |
5.0 |
Tree-sitter query timeout in seconds |
DCS_QUERY_MAX_RESULTS |
1000 |
Max results per tree-sitter query |
DCS_BRIDGE_MAX_TARGETS |
10 |
Max fuzz targets produced by SAST-to-Fuzz bridge |
Dynamic Analysis (Fuzzing):
| Variable | Default | Description |
|---|---|---|
ANTHROPIC_API_KEY |
(none) | API key for Claude (required for fuzzing) |
GOOGLE_CLOUD_PROJECT |
(none) | GCP project ID for Vertex AI (optional) |
CLOUD_ML_PROJECT_NUMBER |
(none) | GCP project number for Vertex AI (optional) |
ANTHROPIC_VERTEX_PROJECT_ID |
(none) | Vertex AI project override (optional) |
DCS_FUZZ_MODEL |
claude-sonnet-4-6 |
Claude model for input generation |
DCS_FUZZ_MAX_ITERATIONS |
10 |
Max fuzzing iterations |
DCS_FUZZ_INPUTS_PER_ITER |
10 |
Inputs generated per iteration |
DCS_FUZZ_TIMEOUT_MS |
5000 |
Per-input execution timeout |
DCS_FUZZ_MAX_COST_USD |
5.0 |
API cost budget |
DCS_FUZZ_OUTPUT_DIR |
./fuzzy-output |
Corpus and report output directory |
DCS_FUZZ_CONSENT |
false |
Pre-configured consent for CI |
DCS_FUZZ_GCP_REGION |
us-east5 |
GCP region for Vertex AI |
DCS_FUZZ_ALLOWED_PLUGINS |
python |
Comma-separated allowlist of fuzzer plugins (default: python; set to python,c to enable both) |
DCS_FUZZ_MCP_TIMEOUT |
120 |
Hard wall-clock timeout for MCP fuzz invocations |
DCS_FUZZ_CONTAINER_IMAGE |
dcs-fuzz-python:latest |
Podman image used by ContainerBackend for MCP fuzz runs |
DCS_FUZZ_C_CONTAINER_IMAGE |
dcs-fuzz-c:latest |
Podman image used by CContainerBackend |
DCS_FUZZ_C_COMPILE_FLAGS |
"" |
Comma-separated gcc flags (e.g., -O2,-march=native) |
DCS_FUZZ_C_INCLUDE_PATHS |
"" |
Comma-separated include paths for C harness compilation |
MCP Tools
| Tool | Description |
|---|---|
deep_scan_hunt |
Run Hunter phase (AST parse + taint track) |
deep_scan_verify |
Run Auditor phase (sandbox exploit verification) |
deep_scan_remediate |
Run Architect phase (remediation guidance) |
deep_scan_full |
Run all three phases sequentially |
deep_scan_status |
Check sandbox health and registry info |
deep_scan_fuzz |
Run AI-powered fuzzing (requires Podman container backend) |
deep_scan_hunt_fuzz |
Run SAST analysis followed by AI-powered fuzzing of identified vulnerable functions (requires Podman + consent) |
deep_scan_fuzz_status |
Check fuzzer availability and configuration |
Confidence Scoring
The confidence score (0-100) uses a weighted composite:
| Factor | Weight | Notes |
|---|---|---|
| Taint path completeness | 45% | Full path = 100, partial = 50, heuristic = 20 |
| Sanitizer absence | 25% | No sanitizer = 100, full sanitizer = 0 |
| CWE severity baseline | 20% | Critical = 100, High = 75, Medium = 50, Low = 25 |
| Exploit verification | 10% | Bonus only — failed PoC does not penalize |
Thresholds: >=75 confirmed, >=45 likely, >=20 unconfirmed, <20 false positive
Sandbox Security Policy
Sandbox containers enforce:
--network=none— no network access--read-only— read-only root filesystem--tmpfs /tmp:rw,noexec,nosuid,size=64m— writable temp with noexec--cap-drop=ALL— no Linux capabilities--security-opt=no-new-privileges— no privilege escalation--security-opt seccomp=seccomp-default.json— custom seccomp profile--pids-limit=64— no fork bombs--memory=512m— memory ceiling--user=65534:65534— run as nobody
Development
make lint # Lint with ruff
make test # All tests (90%+ coverage required)
make test-hunter # Hunter tests only
make test-auditor # Auditor tests only
make test-architect # Architect tests only
make test-mcp # MCP server tests only
make test-fuzzer # Fuzzer tests only
make test-c-fuzzer # C fuzzer plugin tests only
make sast # Security scan with bandit
make security # sast + pip-audit
Registry Format
See registries/README.md for the YAML registry format documentation.
Known Limitations (v1)
-
Intraprocedural taint only — source and sink must be in the same function body. Expected detection rate: 10-25% of real-world injection vulnerabilities. Most web app vulnerabilities span multiple function call boundaries and will NOT be detected by v1.
-
Query brittleness (tree-sitter backend only) — tree-sitter queries match specific AST shapes. When using Semgrep backend, aliased imports, fully-qualified names, and class attributes are handled correctly. The following patterns are NOT matched when using tree-sitter:
- Aliased imports:
req = request; req.form - Fully-qualified names:
flask.request.form - Class attributes:
self.request.form - Chained calls:
request.form.get("key")(partial match only)
- Aliased imports:
-
PoC verification is bonus-only — most template-based PoCs fail due to missing execution context (framework setup, dependency injection, state initialization). A failed PoC does NOT mean the vulnerability is false. The exploit bonus is capped at 10 points.
-
No cross-language taint — Python calling C via FFI is not analyzed. Each language is analyzed independently.
-
No interprocedural analysis — call graphs across functions/files are not traced in v1. Deferred to v1.1.
-
Fuzzer requires optional dependencies — dynamic analysis requires
pip install -e ".[fuzz]"to install theanthropicSDK and related packages. The fuzzer will not be available without these dependencies. -
deep_scan_fuzzMCP tool requires Podman — The MCP fuzzing tool uses ContainerBackend for full isolation and is only available when Podman is installed and thedcs-fuzz-python:latestimage is built viamake build-fuzz-sandbox. CLI fuzzing supports both SubprocessBackend (rlimits-only) and ContainerBackend. -
C language: no preprocessor resolution —
#ifdefguards and macro expansions are invisible to the scanner. Code hidden behind conditional compilation will not be analyzed. -
C language: no struct member taint tracking — taint does not propagate through struct field assignments. Only scalar variables and direct pointer dereferences are tracked.
-
C language: pointer aliasing tracked within same function only — intraprocedural constraint applies (same as limitation #1). Pointer aliases passed to other functions are not tracked.
-
C language: output-parameter sources deferred — C source functions that deliver tainted data via output parameters (
recv,fread,read,scanf,getline,getdelim) are not effective taint sources in v1. Only functions whose return value is the tainted data (argv,getenv,gets,fgets) work correctly with the LHS-seeding taint engine. -
C language: CWE-416 (use-after-free) detection deferred — requires temporal ordering analysis (tracking that
free(ptr)precedes a subsequent use ofptr), which is fundamentally different from the source-to-sink taint model. -
C language:
mktemp()/tmpnam()detection gap — registered as CWE-676 sinks, but the taint-flow pipeline requires a source-to-sink path. Most real-world uses call these with hardcoded template strings, so they will NOT be flagged. -
C fuzzer harness validation is allowlist-based, not sandbox-escape-proof — The C fuzzer compiles and executes LLM-generated C code inside a Podman container with seccomp enforcement. Dual-layer AST validation prohibits dangerous syscalls and non-standard includes, but this is a defense-in-depth measure, not a complete security boundary. The primary isolation mechanism is the Podman container with
--network=none,--read-only,--cap-drop=ALL, and a custom seccomp profile (sandbox/seccomp-fuzz-c.json). Prompt injection attacks that evade the AST allowlist could still execute arbitrary code inside the container (but not escape to the host).
Security Model
The MCP server runs as a native stdio process on the host. It does NOT run inside a Docker container, avoiding the Docker socket mount attack vector. Docker or Podman is used for sandbox containers that execute exploit PoCs (auditor/architect phases). The fuzzer's ContainerBackend uses Podman exclusively for rootless container execution.
All file access goes through DCS_ALLOWED_PATHS allowlist validation with symlink resolution. All RawFinding fields are validated before exploit template interpolation. Finding provenance is verified via server-side session store (external callers cannot inject arbitrary findings).
Fuzzer Execution Model
The Python and C fuzzers use fundamentally different execution models inside the sandbox container:
- Python fuzzer (
_worker.py): useseval()with restricted globals (no imports, limited builtins) and dual-layer AST validation. No arbitrary machine code is generated. - C fuzzer (
_c_worker.py): does NOT useeval(). Instead, AI-generated C source is compiled withgccand the resulting binary is executed. This means arbitrary machine code runs inside the container, making the Podman seccomp profile (sandbox/seccomp-fuzz-c.json) the primary security boundary.
Both backends run under --network=none, --read-only, --cap-drop=ALL, --pids-limit=64, and --memory=512m.
v1.1 Roadmap
- Interprocedural taint tracking (call graph construction)
- Java and Rust language support
- Additional registry patterns (aliased imports, fully-qualified names)
- gVisor/Firecracker sandbox option for higher-risk deployments
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。