Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(ci): allow-list MSYS2 toolchain URL in binary string audit

Martin Vogel170d5a82ab4d
diff --git a/scripts/security-strings.sh b/scripts/security-strings.sh
index 06e44ea9e..26cb4e34f 100755
--- a/scripts/security-strings.sh
+++ b/scripts/security-strings.sh
@@ -81,6 +81,9 @@ ALLOWED_URLS=(
"https://bugs.launchpad.net"
"https://gcc.gnu.org"
"https://sourceware.org"
+ # MSYS2 CLANG64 toolchain (libc++/compiler-rt) package-tracker URL, baked
+ # into the static Windows .exe — Windows-only, hence Linux smoke stays clean.
+ "https://github.com/msys2/MINGW-packages"
# W3C XML namespace URIs (SVG, MathML, XLink — used in UI bundle)
"http://www.w3.org/"
# UI bundle: React, Three.js, Tailwind, Google Fonts, bundled libraries
diff --git a/scripts/test.sh b/scripts/test.sh
index 6b03f8618..62210b426 100755
--- a/scripts/test.sh
+++ b/scripts/test.sh
@@ -75,4 +75,10 @@ echo "=== Step 5: parent-death watchdog regression (#406/#407) ==="
$ARCH_PREFIX make -j"$NPROC" -f Makefile.cbm cbm $MAKE_ARGS
bash "$ROOT/tests/test_parent_watchdog.sh"
+# Step 6: security-strings URL allow-list regression. The MSYS2 CLANG64 toolchain
+# bakes its package-tracker URL into the static Windows .exe; the binary string
+# audit must allow-list it (Windows-only — Linux smoke never saw it).
+echo "=== Step 6: security-strings allow-list regression ==="
+bash "$ROOT/tests/test_security_strings_allowlist.sh"
+
echo "=== All tests passed ==="
diff --git a/tests/test_security_strings_allowlist.sh b/tests/test_security_strings_allowlist.sh
new file mode 100755
index 000000000..03305ac9e
--- /dev/null
+++ b/tests/test_security_strings_allowlist.sh
@@ -0,0 +1,67 @@
+#!/usr/bin/env bash
+# Regression guard: scripts/security-strings.sh must allow-list the MSYS2/MinGW
+# toolchain URL that the CLANG64 toolchain embeds into the static Windows binary
+# (https://github.com/msys2/MINGW-packages).
+#
+# Reproduces the smoke-windows dry-run failure:
+# BLOCKED: Unauthorized URL in binary: https://github.com/msys2/MINGW-packages
+# === BINARY STRING AUDIT FAILED ===
+#
+# Root cause: the URL audit's hardcoded ALLOWED_URLS list did not include the
+# MSYS2 package-tracker URL. That URL is a toolchain artifact, analogous to the
+# gcc.gnu.org / sourceware.org / bugs.launchpad.net entries already allow-listed,
+# and only appears in the Windows (.exe) build — hence Linux smoke stayed green.
+#
+# The negative-control case proves the fix does not weaken the audit: a genuinely
+# unauthorized URL must still be BLOCKED.
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
+SCRIPT="$ROOT/scripts/security-strings.sh"
+
+TMP="$(mktemp -d)"
+trap 'rm -rf "$TMP"' EXIT
+
+# Build a fixture that `file` classifies as binary "data" (NOT text/script), so
+# security-strings.sh runs the URL audit (it intentionally skips the URL audit
+# for script/text files). Leading non-printable bytes + NUL separators => data.
+make_fixture() {
+ local out="$1"; shift
+ printf '\x00\x01\x02\x03\x04\x05\x06\x07\xff\xfe\xfd\xfc' > "$out"
+ local s
+ for s in "$@"; do
+ printf '%s\x00' "$s" >> "$out"
+ done
+ printf '\x00\x00\x00\x00\xff\xff\xff\xff' >> "$out"
+}
+
+PASS=0
+FAIL=0
+
+# ── Case 1 (the bug): toolchain URL present => audit MUST pass (exit 0) ──
+GOOD="$TMP/good.bin"
+make_fixture "$GOOD" \
+ "https://github.com/DeusData/codebase-memory-mcp" \
+ "https://github.com/msys2/MINGW-packages"
+if bash "$SCRIPT" "$GOOD" >/dev/null 2>&1; then
+ echo "PASS: MSYS2 toolchain URL https://github.com/msys2/MINGW-packages is allow-listed"
+ PASS=$((PASS + 1))
+else
+ echo "FAIL: security-strings.sh blocked the MSYS2 toolchain URL (regression)"
+ bash "$SCRIPT" "$GOOD" 2>&1 | grep -i "BLOCKED" || true
+ FAIL=$((FAIL + 1))
+fi
+
+# ── Case 2 (negative control): unauthorized URL MUST still be blocked ──
+BAD="$TMP/bad.bin"
+make_fixture "$BAD" "https://evil.example.com/exfil-payload-endpoint"
+if bash "$SCRIPT" "$BAD" >/dev/null 2>&1; then
+ echo "FAIL: unauthorized URL https://evil.example.com was NOT blocked (audit weakened)"
+ FAIL=$((FAIL + 1))
+else
+ echo "PASS: unauthorized URL https://evil.example.com still blocked"
+ PASS=$((PASS + 1))
+fi
+
+echo "=== security-strings allow-list test: $PASS passed, $FAIL failed ==="
+[ "$FAIL" -eq 0 ]