Skip to content

Commit 673e523

Browse files
committed
fix(security-strings): audit .mcpb manifests as structured text, not as binaries
The v0.10.3 release failed its `verify` gate: --- Auditing: scan-...--manifest.json --- BLOCKED: Unauthorized URL in binary: https://github.com/DeusData BLOCKED: Unauthorized URL in binary: https://deusdata.github.io/... === BINARY STRING AUDIT FAILED === The blocked URLs are OURS — the .mcpb bundle manifest's own homepage and documentation fields. security-strings.sh already knows that URL and dangerous-command auditing are "designed for compiled artifacts" and skips them for text, keeping the credential and base64 audits that are universally meaningful. Its detection just had no case for JSON: `file` reports "JSON data", which matched none of the shell-script/ASCII-text patterns, so a manifest was audited as if it were a compiled binary. An MCP manifest is exactly the shape that misfires — it carries project URLs by design, and a `command` field by specification. This is the first release to ship .mcpb bundles, which is why it surfaced now: it is the first time a manifest reached the scanned object set. The bundles were noted as end-to-end unproven until a stable release; this is that proof doing its job. Two changes: - Classify structured-text artifacts by extension FIRST (.json/.yaml/.toml/ .md/...), then by `file` type with JSON/XML added. The extension check also covers hosts without file(1), where the existing `command -v` guard silently left every artifact classified as binary. - Allow-list our own org root and documentation site, so a compiled binary embedding the docs link (the graph UI does) passes on its own merits rather than relying on the text exemption. Tests: the manifest case, plus a control proving the exemption is narrow — the credential audit still runs on structured text. The existing negative control (an unauthorized URL in a real binary is still BLOCKED) is unchanged and still passes, so the binary audit is not weakened. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 70a9539 commit 673e523

2 files changed

Lines changed: 58 additions & 2 deletions

File tree

‎scripts/security-strings.sh‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,20 @@ FAIL=0
3131
# audits which are designed for compiled artifacts. Script content is
3232
# reviewed in PRs and scanned end-to-end by VirusTotal in the same pipeline.
3333
IS_SCRIPT=false
34-
if command -v file &>/dev/null; then
34+
# Structured-text artifacts by EXTENSION first: `file` reports JSON as
35+
# "JSON data" / "JSON text data", which matched none of the text patterns
36+
# below, so an .mcpb bundle manifest was audited as if it were a compiled
37+
# binary and its own homepage/documentation URLs were BLOCKED as unauthorized.
38+
# The extension check also covers hosts where file(1) is absent, where the
39+
# `command -v` guard below silently leaves every artifact classified as binary.
40+
case "$BINARY" in
41+
*.json|*.jsonc|*.yaml|*.yml|*.toml|*.md|*.txt) IS_SCRIPT=true ;;
42+
esac
43+
if [ "$IS_SCRIPT" = false ] && command -v file &>/dev/null; then
3544
FILE_TYPE=$(file -b "$BINARY" 2>/dev/null || echo "")
3645
case "$FILE_TYPE" in
37-
*"shell script"*|*"ASCII text"*|*"UTF-8 Unicode text"*|*"Unicode text"*|*"a /usr/bin/env"*)
46+
*"shell script"*|*"ASCII text"*|*"UTF-8 Unicode text"*|*"Unicode text"*|*"a /usr/bin/env"*|\
47+
*"JSON"*|*"XML"*)
3848
IS_SCRIPT=true
3949
;;
4050
esac
@@ -72,6 +82,10 @@ echo "--- URL audit ---"
7282
ALLOWED_URLS=(
7383
"https://api.github.com/repos/DeusData/codebase-memory-mcp"
7484
"https://github.com/DeusData/codebase-memory-mcp"
85+
# Our own org root and documentation site: the .mcpb bundle manifest carries
86+
# them as homepage/documentation fields, and the graph UI links the docs.
87+
"https://github.com/DeusData"
88+
"https://deusdata.github.io/codebase-memory-mcp"
7589
"http://127.0.0.1"
7690
"http://localhost"
7791
# SQLite internal URLs (part of vendored sqlite3 strings)

‎tests/test_security_strings_allowlist.sh‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,47 @@ else
6363
PASS=$((PASS + 1))
6464
fi
6565

66+
# ── Case 3: an .mcpb bundle manifest must not be audited as a compiled binary ──
67+
# `file` reports JSON as "JSON data", which matched none of the text patterns, so
68+
# the manifest was run through the URL audit and its own homepage/documentation
69+
# fields were BLOCKED as unauthorized. This blocked the v0.10.3 release — the
70+
# first release to ship .mcpb bundles, hence the first time a manifest reached
71+
# the scanned object set.
72+
MANIFEST="$TMP/manifest.json"
73+
cat > "$MANIFEST" <<'JSON'
74+
{
75+
"name": "codebase-memory-mcp",
76+
"homepage": "https://github.com/DeusData/codebase-memory-mcp",
77+
"documentation": "https://deusdata.github.io/codebase-memory-mcp/",
78+
"server": { "command": "codebase-memory-mcp", "args": [] }
79+
}
80+
JSON
81+
if bash "$SCRIPT" "$MANIFEST" >/dev/null 2>&1; then
82+
echo "PASS: .mcpb manifest.json audited as structured text, not as a binary"
83+
PASS=$((PASS + 1))
84+
else
85+
echo "FAIL: manifest.json still audited as a compiled binary (regression)"
86+
bash "$SCRIPT" "$MANIFEST" 2>&1 | grep -i "BLOCKED" || true
87+
FAIL=$((FAIL + 1))
88+
fi
89+
90+
# ── Case 4 (negative control for case 3): the exemption is by FILE TYPE, not a
91+
# blanket pass. A binary carrying an unauthorized URL must still be blocked even
92+
# though a .json carrying one would not be — that asymmetry is the design, and
93+
# case 2 above proves the binary half still holds. Here we prove the credential
94+
# audit still runs on structured text, so the exemption is narrow. ──
95+
CREDS="$TMP/creds.json"
96+
# The credential audit matches assignment syntax (api_key=, secret=, ...), which
97+
# is what leaks look like in embedded strings — so the fixture uses that form
98+
# inside the JSON value rather than a JSON "key": "value" pair.
99+
printf '{"connection":"host=db user=admin password=hunter2-not-a-real-secret"}' > "$CREDS"
100+
if bash "$SCRIPT" "$CREDS" >/dev/null 2>&1; then
101+
echo "FAIL: credential pattern in JSON was NOT flagged (exemption too broad)"
102+
FAIL=$((FAIL + 1))
103+
else
104+
echo "PASS: credential audit still runs on structured text"
105+
PASS=$((PASS + 1))
106+
fi
107+
66108
echo "=== security-strings allow-list test: $PASS passed, $FAIL failed ==="
67109
[ "$FAIL" -eq 0 ]

0 commit comments

Comments
 (0)