Repository navigation
[AUTOMATED] feat(p7): securitycheck — strip rustc bounds/overflow panic branches - #325
Merged
Merged
Conversation
…ic branches
Ports SEFCOM Oxidizer's SecurityCheckRemover (angr
angr/rust/optimization_passes/security_check_remover.py, whose work lives in the
CFAMixin::match_call / CFGTransformationMixin::remove_block mixins it composes) as
`option securitycheck` (P7 edge-virtualization, default ON, DIV-82).
rustc emits a check in front of every slice index, every string slice and every
non-constant `/` or `%`; each lowers to a conditional branch to a small diverging
block that calls one of seven `-> !` helpers in libcore. Ghidra has no notion of
them, so kuna rendered the guard and the call verbatim in front of every array
access.
Two parts under one option:
1. The divergence fact (ArchFlowEnv::query_call_no_return) reports a call to one of
the seven no-return from its NAME -- the same hook, shape and one-list discipline
as the default-on noreturn_externmatch. kuna's address-keyed no-return discovery
only proves divergence for the helper bodies it can walk, and the ones it misses
leave a *returning* panic block that part 2 correctly declines to touch.
2. p7_regions/kuna_securitycheck.rs (ActionRemoveSecurityCheck) severs the CBRANCH
edge to a diverging basic block whose single call is one of the seven, with
Funcdata::remove_branch + remove_unreachable_blocks -- the same primitive pair,
sub-stage and destructive/transform contract as DIV-14's stackguard, scheduled
immediately after it in fullloop's returnsplit group.
The match is on the path PREFIX before the first `<` (so
slice_start_index_len_fail<usize> matches), with a legacy ::h<16 hex> trimmed, and
accepts a whole-`::`-component suffix down to the bare leaf; slice_error_fail_rt is
a different leaf and never matches. All seven names exist nowhere but Rust, so both
halves are structurally inert on a C binary -- which is what lets it default ON with
no compiler-detection channel from the loader (none exists, and this builds none).
Measured on a rustc -O binary (551 functions): 17 of 24 emitted panic-helper calls
removed, -99 emitted lines, -26 `if (` guards, -5 gotos, and one function that
previously hit the 10 s per-function watchdog now completes. Zero collateral on C:
whole-binary decompile-all over tests/bug-repro/{faillog,grep,sort,libselinux.so.1}
and tests/fixtures/fid/prog (2,688 functions) is byte-identical on/off. Speed
(interleaved, min-of-N): grep -0.35%, sort +0.38%, the Rust witness +0.72%.
Gates: make test 675/675 PARITY OK; make test-stages 496/496 PARITY OK (baseline
re-recorded for the new stage file); make rust-test green; make check-spec green
(--strict green); kuna catalog --check OK.
Known limit, reported not fixed: the trigger needs a recovered callee name, and in a
default (PIE, dynamically linked) Rust binary the helper is reached through a .got
slot whose R_X86_64_RELATIVE relocation kuna never applies, so the call is an
unnamed CALLIND and the pass is a measured no-op there. Closing that is an ELF
sibling of the peimportcall pass.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_016WUuE4zdiEqZFWLL2YEUk9
mahaloz
force-pushed
the
feat/rust-securitycheck
branch
from
August 22, 2026 04:47
11913b5 to
6c0723b
Compare
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.
What
Ports SEFCOM Oxidizer's
SecurityCheckRemover(
angr/rust/optimization_passes/security_check_remover.py, whose work lives in theCFAMixin::match_call/CFGTransformationMixin::remove_blockmixins it composes) asthe kuna option
securitycheck(P7edge-virtualization, default ON, DIV-82).rustc emits a check in front of every slice index, every string slice and every
non-constant
/or%. Each lowers to a conditional branch to a small block that loadsthe panic
Location, calls one of seven helpers declared-> !in libcore, and diverges.Ghidra has no notion of them, so kuna rendered the guard and the call verbatim in front of
every array access — roughly doubling the CFG of ordinary Rust code.
How
Two parts under the one option.
ArchFlowEnv::query_call_no_return,infra/decompile_drive.rs)— a call to one of the seven is reported no-return from its NAME. The same hook, the
same shape and the same one-list discipline as the already-default-on
noreturn_externmatch. Needed because kuna's address-keyed no-return discovery onlyproves divergence for the helper bodies it can walk, and the ones it misses leave a
returning panic block that part 2 correctly declines to touch. Without it roughly
half the checks survive.
p7_regions/kuna_securitycheck.rs,ActionRemoveSecurityCheck)—
Funcdata::remove_branch+remove_unreachable_blocks, the same primitive pair,the same sub-stage and the same destructive/transform contract as DIV-14's
stackguard, scheduled immediately after it in fullloop'sreturnsplitgroup.Safety envelope. The arm is removed only when it is a basic block that diverges
(
size_out() == 0— so nothing downstream, and in particular no return, depends on it)and contains exactly one call, whose callee is one of the seven. A second call rejects
it. Either branch polarity is accepted; the arm is identified by what it contains, never
by the branch sense. A block also reachable another way is never orphaned —
remove_unreachable_blockscollects it only when no predecessor remains.Name matching. On the path PREFIX before the first
<(soslice_start_index_len_fail<usize>matches), with a legacy::h<16 hex>trimmed, andaccepting a whole-
::-component suffix down to the bare leaf — which is a shape kuna'sELF symbol path really produces.
core::str::slice_error_fail_rtis a different leaf andnever matches.
Why default-ON with no compiler-detection channel. All seven names exist nowhere but
Rust, so on a C binary both halves are structurally inert. No loader→engine compiler
channel is built (none exists).
Measured
Witness: a
rustc -O -C relocation-model=staticbinary (551 functions, slice/str/divwork).
if (guards9 functions change; every one indexes a slice. One function that previously hit the
per-function watchdog (
std::backtrace_rs::symbolize::gimli::Context::new) now completes.Zero collateral on C. Whole-binary
decompile-all --jsonovertests/bug-repro/{faillog,grep,sort,libselinux.so.1}andtests/fixtures/fid/prog(2,688 functions) is byte-identical on/off — 0 differing
codefields.Speed (interleaved, min-of-N): C
grepwhole-binary 14.240 s -> 14.190 s (-0.35%,N=5), C
sort7.960 s -> 7.990 s (+0.38%, N=5), the Rust witness whole-binary131.34 s -> 132.29 s (+0.72%, N=3 — and the ON side decompiles one MORE function, the
watchdog rescue above), per-function
app::transpose/app::ratios+0.00% (N=5). Allwell inside the +5% budget.
One visible second-order effect: a length argument whose only reader was the removed
compare becomes genuinely unused, so parameter recovery may trim it from the signature —
the same trade
stackguardmakes with the canary slot, and the reason the option exists.Documented in the option's
use_when, the module doc, the spec and the DIV row.Known limit (reported, not fixed here)
The trigger needs a recovered callee name. In a default (PIE, dynamically linked) Rust
binary the helper is reached through a
.gotslot whoseR_X86_64_RELATIVErelocationkuna never applies, so the call is an unnamed
CALLINDand the pass is a measured no-opthere (0 changes on
private/FakeCrypt, all 263 of whose panic call sites areGOT-indirect). Closing that is an ELF sibling of the
peimportcallpass — a separatefeature.
Gates
make test— 675/675, PARITY OKmake test-stages— 496/496, PARITY OK (baseline re-recorded for the new stage file)make rust-test— green (317 test binaries, 0 failures)make check-spec— green,--strictgreenkuna catalog --check— catalog OKtests/stages/oxidizer-securitycheck.xmlis the two-pass testcase (off = the guard andthe
panic_bounds_checkcall; on = neither, with the guarded load untouched).Catalog counts written
settables 111 → 112; surfaces 102 → 103; tiers
(core, transform, analysis)(24, 48, 39) → (24, 49, 39); catalog JSON
},\n110 → 111; bytecompat fixture111 → 112 (x3);
kuna-catalog.xmlsource_decompiler="angr"31 → 32,change_kind="opt-in-tool"14 → 15; stage corpus file count 209 → 210; universalaction-tree leaves 272 → 273.
🤖 Generated with Claude Code
https://claude.ai/code/session_016WUuE4zdiEqZFWLL2YEUk9