Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

fix(security): pin binary-asset-hashes.txt in CODEOWNERS and correct digest-mismatch remediation text (#6188)

LearningCircuitd6b1ee2ef697
diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 530c575e4c..13839ab51a 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -131,4 +131,5 @@
/.file-whitelist.txt @LearningCircuit
/.pre-commit-hooks/file-whitelist-check.sh @LearningCircuit
/.github/scripts/file-whitelist-check.sh @LearningCircuit
+/.github/security/binary-asset-hashes.txt @LearningCircuit
/.github/CODEOWNERS @LearningCircuit
diff --git a/.github/scripts/file-whitelist-check.sh b/.github/scripts/file-whitelist-check.sh
index b30f145341..518674a63a 100755
--- a/.github/scripts/file-whitelist-check.sh
+++ b/.github/scripts/file-whitelist-check.sh
@@ -312,6 +312,8 @@ FILES_CHECKED=0
WHITELIST_VIOLATIONS=()
LARGE_FILES=()
BINARY_FILES=()
+BINARY_REASONS=()
+HAS_NON_DIGEST_BINARY_VIOLATION=false
CONTENT_CHECK_FILES=()
SUSPICIOUS_FILES=()
RESEARCH_DATA_VIOLATIONS=()
@@ -511,10 +513,12 @@ CONTENT_SCAN_OUTPUT=""
if ! CONTENT_SCAN_OUTPUT=$(check_file_contents "$REPO_ROOT" "${CONTENT_CHECK_FILES[@]}"); then
if [ -z "$CONTENT_SCAN_OUTPUT" ]; then
BINARY_FILES+=("<content scanner> (failed without diagnostics)")
+BINARY_REASONS+=("")
else
while IFS=$'\t' read -r binary_path reason; do
[ -z "$binary_path" ] && continue
BINARY_FILES+=("$binary_path ($reason)")
+BINARY_REASONS+=("$reason")
done <<< "$CONTENT_SCAN_OUTPUT"
fi
fi
@@ -591,10 +595,48 @@ echo ""
echo "❌ UNEXPECTED BINARY CONTENT - Files must be reviewable UTF-8 text:"
echo " Only the six exact, pre-existing PNG/MP3 assets are content exceptions."
echo ""
-for violation in "${BINARY_FILES[@]}"; do
+for i in "${!BINARY_FILES[@]}"; do
+violation="${BINARY_FILES[$i]}"
+reason="${BINARY_REASONS[$i]}"
echo " 🔒 $violation"
+# check_file_contents() reports two distinct failures through this same
+# array: a binary blob at a path that was never allowed to be binary, and
+# a byte-for-byte mismatch at one of the six paths that IS allowed to be
+# binary (pinned_digest_mismatch_reason() -- its message always contains
+# "does not match its pinned digest"). Those need different remediation:
+# the first says remove the file, which is actively wrong advice for the
+# second (a legitimate asset update that just forgot to regenerate the
+# digest file).
+#
+# Branch on $reason rather than $violation (which is
+# "$binary_path ($reason)" -- an attacker-chosen path is concatenated in
+# front of the reason, so matching against the combined string lets a
+# crafted filename spoof the digest-mismatch branch even for a genuine
+# unauthorized-binary violation).
+#
+# This NARROWS the taint, it does not eliminate it. $reason is not
+# guaranteed to be the classifier's own message: the producer joins
+# fields with a tab and `IFS=$'\t' read -r binary_path reason` assigns
+# everything after the FIRST tab to $reason, so a filename containing a
+# tab still lands attacker-controlled text there and can reach the
+# digest-mismatch branch. That path is currently unreachable only
+# because a file whose name contains a control character is skipped
+# earlier: the `git ls-files` / `git diff --name-only` calls at :328-334
+# run without `-z`, so with default core.quotePath such paths arrive
+# C-quoted, fail the `[ ! -f "$file" ]` test, and are dropped before any
+# check runs. That upstream skip is itself a fail-open, tracked in #6212
+# -- do not treat it as the defence here. Either fix makes
+# this branch sound; neither alone is a reason to call $reason clean.
+# Note the blast radius is advisory text only: every branch here prints
+# guidance, and none of them changes the exit code.
+if [[ "$reason" == *"does not match its pinned digest"* ]]; then
+echo " → Issue: Content at an approved binary asset path does not match its pinned SHA-256 digest"
+echo " → Fix: Do NOT remove the file. If this is an intentional asset update, regenerate ALL SIX digests in the SAME PR as the byte change so the change is reviewed (see command in the reason above)"
+else
echo " → Issue: Binary content appeared outside an approved binary asset path"
echo " → Fix: Remove it; renaming a binary to an allowed extension is not permitted"
+HAS_NON_DIGEST_BINARY_VIOLATION=true
+fi
echo ""
done
TOTAL_VIOLATIONS=$((TOTAL_VIOLATIONS + ${#BINARY_FILES[@]}))
@@ -830,9 +872,16 @@ else
echo ""
echo "💡 To fix these issues:"
echo " - For text/config files: add pattern to .file-whitelist.txt (requires maintainer approval)"
+# Only show the generic "don't add binary files" advice when there is an
+# actual unauthorized-binary-content or whitelist violation to fix that
+# way. Showing it unconditionally would contradict the per-violation
+# "Do NOT remove the file" guidance above when the only BINARY_FILES
+# entries are digest mismatches at already-approved binary paths.
+if [ ${#WHITELIST_VIOLATIONS[@]} -gt 0 ] || [ "$HAS_NON_DIGEST_BINARY_VIOLATION" = true ]; then
echo " - For binary files (images, audio, video, archives): do NOT add to the repo"
echo " Binary files permanently bloat git history. Store them externally instead."
echo " Only a small set of explicitly listed binary files is permitted."
+fi
echo " - Use environment variables for secrets"
echo " - Never hardcode research data or session IDs"
echo " - Use .env.example files instead of .env"
diff --git a/tests/security/test_repo_guardrails.py b/tests/security/test_repo_guardrails.py
index f29af0d0ba..2994642368 100644
--- a/tests/security/test_repo_guardrails.py
+++ b/tests/security/test_repo_guardrails.py
@@ -131,6 +131,7 @@ CODEOWNERS_GUARDRAIL_PATHS = {
"/.file-whitelist.txt",
"/.pre-commit-hooks/file-whitelist-check.sh",
"/.github/scripts/file-whitelist-check.sh",
+ "/.github/security/binary-asset-hashes.txt",
"/.github/CODEOWNERS",
}