Skip to content

Fix detector.py's dead RCE-taint corroboration and the sec_ merge overwrite - #347

Merged
squid-protocol merged 1 commit into
mainfrom
fix/344-dead-taint-corroboration-blocks
Jul 24, 2026
Merged

squid-protocol merged 1 commit into
mainfrom
fix/344-dead-taint-corroboration-blocks

Conversation

@squid-protocol

Copy link
Copy Markdown
Owner

Summary

Fixes #344. The originally-filed issue described the bug as a merge overwrite (security_lens.py's count silently clobbering detector.py's own corroborated count); implementing it surfaced a more fundamental issue underneath, corrected in a follow-up comment on #344 before this PR.

  • detector.py::coding_analysis()'s "1. Taint Tracking (RCE Weaponization)" block checked spatial_map for "sec_high_risk_execution"/"sec_io" — keys that belong exclusively to the Passive Security Lens Observer family (SIGNAL_SCHEMA), populated only by security_lens.py during galaxyscope.py's Phase 5.5, which runs after coding_analysis() has already returned. spatial_map is local to a single coding_analysis() call and can never contain a sec_-prefixed key. The block's guard was always False — this correlation has never actually executed.
  • Fixed by pointing the block at the keys detector.py's own rules really produce at this stage: "high_risk_execution"/"io" (both real, unprefixed SIGNAL_SCHEMA members).
  • The sibling block, "4. The Active Hemorrhage", has the same wrong-key shape but no equivalent fix is available yet: "hardcoded_secrets" (unprefixed) isn't a SIGNAL_SCHEMA member at all, so there's no key detector.py's own rules could ever populate it under. Left intentionally dead, annotated in place, pending [FEATURE/CORE-ENGINE] Extract a shared, scope-aware spatial correlation primitive and make threat_locations the persisted ledger #346 (moving correlation to run after security_lens.py has actually populated its data).
  • Once block 1 computes a real value, galaxyscope.py's Phase 5.5 merge loop would have erased it again on the next line — it did equations[f"sec_{key}"] = hit_count unconditionally. Made the merge additive so detector.py's proximity-based corroboration and security_lens.py's independent variable-echo corroboration both survive.
  • Two existing tests (test_detector_advanced_appsec_sensors, and its MOCK_LANG_DEFS) had been quietly papering over the dead-code bug by injecting fake rules literally named sec_high_risk_execution/sec_io — updated them to use the real unprefixed rule names, matching how language_standards.py actually names these rules in production.

Test plan

  • Added test_worker_merges_sec_tainted_injection_additively in test_galaxyscope.py, driving a real detector.py corroboration (1 hit) together with a mocked security_lens.py contribution (3 hits) through the full worker path, asserting the merged result is 4, not 3. Verified it fails (3 != 4) on the pre-fix code and passes after.
  • python -m pytest tests/core_engine/test_detector.py tests/core_engine/test_galaxyscope.py tests/core_engine/test_signal_processor.py tests/security_auditing/test_security_lens.py -q — all pass.
  • python -m pytest tests/ -q — full suite, 812 passed, 1 xfailed (pre-existing, unrelated).

🤖 Generated with Claude Code

…rwrite (#344)

detector.py::coding_analysis()'s "1. Taint Tracking (RCE Weaponization)"
block checked spatial_map for "sec_high_risk_execution"/"sec_io" -- keys
that belong exclusively to the Passive Security Lens Observer family
(SIGNAL_SCHEMA), only ever populated by security_lens.py during
galaxyscope.py's Phase 5.5, which runs strictly after coding_analysis()
(and the splice() call around it) has already returned. spatial_map is
local to a single coding_analysis() call and only ever contains keys
from that function's own per-language rules -- it can never contain a
"sec_"-prefixed key. The block's guard condition was therefore always
False: detector.py's own in-segment proximity corroboration for RCE
taint has never actually executed.

Point the block at the keys detector.py's own rules really produce at
this stage ("high_risk_execution"/"io", both real SIGNAL_SCHEMA members
with an unprefixed sibling), so it corroborates real detector-side
signal instead of nothing.

The sibling block, "4. The Active Hemorrhage", has the same wrong-key
shape but no fix available yet: "hardcoded_secrets" (unprefixed) isn't
a SIGNAL_SCHEMA member at all, so there is no key detector.py's own
rules could ever populate it under. It's left as still-dead, annotated
in place, pending #346 (moving correlation to run after security_lens.py
has actually populated its data).

Once block 1 computes a real value, galaxyscope.py's Phase 5.5 merge
loop would immediately have erased it again: it wrote
`equations[f"sec_{key}"] = hit_count` unconditionally, discarding
whatever coding_analysis() had already put there. Make the merge
additive so detector.py's proximity-based corroboration and
security_lens.py's independent variable-echo corroboration both
survive, instead of whichever one ran last winning silently.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
@github-actions

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

@squid-protocol
squid-protocol merged commit 37bd8f4 into main Jul 24, 2026
22 checks passed
@squid-protocol
squid-protocol deleted the fix/344-dead-taint-corroboration-blocks branch July 24, 2026 01:18
squid-protocol added a commit that referenced this pull request Jul 26, 2026
…alc_cog_load) (#506)

Found via CodeQL's py/redundant-comparison + py/unreachable-statement
alerts (#347, #349): `if safe_loc < 15: ... return 5.0, total_density`
returns unconditionally for any 1-14 LOC file, so the later
`if safe_loc <= 2 and total_density == 0: return 0.0, total_density`
could never execute -- safe_loc is always >= 15 by the time execution
reaches it. Every tiny file, including a provably empty stub (e.g. a
near-blank __init__.py), was forced to a cognitive_load score of 5.0.

The dead code itself documents the original intent: a truly empty
<=2 LOC file shouldn't get even the small-file floor. Moved that exact
check inside the reachable `< 15` branch rather than inventing new
behavior, and removed the now-fully-dead duplicate below it.

The carve-out only fires for tier1 languages (irc == 0) since irc
feeds into total_density too -- tier2/3 files always carry a nonzero
floor from irc alone. Verified against the language-crucible corpus in
both zero-dependency and full-precision mode: exactly one file
(rust/tokio/fuzz.rs, tier1) changed from a phantom 5.0% to a correct
0.0%, rippling into its directory/global averages. Regenerated both
golden masters and added two unit tests (empty tiny file -> true 0.0,
small file with real signal -> unchanged 5.0 floor).

Full suite: 869 passed, 1 pre-existing xfail. Baseline regenerated for
line-shift from removing the dead duplicate (no new findings).

Co-authored-by: Joe Esquibel <[email protected]>
Co-authored-by: Claude Sonnet 5 <[email protected]>
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.

[BUG/CORE-ENGINE] security_lens results silently clobber detector.py's spatially-corroborated sec_tainted_injection count

1 participant