Repository navigation
Fix detector.py's dead RCE-taint corroboration and the sec_ merge overwrite - #347
Merged
Merged
Conversation
…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]>
3 tasks
Contributor
5 tasks done
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #344. The originally-filed issue described the bug as a merge overwrite (
security_lens.py's count silently clobberingdetector.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 checkedspatial_mapfor"sec_high_risk_execution"/"sec_io"— keys that belong exclusively to the Passive Security Lens Observer family (SIGNAL_SCHEMA), populated only bysecurity_lens.pyduringgalaxyscope.py's Phase 5.5, which runs aftercoding_analysis()has already returned.spatial_mapis local to a singlecoding_analysis()call and can never contain asec_-prefixed key. The block's guard was alwaysFalse— this correlation has never actually executed.detector.py's own rules really produce at this stage:"high_risk_execution"/"io"(both real, unprefixedSIGNAL_SCHEMAmembers)."hardcoded_secrets"(unprefixed) isn't aSIGNAL_SCHEMAmember at all, so there's no keydetector.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 aftersecurity_lens.pyhas actually populated its data).galaxyscope.py's Phase 5.5 merge loop would have erased it again on the next line — it didequations[f"sec_{key}"] = hit_countunconditionally. Made the merge additive sodetector.py's proximity-based corroboration andsecurity_lens.py's independent variable-echo corroboration both survive.test_detector_advanced_appsec_sensors, and itsMOCK_LANG_DEFS) had been quietly papering over the dead-code bug by injecting fake rules literally namedsec_high_risk_execution/sec_io— updated them to use the real unprefixed rule names, matching howlanguage_standards.pyactually names these rules in production.Test plan
test_worker_merges_sec_tainted_injection_additivelyintest_galaxyscope.py, driving a realdetector.pycorroboration (1 hit) together with a mockedsecurity_lens.pycontribution (3 hits) through the full worker path, asserting the merged result is4, not3. 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