Skip to content

Commit 3305c1f

Browse files
committed
fix(security): widen release audit to all files in binaries/
Previously the verify job only ran scripts/security-strings.sh on files matching binaries/codebase-memory-mcp* — install.sh, install.ps1, LICENSE, and any future companion files in the release archives were NOT covered by the binary-string audit (only by VirusTotal). Changes: - release.yml: loop over binaries/* (every file in the audit set). - security-strings.sh: detect file type via 'file -b'. For shell scripts and other text files, skip the URL audit and dangerous-cmd audit (those rules are tuned for compiled binaries — install.sh legitimately uses wget as a curl fallback, and 'case https://*)' globs look like unauthorized URLs to a strings dump). Always run credential and base64 pattern audits — those are universally meaningful regardless of file type. - Verified locally: install.sh and install.ps1 now both pass. Net effect: every release artifact is now audited, with rule sets appropriate to its file type.
1 parent 2ab901f commit 3305c1f

2 files changed

Lines changed: 48 additions & 9 deletions

File tree

.github/workflows/release.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -197,12 +197,18 @@ jobs:
197197
cp install.ps1 binaries/ 2>/dev/null || true
198198
ls -la binaries/
199199
200-
- name: Security audits on all release binaries
200+
- name: Security audits on all release files
201201
run: |
202-
for bin in binaries/codebase-memory-mcp*; do
203-
[ -f "$bin" ] || continue
204-
echo "--- Auditing: $(basename "$bin") ---"
205-
scripts/security-strings.sh "$bin"
202+
# Audit every file that ships in the release archives — binaries,
203+
# install scripts, LICENSE, and any future companion files.
204+
# security-strings.sh detects file type and applies binary-only
205+
# rules (URL allowlist, dangerous-command detection) only to real
206+
# binaries; for shell scripts it still runs credential and base64
207+
# pattern audits.
208+
for f in binaries/*; do
209+
[ -f "$f" ] || continue
210+
echo "--- Auditing: $(basename "$f") ---"
211+
scripts/security-strings.sh "$f"
206212
done
207213
208214
- name: VirusTotal scan

scripts/security-strings.sh

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,32 @@ fi
2020

2121
FAIL=0
2222

23-
echo "=== Layer 2: Binary String Audit ==="
24-
echo "Binary: $BINARY"
23+
# Detect file type. Shell scripts and other text files extract poorly via
24+
# `strings` (the entire content becomes the "strings"), and rules tuned for
25+
# compiled binaries (URL allowlist, wget/telnet detection) produce false
26+
# positives — install.sh legitimately uses `wget` as a curl fallback, and
27+
# `case` glob patterns like `https://*` look like unauthorized URLs.
28+
#
29+
# Strategy: for non-binary files we still run credential and base64 audits
30+
# (those are universally meaningful), but skip the URL and dangerous-command
31+
# audits which are designed for compiled artifacts. Script content is
32+
# reviewed in PRs and scanned end-to-end by VirusTotal in the same pipeline.
33+
IS_SCRIPT=false
34+
if command -v file &>/dev/null; then
35+
FILE_TYPE=$(file -b "$BINARY" 2>/dev/null || echo "")
36+
case "$FILE_TYPE" in
37+
*"shell script"*|*"ASCII text"*|*"UTF-8 Unicode text"*|*"Unicode text"*|*"a /usr/bin/env"*)
38+
IS_SCRIPT=true
39+
;;
40+
esac
41+
fi
42+
43+
if $IS_SCRIPT; then
44+
echo "=== Layer 2: Script Content Audit ==="
45+
else
46+
echo "=== Layer 2: Binary String Audit ==="
47+
fi
48+
echo "File: $BINARY"
2549
echo ""
2650

2751
# Check for strings command (needs binutils on some MSYS2 setups)
@@ -37,8 +61,11 @@ SEC_CREDS=$(mktemp)
3761
trap 'rm -f "$STRINGS_FILE" "$SEC_CMDS" "$SEC_CREDS"' EXIT
3862
strings -n 4 "$BINARY" | sort -u > "$STRINGS_FILE"
3963

40-
# ── 1. URL audit ─────────────────────────────────────────────────
64+
# ── 1. URL audit (binary only — scripts handled via VT + PR review) ────
4165

66+
if $IS_SCRIPT; then
67+
echo "--- URL audit (skipped — script file) ---"
68+
else
4269
echo "--- URL audit ---"
4370

4471
# Allowed URL prefixes
@@ -93,6 +120,7 @@ done < <(grep -oE 'https?://[a-zA-Z0-9._/~:@!$&()*+,;=?#%[-]+' "$STRINGS_FILE" |
93120
if [[ $FAIL -eq 0 ]]; then
94121
echo "OK: All URLs are authorized."
95122
fi
123+
fi # end !IS_SCRIPT URL audit
96124

97125
# ── 2. Base64 payload detection ──────────────────────────────────
98126

@@ -111,9 +139,13 @@ else
111139
echo "OK: No suspicious base64 payloads found."
112140
fi
113141

114-
# ── 3. Dangerous command detection ───────────────────────────────
142+
# ── 3. Dangerous command detection (binary only) ─────────────────
115143

116144
echo ""
145+
if $IS_SCRIPT; then
146+
echo "--- Dangerous command detection (skipped — script file) ---"
147+
DANGEROUS_CMDS=''
148+
else
117149
echo "--- Dangerous command detection ---"
118150

119151
DANGEROUS_CMDS='wget|netcat|ncat|/dev/tcp|telnet'
@@ -136,6 +168,7 @@ if [ -s "$SEC_CMDS" ]; then
136168
else
137169
echo "OK: No dangerous commands found."
138170
fi
171+
fi # end !IS_SCRIPT dangerous-cmd audit
139172

140173
# ── 4. Credential pattern detection ──────────────────────────────
141174

0 commit comments

Comments
 (0)