sec-graph

sec-graph

Enables triage of SAST findings by exposing a read-only MCP server with tools to access hash-verified source-to-sink code slices, unguarded sinks, and layered enrichment for local LLM analysis.

Category
访问服务器

README

sec-graph

An interactive security map + local‑LLM triage layer over any SAST.

sec-graph is not another taint engine. It takes the findings your existing static analyzer already produces — CodeQL, Semgrep, Bandit, anything that emits SARIF — binds them to a code map, enriches them with two layers no engine ships (a credentials / PII layer and an auth / unguarded verdict), and hands each finding to your own local LLM over MCP as a minimal, hash‑verified source→sink slice for triage. Everything runs locally and deterministically; no finding data leaves your machine.

Built on graphify (MIT). A small built‑in Python taint engine is kept as the fallback for when you don't have a SARIF report — it is not the product.

sec-graph: SQLi paths with the auth/unguarded layer

The layer no SAST ships: red glow = a dangerous sink reachable with no auth barrier (triage these first) · green ring = the same sink behind a real auth check. Colour = data layer; the right‑hand sidebar carries each finding's CWE + the hash‑verified source→sink slice an LLM triage call receives.

Why

Mature SAST engines are very good at finding data‑flows and very bad at two things a human (or an LLM) actually needs to triage them: "is this reachable without authentication?" and "does this path touch a credential/PII?" — plus they dump raw findings with no cheap way to feed just the relevant code to a model. sec-graph adds exactly those, on top of whatever engine you already run.

Does it actually help? (an honest benchmark)

We pre‑registered and ran a control‑vs‑treatment benchmark — a local Gemma 3n E4B triaging the same 66 CodeQL findings on three deliberately‑vulnerable Python apps, whole‑file context vs sec-graph's MCP slices, scored against hand‑labelled, independently‑audited ground truth. The honest result:

  • The robust win is efficiency — sec-graph's minimal slices matched whole‑file triage quality at ~1/7th the prompt tokens and ~half the wall‑time (12× fewer tokens per finding on large files). That's what makes per‑finding triage cheap enough to run on a local model.
  • Accuracy: a small, statistically‑inconclusive, repo‑dependent edge (real/FP +6 pts pooled, not significant) — reported as a signal, not a result.
  • The self‑audit is honest about a limitation. sec-graph's unguarded verdict over‑reports (56% precision) when an app uses a custom auth decorator/callable not in the default barrier list, or a guard in a calling function — though it never falsely claims guarded (100%). That's configuration + a future interprocedural improvement, published, not buried.

Full methodology, numbers, and a "when it helps / when it doesn't" table: benchmark/BENCHMARK.md · pre‑registration: benchmark/PROTOCOL.md.

sec-graph on PyGoat, real CodeQL findings

On a real repo (PyGoat + CodeQL's 40 findings): most web‑app findings are intra‑function, so the map is a constellation of unguarded hotspots rather than long routes — the enriched sidebar is the workhorse there, and the graph earns its keep on cross‑function/cross‑file data‑flow. Honest by design.

Install

pip install -e .          # or: uv pip install -e .
secgraph --version

Requires Python ≥ 3.11. Pulls graphify, tree-sitter, mcp, typer, pyyaml.

Quickstart

# 1. run your SAST and export SARIF
codeql database create db --language=python && \
codeql database analyze db --format=sarif-latest -o findings.sarif \
    codeql/python-queries:codeql-suites/python-security-extended.qls
#   (or)  semgrep scan --sarif -o findings.sarif

# 2. bind + enrich + map
secgraph analyze ./my-app --sarif findings.sarif   # -> graph.json, taint.json, secgraph.html
secgraph view                                       # open the interactive layered map

# 3. triage with your own LLM over MCP
secgraph serve                                      # read-only MCP server (stdio)

No SARIF? secgraph analyze ./my-app runs the built‑in Python fallback engine instead.

How it works

  1. Ingest — parse SARIF (results + codeFlows) or Semgrep JSON into one normalized finding, bound to the code graph structurally (by (file, def‑line) span, never by name).
  2. Enrich — add, per finding: sensitive‑data layers (credentials/PII identifiers & secret patterns on the tool‑verified flow lines) and, for Python sinks, an auth/unguarded verdict from a structural guard analysis, with an honest tri‑state (analyzed / unknown — never a false "guarded").
  3. Map — a self‑contained, deterministic force‑directed HTML map: colour = data layer, red glow = unguarded, a one‑click "Critical paths" preset.
  4. Triage over MCP — secgraph serve exposes read‑only tools (list_paths, get_path_slice, find_unguarded_sinks, explain_layer, get_function_taint) that hand your LLM the minimal, hash‑verified code windows for a path — never the whole repo. Run it alongside graphify --mcp (entity‑level questions stay with graphify; data‑flow paths are ours).

credentials + secret enrichment

Enrichment in action (credentials + untrusted-input layers): a hard‑coded secret:aws-access-key-id and credentials‑tagged data‑flows in amber — surfaced from the same findings, with tags no engine emits.

The analysis core is deterministic — no LLM on the critical path; analyze twice is byte‑identical.

Scope & honest limits

sec-graph is bounded by your upstream SAST's recall — it adds no findings the engine missed. The enrichment is lexical (identifier/secret patterns on a proven flow), stronger than grep but weaker than value‑tracking taint. The auth verdict and the built‑in engine are Python‑only; other languages get the map + slices but a guard_status: unknown. See BENCHMARK.md for the measured weaknesses (including a current guard‑analysis bug); the licence/scope notes for each engine are in docs/.

Development

uv pip install -e ".[dev]"
pytest                 # 121 tests
pytest tests/contract  # the graphify contract test

Architecture: docs/architecture.md · contributing: CONTRIBUTING.md.

License & credits

MIT (see LICENSE). Built on graphify (MIT); parses CodeQL / Semgrep SARIF; uses tree-sitter. sec-graph ships no third‑party code — those are runtime dependencies / input formats.

Responsible use

Defensive and static only — sec-graph exploits nothing and ships no exploit code; the MCP triage prompts enforce a defensive framing. Audit code you own or are authorized to review, and practice coordinated disclosure. Do not use it to mass‑scan third‑party code and publish 0‑days.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选