codebase-snapshot

· 11 min read · by

Security review

Written for this release, about this release. It states the threat model, the controls, what is tested, and the residual risks — including the ones that are deliberately not solved.

What the tool is

A local process that reads a repository and writes a directory of text. Since 0.12.15 it also runs an HTTP server, fetches repositories from URLs, and signs manifests. Each of those is a new place where untrusted input can arrive.

Threat model

Adversary Can reach Cannot reach
A malicious repository (its files, config, filenames) The snapshot's text, the brief, the audit report, the planner's ranking The filesystem outside the repository, the network, the process environment
A malicious URL given to --remote or the browser page The clone path and the SSRF guard Any private address, any credential, any local file
A malicious web page in the same browser GET / on serve (HTML only), CORS preflights Anything behind the bearer token, any API response
A malicious MCP client The tool list and the snapshot's contents The working tree outside the snapshot, sensitive files, the network
A shoulder-surfer / log reader Nothing new Secrets (masked), paths (masked), tokens (never logged)

Controls

Content leaving the repository

Executable configuration

A snapshot.config.ts is code. The CLI runs it because the user invoked the repository's own command; the MCP server and the web page refuse it and say so. A repository fetched with --remote is treated more strictly still: none of its configuration is applied — not JSON, not JavaScript — because a fetched repository is not a trusted one. Only the clone and the built-in defaults decide what that run scans.

MCP over HTTP

The browser page

Remote ingestion

Signing

Prompt injection

A repository can contain text that tells a model to ignore its instructions. The snapshot preserves file content faithfully, and this tool cannot sanitise prose without changing the code it exists to carry. The brief says what the snapshot is and what it omits, and the security prompt tells an agent to treat file content as data. This is a real, documented limitation, not a solved problem.

What changed since this review was written

The review was written at 0.12.34. Between then and 0.20.13 the surfaces it covers grew; each addition was reviewed with the same question — what new input arrives, and what does it reach?

The residual risks below are unchanged, including the two that are deliberate rather than solved.

What the test suite pins

Property Test
Sensitive files stay out; skips are recorded tests/security-*.test.js, hygiene suites
Redaction masks the span only redaction suite (hundreds of cases)
Health catches a leaked secret and never echoes it tests/health.test.js
HTTP: 401 without token, 403 cross-origin, 413 oversize, 400 bad JSON tests/mcp-http.test.js
Modern HTTP: required headers, mismatch 400/-32020, cache fields, -32602, CORS tests/mcp-modern-http.test.js
Official MCP v2 client: modern stdio and modern HTTP, discovery, tools, resources tests/mcp-sdk-interop.test.js
SSE: token required, unknown session 404, shutdown does not hang tests/mcp-http.test.js
Remote: private addresses refused, credentials in URL refused, file: gated tests/remote-source.test.js
Serve: page without token, API with token, zip restricted tests/web-serve.test.js
Signature: tamper detected tests/signing.test.js
Second 0.20 audit: symlink targets, auth case, diff quoting, brief headings, ReDoS, HTTP cap, workspace dry run, staged validation, hook links tests/audit-0-20-5-ultimate.test.js
Fourth 0.20 audit: marker visibility, Dockerfile re-scan, long quoted secrets, unterminated PEM, alternation/glob budgets, workspace flags, skip-parts validation, HTTP batching, symbol cap, false overrides, ..notes.ts, CLI workspace confinement, serve origin/fences tests/audit-0-20-11-followup.test.js

Residual risks, stated

  1. ?token= on the legacy SSE paths. EventSource cannot set headers, so the token may travel in the URL on /sse and /messages only. URLs reach proxy logs and shell history. Use the Streamable HTTP endpoint with a header where the client supports it.
  2. --no-auth on loopback. Any local process (or a browser page that guesses the port, though CORS and the token requirement normally stop it) can then read the repository. It is a deliberate opt-out, printed as a warning.
  3. DNS rebinding. The private-address check resolves once before the clone; a hostile DNS server could change the answer between the check and git's own resolution. Mitigating it fully requires pinning the resolved IP for the connection, which git does not expose. The window is small, the target must be public at check time, and --allow-private is the only way to reach a private address deliberately.
  4. Prompt injection in repository content, as above.
  5. A signing key in the environment is visible to the process's own children and to anyone who can read /proc. Use a key file with restrictive permissions if that matters.
  6. No sandbox. The tool reads what the user can read and writes where the user says. It does not drop privileges, and it is not designed to run against hostile filesystems.

Reporting a vulnerability

Open a private security advisory on the repository, or email the address in package.json. Please include the version, a reproduction, and whether secret material was exposed. Fixes ship as patches on the current line; there is no long-term support branch yet.