Repository navigation
[AUTOMATED] fix(analysis): Rust v0 detection requires the leading underscore - #332
Merged
Merged
Conversation
…erscore
`is_rust_mangled`'s v0 arm was written
let v0 = name.strip_prefix('_').unwrap_or(name);
if v0.starts_with('R') && v0.len() > 1 { return true; }
and `strip_prefix` returns None when there is no leading underscore, so
`.unwrap_or(name)` hands back the ORIGINAL name and the test degenerates from
"begins with `_R`" to "begins with `R`". One matching symbol classifies the whole
image, so any C program importing OpenSSL's `RAND_bytes` / `RSA_new` / `RAND_add`
was reported as `Compiler::Rustc`.
That reaches the reader through DIV-80's `--language auto` policy:
$ kuna decompile /usr/bin/ncat --addr 0x1e640 # ncat is C
unsafe fn sub_1e640(mut a0: u64, mut a1: u32) -> *mut u64
After the fix ncat renders as C and a real Rust binary still renders as Rust.
Neither parity corpus can see this: every datatest and stage fixture is a
`<bytechunk>` image with no symbol table, so `symbols_indicate_rust` is never
consulted. The regression test pins the OpenSSL names directly.
Found by an adversarial verifier while reviewing the `rustabi` gate. The
implementing agent's own C-collateral sweep (grep, sort, faillog,
libselinux.so.1, fauxware) reported zero differences and was correct -- all five
carry zero `R`-prefixed symbols. Sample bias, not carelessness.
Gates: make test 675/675 PARITY OK; make test-stages PARITY OK; make rust-test
exit 0 (319 groups); make check-spec OK lenient + strict; catalog --check OK.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016WUuE4zdiEqZFWLL2YEUk9
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.
The defect
is_rust_mangled's v0 arm intends to match Rust v0 mangling (_R…):strip_prefixreturnsNonewhen there is no leading underscore, and.unwrap_or(name)then hands back the original name — so the test silently degenerates from "begins with_R" to "begins withR".symbols_indicate_rustis an.any(), so one matching symbol classifies the whole image. OpenSSL'sRAND_bytes,RSA_new,RAND_addall match.What it costs the reader
Via DIV-80's
--language autopolicy, ordinary C programs render as Rust:A real Rust binary is unaffected —
private/FakeCryptstill detects as Rust and rendersunsafe fn encrypt_file(…).The misclassification also reaches anything else gated on
Compiler::Rustc(the Rust no-return list,noreturn_propagate's widening).Why no test caught it
Every fixture in both parity corpora is a
<bytechunk>image with no symbol table, sosymbols_indicate_rustis never reached. The corpora are structurally blind to this predicate. The new regression test pins the OpenSSL names directly.Provenance, stated plainly
Found by an adversarial verifier reviewing the
rustabigate (PR #331), not by the implementer. The implementer's C-collateral sweep —grep,sort,faillog,libselinux.so.1,fauxware— reported zero differences and was correct: all five carry zeroR-prefixed symbols. Sample bias, not carelessness. PR #331 is held until this lands, because its Rust gate is only sound afterwards.Gates
make testmake test-stagesmake rust-testmake check-spec--strictkuna catalog --checkNo option, no catalog change, no baseline re-pin — this is a strict bug fix that only corrects wrong output. Spec prose added to
docs/spec/01-program-prep.mdbeside the demangler-routing paragraph.🤖 Generated with Claude Code
https://claude.ai/code/session_016WUuE4zdiEqZFWLL2YEUk9