Skip to content

#4126: narrow disguised-executable detector, wired into census and worker - #4129

Merged
squid-protocol merged 3 commits into
mainfrom
fix/extension-mismatch-4126
Oct 3, 2026
Merged

squid-protocol merged 3 commits into
mainfrom
fix/extension-mismatch-4126

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Oct 2, 2026 •

Copy link
Copy Markdown
Owner

Fixes #4126

Problem

threat_extension_mismatch was 0 everywhere because the Binary Analysis Sensor could not fire. Two disconnections:

  1. The worker tested the aperture reason for wording that Gate 1.3 stopped emitting in 3477c48.
  2. More fundamentally, the census routes every denied-extension file straight to the unparsable list, so no worker ever saw one.

Restoring the old wide check (scan_binary) would have flagged 10.5% of ordinary denied files: compressed images, LFS pointers, image-format mislabels.

Change

  • security_lens.detect_disguised_executable() (narrow). Flags executable magic only at offset 0: ELF; PE verified through e_lfanew, plus NE/LE/LX; a self-consistent DOS MZ; Mach-O; Java class; wasm. It fires only under an extension that claims an inert format, so image aliasing, LFS pointers and empty files can't fire by construction.
  • aperture: structured reason. ApertureReason is a str carrying .kind, and survives pickling. Gate 1.3 returns kind == DENIED_EXTENSION; the message text is unchanged.
  • Census (git and filesystem walk). A denied file with executable magic under an inert extension is dispatched. It joins the dispatch maps only, not the language census or the extension tallies.
  • Worker. Gates on reason.kind and calls detect_disguised_executable instead of scan_binary; scan_binary stays for binary_anomaly_detector.py. threat_snippet stays out of the numeric equations.
  • signal_processor. The unreachable text-spoof branch and its test are removed; sec_extension_mismatch keeps its slot.
  • Tests.
    • Detector cases, the reason's kind and its pickling.
    • The two mocked worker tests, updated.
    • An end-to-end scan of planted files: an ELF as .png and a PE as .jpg fire; an LFS pointer, an empty .png and a PNG named .jpg don't.

Measurement

  • Corpus pool (/nvme-data/gitgalaxy-data, 140 repos), through the same census check: 0 of 98,228 denied-extension files flagged (79,423 with inert extensions). The old scan_binary() flagged 10.5%.
  • Planted end-to-end: exactly the 2 disguised executables are flagged (threat_extension_mismatch = 1, binary_anomaly = 1).
  • Golden crucible (v1.6.0): no drift. Zero-dependency passes. Full-precision differs only in this machine's missing optional packages (xgboost, tiktoken), identically on unmodified main.
  • tests/tools/pr_gates.py --fast: 5/5 (lint, audits, secrets, xray, gauntlet).

Score impact

The signal feeds the hit_vector, threat_extension_mismatch, binary_anomaly and fam_threat (display only). It's excluded from archetype features (the sec_ prefix). is_malware is unaffected, since it comes only from the XGBoost model, which isn't shipped. Each flag adds one synthetic artifact (impact 5000). Flags are 0 on the pool and on the crucible, so no golden change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ

… under inert extensions)

Not yet wired into galaxyscope; see draft PR for status.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 2 commits October 2, 2026 23:39
…ed files with executable magic; structured aperture reason

The Binary Analysis Sensor could not fire: galaxyscope's worker tested the
aperture reason for wording Gate 1.3 no longer emits, and the census routed every
denied-extension file to the unparsable list before any worker saw it.

- aperture: ApertureReason (a str carrying .kind); Gate 1.3 returns kind
  DENIED_EXTENSION. The message text is unchanged for every log/report reader.
- census (git and filesystem walk): a denied file whose first 8KB is an
  executable under an inert extension (security_lens.detect_disguised_executable:
  ELF, PE/NE/LE, self-consistent DOS MZ, Mach-O, Java class, wasm at offset 0) is
  dispatched -- stem_map/size only, not the language census or tallies.
- worker: gates on reason.kind, calls detect_disguised_executable instead of
  scan_binary (kept for binary_anomaly_detector.py); threat_snippet stays out of
  the numeric equations.
- signal_processor: the unreachable text-spoof branch and its test removed.
- tests: detector cases, the reason's kind and pickling, and an end-to-end scan
  of planted files (ELF as .png and PE as .jpg fire; an LFS pointer, an empty
  .png and a png named .jpg do not).

Measured: 0 of 98,228 denied-extension files flagged across 140 corpus-pool
repos; golden crucible unchanged (zero-dependency passes; full-precision differs
from main only by this machine's missing optional packages, identically on main).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01RZE6us7fUL6Hynk59rWLvZ
@squid-protocol squid-protocol changed the title WIP #4126: narrow extension-mismatch (disguised executable) detector #4126: narrow disguised-executable detector, wired into census and worker Oct 3, 2026
@squid-protocol
squid-protocol marked this pull request as ready for review October 3, 2026 04:10
@squid-protocol
squid-protocol merged commit 4f3f445 into main Oct 3, 2026
32 checks passed
@squid-protocol
squid-protocol deleted the fix/extension-mismatch-4126 branch October 3, 2026 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sec_extension_mismatch can never fire in a scan: binary sensor gate checks a renamed aperture reason (3477c48cc), text-spoof path unreachable

1 participant