Files
codebase-memory-mcp/SECURITY.md
Martin Vogel 8eabe191d2 fix(install,daemon): unbreak npx clients, group-writable homes, and legacy updaters
Five field reports in the 24 hours after v0.10.0 all pointed at the same thing:
gates that were right in principle refused real, ordinary setups, and then
failed to say why. Per the consolidated strictness decision, each gate keeps the
protection that matters and drops the part that was refusing legitimate users —
and every refusal now names what it refused and how to proceed.

**Daemon image gate: npx and every ephemeral install path (#1539, #1383).**
The admission check treated "the peer's image hashes differently" and "the
peer's image cannot be examined at all" as one failure. The second is what
`npx codebase-memory-mcp` always produces (ephemeral cache path,
unfingerprintable), so every npx-invoked client was rejected — and, because the
client never reported it, agents saw a transport that closed mid-handshake with
zero bytes on stdout. Reported by @wassolles with the admission path already
read and the fix space mapped.

An unverifiable image is now admitted: the rendezvous HELLO immediately above it
has already proven semantic version, build fingerprint, and protocol/store/
feature ABI, and the image check was trading that real proof for an unavailable
one. It logs daemon.client_image_unverifiable_admitted so the weaker check is
never invisible. A fingerprint MISMATCH — the tamper case the gate exists for —
still rejects hard. Separate test seams keep the two modes testable apart.

**Client bootstrap failures are no longer silent (#1539).**
An MCP client that cannot reach the daemon now emits a JSON-RPC error on stdout
naming the reason, plus the same text on stderr. Previously the reason sat in
bootstrap_result.message and the process exited having written nothing at all.

**POSIX activation: group-writable ancestors (#1535, discussion #1526).**
activation_directory_secure required no group or other write bit on the install
directory AND every ancestor. WSL2 ships ~ and ~/.local at 0775, as do several
distro skeletons and any site using a shared primary group, so install.sh failed
for a large fraction of Linux users — reporting a policy refusal as "activation
transaction I/O failed", which sent reporters after disk errors and filesystem
types. Root-caused by @AmirF194 in a clean ubuntu container; @shochdoerfer and
@iandol confirmed independently.

World-writable ancestors are still refused (any local user could swap a path
component mid-transaction). Group-writable ancestors are now warned about and
admitted. The LEAF directory stays strictly owner-private — that is where the
binary is published, and group write there would let another account replace the
executable between validation and exec. Refusals now name the directory, its
mode, and which rule refused.

**The obsolete ui/standard chooser (#1538, from discussion #1526).**
v0.10.0 consolidated to one archive per platform with the UI always embedded,
but `update` still offered a variant choice: "ui" could only 404, and "standard"
quietly WAS the UI build. Reported by @iandol upgrading 0.9.0 -> 0.10.0. The
chooser, its --standard/--ui flags, and the ui- URL plumbing are removed, along
with the CBM_VARIANT=ui remnant in the npm installer.

Already-released 0.9.x binaries cannot be fixed retroactively, so the release
workflow now publishes byte-identical ui-*-named alias assets — their updaters
work again with no user action. The aliases are uploaded AFTER the VirusTotal
gate: they are the same bytes as archives it already cleared, and uploading them
earlier would duplicate every object in the scan set and the provenance manifest.

**macOS install noise and attribution (#1537).**
install.sh silenced the "No such xattr: com.apple.quarantine" line, which is
what happens when a curl-downloaded archive carries no quarantine attribute —
harmless, and it became the title of a bug report about an unrelated failure.
The session-stop refusal now points at `daemon status` to list the client
processes actually holding the daemon, instead of asserting sessions exist and
leaving the reader to guess. Reported by @listepo.

**Riders.** hatchling is pinned in pkg/pypi (an unpinned backend resolved fresh
inside `python -m build` is what emitted Metadata-Version 2.5 and broke the
v0.10.1 publish); SECURITY.md's supported-versions table moves to 0.10.x.

Tests: separate seams for unverifiable vs mismatched peer images with a test per
outcome; activation refusal must name directory + mode + rule; a group-writable
ancestor must stage successfully. The update tests drop the flag that no longer
exists. Verified against each reporter's environment shape.

**Open security alerts (all three, OSSF Scorecard).**
- HIGH, binary artifact: an 8.8 MB compiled Go ELF wrapper had been committed at
  pkg/go/codebase-memory-mcp by accident. Removed, and both it and its .exe
  sibling are gitignored so `go build` in that directory cannot repeat it.
- HIGH, GHSA-2v37-7h3g-55p8: nanoid < 3.3.17 loops forever when a custom
  generator is called with size 0. It reaches us transitively (postcss -> vite),
  so it is pinned through the existing graph-ui overrides block rather than
  promoted to a direct dependency; the lockfile resolves 3.3.18.
- MEDIUM, unpinned pip command: the publish step installed build/twine by
  version only, leaving the whole transitive graph resolved at run time.
  pkg/pypi/requirements-publish.txt now hash-pins the complete toolchain (316
  hashes), generated on a linux/amd64 python:3.12 image so the wheels match what
  ubuntu-latest resolves, and the step runs pip with --require-hashes. Verified
  by installing from it in that same image.

Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
2026-08-11 13:37:32 +02:00

297 lines
16 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Security Policy
## Transparency & Disclaimer
codebase-memory-mcp interacts deeply with your filesystem. It reads source files across your entire codebase, writes to agent configuration files, and spawns background processes. This is inherent to what it does — not a bug.
**If you are uncomfortable with these access patterns**, please audit the source code before running. The full source is available in this repository. Release archives produced by the current release pipeline are verifiably built from this source and can be independently verified via SLSA Build Level 3 provenance, Sigstore signatures, and SHA-256 checksums (see [Verification](#verification) below). Each archive contains a native executable and its authenticated release-owned runtime assets.
We are humans and can make mistakes. We take security seriously — it is Priority #1 for this project — but we cannot guarantee perfection. By using this software you accept responsibility for evaluating whether it meets your own security requirements.
## Runtime Network Behavior
Indexing, graph queries, semantic search, and MCP tool handling run locally. The
MCP server does not upload source code, repository paths, graph indexes, query
contents, environment variables, usage metrics, or telemetry.
The MCP server has one best-effort external runtime check: after MCP
`initialize`, it starts a background update-check thread that requests release
metadata from
`https://api.github.com/repos/DeusData/codebase-memory-mcp/releases/latest`.
That request is used only to show an update notice when a newer release exists.
It sends no project data; only standard HTTPS metadata, such as the destination
host and the normal `curl` request headers, are visible to GitHub and the
network path.
The update check is non-blocking for MCP startup and tool calls. If the machine
is offline, DNS fails, GitHub is unreachable, or `curl` exits with an error, the
check is ignored. The request is also bounded with `curl --max-time 5`; a
process shutting down immediately while the check is still running may wait for
that bounded background thread to finish.
Explicit install, package-manager, and `codebase-memory-mcp update` flows are
separate user-initiated network operations that download release assets and
checksums from GitHub.
## Help Us Stay Secure
**We actively invite security researchers to try to break this project.**
If you find a vulnerability — anything from a logic bug to a remote code execution — we want to know. You will receive a fast response, public credit (if you want it), and the knowledge that you helped make a tool used by developers worldwide more secure.
What we consider in scope:
- Arbitrary code execution via MCP tool inputs or CLI arguments
- File reads or writes outside the indexed project root
- Shell injection through any code path
- Binary tampering or supply chain attacks
- Privilege escalation or sandbox escapes
Please report **privately** rather than as a public issue so we can fix before public disclosure. See below for how.
## Reporting a Vulnerability
If you discover a security vulnerability, please report it **privately** so we
can fix it before public disclosure:
1. **Do NOT open a public issue, PR, or social-media post** for security
vulnerabilities.
2. **Preferred:** use GitHub's [private vulnerability reporting](https://github.com/DeusData/codebase-memory-mcp/security/advisories/new)
(the repository's **Security → Report a vulnerability** button). This keeps
everything in one place and starts a private advisory automatically.
3. **Alternative:** email martin.vogel.tech@gmail.com.
4. Include: description, reproduction steps, affected version, and potential
impact.
5. Include your **GitHub handle and a contact email**. We use these to credit
you and to invite you (read-only) to privately verify the fix before its
release — see step 4 of the
[handling process](docs/SECURITY-DISCLOSURE.md#what-happens-after-you-report).
Let us know if you would prefer to remain anonymous.
> **This is a solo, volunteer-maintained project, so security handling is
> best-effort.** As good-faith targets — not guarantees — we aim to:
>
> - **acknowledge** your report within **7 days** (usually much sooner);
> - give an **initial assessment and severity** within **14 days**;
> - **develop, validate, and release a fix** as quickly as the severity
> warrants — typically within **90 days**, and expedited for high-severity
> issues.
>
> If something will take longer, we will tell you and keep you updated.
We follow **coordinated disclosure**: fixes are developed privately, validated
across all supported platforms, released, and only then disclosed publicly via a
[GitHub Security Advisory](https://github.com/DeusData/codebase-memory-mcp/security/advisories)
with a **CVE** and credit to you. The full handling process — including how you
can verify the fix before release — is documented in
[`docs/SECURITY-DISCLOSURE.md`](docs/SECURITY-DISCLOSURE.md).
### Safe harbor
We will not pursue or support legal action against researchers who act in good
faith — accessing only their own test data, avoiding privacy violations and
service disruption, and giving us reasonable time to fix before public
disclosure. Research conducted under this policy is considered authorised.
## Security Measures
This project implements multiple layers of security verification. Every release archive is signed and checksummed, and every extracted runtime object must pass its applicable checks before users can download it (draft → verify → publish flow).
### Build-Time (CI — every commit)
- **8-layer security audit suite** runs on every build:
- Layer 1: Static allow-list for dangerous calls (`system`/`popen`/`fork`) + hardcoded URLs
- Layer 2: Binary string audit (URLs, credentials, dangerous commands)
- Layer 3: Network egress monitoring via strace (Linux)
- Layer 4: Install output path + content validation
- Layer 5: Smoke test hardening (clean shutdown, residual processes, version integrity)
- Layer 6: Graph UI audit (external domains, CORS, server binding, eval/iframe)
- Layer 7: MCP robustness (23 adversarial JSON-RPC payloads)
- Layer 8: Vendored dependency integrity (SHA-256 checksums, dangerous call scan)
- **All dangerous function calls** require a reviewed entry in `scripts/security-allowlist.txt`
- **Time-bomb pattern detection** — scans for `time()`/`sleep()` near dangerous calls (could indicate delayed activation)
- **MCP tool handler file read audit** — tracks file read count in `mcp.c` against an expected maximum (detects added file reads that could exfiltrate data through tool responses)
- **CodeQL SAST** — static application security testing on every push (taint analysis, CWE detection, data flow tracking). Any open alert blocks the release.
- **Fuzz testing** — random/mutated inputs to MCP server and Cypher parser (60 seconds per build). Catches crashes, segfaults, and memory errors that structured tests miss.
- **Native antivirus scanning** on every platform (any detection fails the build):
- **Windows**: Windows Defender with ML heuristics — the same engine end users run
- **Linux**: ClamAV with daily signature updates
- **macOS**: ClamAV with daily signature updates
### Release-Time (draft → verify → publish)
Releases are created as **drafts** (invisible to users) and only published after all verification passes:
1. **SLSA Build Level 3 provenance for release archives** — cryptographic attestation generated inside the trusted GitHub Actions build workflow immediately after each release archive is produced
2. **Sigstore cosign signing** — keyless digital signatures verifiable by anyone
3. **SBOM** — Software Bill of Materials (SPDX) listing all vendored dependencies
4. **SHA-256 checksums** — published with every release
5. **VirusTotal scanning** — every distinct extracted member and unpacked UI asset is scanned; downloadable `.tar.gz`/`.zip` containers are not submitted. Each completed analysis must contain at least 50 decisive engine results, zero malicious verdicts, and zero suspicious verdicts. Release notes retain archive SHA-256 provenance and link durable public association, exact-scan-set, per-object-result, and evidence-checksum assets.
6. **OpenSSF Scorecard** — repository security health score
Scope of the SLSA claim: this is a build provenance claim for release
artifacts. It proves the attested archive was produced by the repository's
trusted GitHub-hosted build workflow from repository source. It is not
third-party certification, it is not retroactive to older releases, and it does
not mean the source code is vulnerability-free or that maintainers cannot change
source. Consumers should verify the signer workflow, not only repository
ownership.
If any antivirus engine flags any scanned release object, the release stays as a
draft and is not published until the issue is investigated and resolved. There
is no exception path in this release gate.
### Code-Level Defenses
- **Shell injection prevention** — `cbm_validate_shell_arg()` rejects metacharacters before all `popen()`/`system()` calls
- **SQLite authorizer** — blocks `ATTACH`/`DETACH` at engine level (prevents file creation via SQL injection)
- **CORS locked to localhost** — graph UI only accessible from localhost origins
- **Path containment** — `realpath()` check prevents reading files outside project root
- **Process-kill restriction** — only server-spawned PIDs can be terminated
- **Release-set verification** — installers verify the downloaded archive's exact
member set and SHA-256 before the candidate executable is activated
### Verification
Users can independently verify any release archive and the runtime set it contains:
```bash
# SLSA Build Level 3 provenance for release archives
gh attestation verify <downloaded-file> \
--repo DeusData/codebase-memory-mcp \
--signer-workflow DeusData/codebase-memory-mcp/.github/workflows/_build.yml
# Sigstore cosign (keyless signature)
cosign verify-blob --bundle <file>.bundle <file>
# SHA-256 checksum
sha256sum -c checksums.txt
# VirusTotal (follow the durable per-object results link in the release notes)
# https://www.virustotal.com/
```
## Antivirus False Positives
Some release binaries are reported by **one** engine — Microsoft — as
`Trojan:Script/Wacatac.B!ml`. We believe this is a false positive, we do not hide
it, and this section exists so you can check that judgement yourself rather than
take our word for it.
### What the detection is
The `!ml` suffix marks a **machine-learning / heuristic** classification, not a
signature match. The `Script` token is a generic bucket in that naming scheme and
says nothing about script content — GitHub's own `gh` CLI and Anthropic's Claude
installer have both carried `Trojan:Script/Wacatac.H!ml` on native binaries.
Typically 61 of ~62 engines on VirusTotal return clean for the same file.
### What we measured
We dissected a full release matrix built from one commit. The verdicts split
across every axis at once:
| Binary | Link | Verdict |
|---|---|---|
| linux-amd64 | dynamic | flagged |
| linux-amd64-portable | static | clean |
| linux-arm64 | dynamic | clean |
| linux-arm64-portable | static | flagged |
| darwin-amd64 | — | flagged |
| darwin-arm64 | — | clean |
| windows amd64 / arm64 | — | clean |
The static/dynamic axis **inverts** between architectures, so no build or link
property explains it. The two macOS binaries have identical segment structure and
still split. Sibling artifacts from one build landed in *different* variant
buckets (`.B` vs `.C`).
We also tested and rejected the obvious structural hypothesis: entropy is low
everywhere (embedded vectors 4.17, parse tables 3.46 bits/byte, against 7.5–8.0
for genuinely packed payloads), so the binary does not resemble a packed dropper.
### What we changed, and what we reverted
We removed every embedded shell script from the binary and moved the UI bundle
and the agent integration templates out into separate verified files. **The
detection count did not drop** — it simply moved between artifacts. We reverted
both changes rather than keep permanent complexity that bought nothing. We are
documenting that here because a negative result is still evidence.
### This is endemic, not specific to us
The same `!ml` family repeatedly hits large, unsigned, native open-source
binaries:
- [llama.cpp #15874](https://github.com/ggml-org/llama.cpp/issues/15874),
[#24487](https://github.com/ggml-org/llama.cpp/issues/24487),
[#24558](https://github.com/ggml-org/llama.cpp/issues/24558) — including one
DLL of many in a single archive, with nothing found on reverse engineering
- [GitHub CLI #13306](https://github.com/cli/cli/issues/13306)
- [Microsoft's own Go toolchain #1255](https://github.com/microsoft/go/issues/1255)
- [Anthropic Claude Code #36796](https://github.com/anthropics/claude-code/issues/36796)
- [yt-dlp #7532](https://github.com/yt-dlp/yt-dlp/issues/7532),
[Godot #110612](https://github.com/godotengine/godot/issues/110612),
[PyInstaller #5854](https://github.com/pyinstaller/pyinstaller/issues/5854),
[Tauri #2486](https://github.com/tauri-apps/tauri/issues/2486),
[OpenAI Codex #2228](https://github.com/openai/codex/issues/2228),
[rust-lang/rust #88297](https://github.com/rust-lang/rust/issues/88297)
A Microsoft engineer on the Go team [put it plainly](https://github.com/microsoft/go/issues/1255):
*"we're aware of Windows Security/Defender issues with Go apps… we can't exactly
go fix something and solve all Go false positives."*
### Why we do not obfuscate around it
Deliberately reshaping a binary to avoid a classifier is what malware does, and
it measurably backfires — the same Microsoft engineer reports that obfuscation
*"increases scrutiny rather than avoiding it."* We would rather be scannable and
explain a false positive than be unreadable and score well.
### Verify it yourself
Every release ships the material needed to check our artifacts independently.
Use the commands in [Verification](#verification) above: SLSA Build Level 3
provenance ties the archive to the workflow run that produced it, Sigstore cosign
verifies the signature, and `checksums.txt` pins the bytes. The release notes
carry a durable per-object VirusTotal link for every scanned file, including any
tolerated detection — we publish those results whether or not they are clean.
You can also rebuild from source and compare: `scripts/build.sh --with-ui`
produces the shipped composition.
### Our release policy
A release may ship with **at most one** detection, and only when the engine is
Microsoft and the label ends in `!ml`. Two or more engines, any signature-based
label, any other vendor, or any "suspicious" verdict blocks the release. That
rule is enforced in `scripts/ci/check-virustotal.sh` and pinned by
`tests/test_vt_gate_policy_contract.sh`.
### If you find something real
We would genuinely rather be wrong in public than confidently wrong. If you find
anything that explains or contradicts the assessment above:
- Open an issue with the **`av-analysis`** label — include the artifact SHA-256,
the engine and label, and what you found.
- If it looks like an actual compromise rather than a classifier artifact, use
the private process in [Reporting a Vulnerability](#reporting-a-vulnerability)
instead.
A concrete finding changes our position. Signing is on the roadmap and will help
on Windows, but note that no code-signing scheme exists that AV engines honour
for Linux ELF binaries, so it is not a complete answer either.
## Supported Versions
| Version | Supported |
|---------|-----------|
| Latest `0.10.x` | Yes — security fixes land in the newest release |
| < 0.10 | No — please upgrade to the latest release |
Only the latest release is supported. Security fixes are shipped in a new
patched release rather than backported to older versions; upgrading to the
newest version is the supported path to receive them.