Repository navigation
Analysis-tier: format-string varargs typing — cross-arch coverage - #21
Merged
Merged
Conversation
…rch64/ARM/RISC-V)
Increment 25. Extends the Increment 16 FormatStringAnalyzer half-B feature
(`--option formatstring on`, gated OFF by default) from the x86-64 first cut
to all four first-class arches.
Three new fixtures built from the same C as fmt_x86_64
(`printf("%d %s\n", argc, argv[0])`): fmt_aarch64, fmt_arm (32-bit Thumb),
fmt_riscv64 — all -O0 -fno-stack-protector, unstripped, with README provenance.
AArch64 and RISC-V worked unchanged (the format address is materialized directly
via adrp+add / auipc+addi, so the existing resolve_const_pointer reads it as-is).
ARM needed a fix: its format pointer is loaded PC-relatively from a read-only
literal pool (ldr [pc,#k]; add pc), so the format-arg varnode is a memory LOAD
that only constant-folds under readonlypropagate. IfcDecompile now enables
readonlypropagate for the duration of a formatstring-on decompile and restores
it afterward — faithful to Ghidra's FormatStringAnalyzer (which reads constant
strings from read-only memory), keeping the feature self-contained on ARM with
a single --option formatstring on. Gate-safe: inert unless formatstring is on
(default off), so the parity gates are byte-identical.
All four arches now type identically: printf("%d %s\n",(uint8)a0,*a1) ->
printf("%d %s\n",a0,(char *)*a1).
New e2e gate verify_formatstring_crossarch.rs (6 tests, off+on x 3 arches, all
ran — not skipped). make test 675/675 PARITY OK; make test-stages 158/158
PARITY OK; make rust-test green; kuna catalog --check catalog OK.
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb
mahaloz
added a commit
that referenced
this pull request
Sep 27, 2026
…_tab_column): stage #21/#22 and the round trip pin its integer return; stages baseline +2 keys (1438) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_01V6bguCkPS65cu9ejj1fbpy
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
… to keeps printing as the global A load the binary makes of a global after storing a computed value to it is left on the global while the value is read sign-sensitively; otherwise the value and its stores are marked and Merge joins them with the global as before. Fixtures gain w_realias/w_rephi/w_reboth/w_recopy (store, pointer store, load); stage assertions #17-#21, and #5/#6/#9 follow the loads the -O0 binary makes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
mahaloz
added a commit
that referenced
this pull request
Sep 30, 2026
…on main 0729b8b (1588 -> 1609) Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
mahaloz
added a commit
that referenced
this pull request
Oct 1, 2026
… to keeps printing as the global A load the binary makes of a global after storing a computed value to it is left on the global while the value is read sign-sensitively; otherwise the value and its stores are marked and Merge joins them with the global as before. Fixtures gain w_realias/w_rephi/w_reboth/w_recopy (store, pointer store, load); stage assertions #17-#21, and #5/#6/#9 follow the loads the -O0 binary makes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
mahaloz
added a commit
that referenced
this pull request
Oct 1, 2026
…on main 48f49b3 (1616 -> 1637) Only the 21 globalvalue keys are new; none of main's keys are missing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
… to keeps printing as the global A load the binary makes of a global after storing a computed value to it is left on the global while the value is read sign-sensitively; otherwise the value and its stores are marked and Merge joins them with the global as before. Fixtures gain w_realias/w_rephi/w_reboth/w_recopy (store, pointer store, load); stage assertions #17-#21, and #5/#6/#9 follow the loads the -O0 binary makes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…on main 5eb9733 (1631 -> 1652) Only the 21 globalvalue keys are new; none of main's keys are missing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
… to keeps printing as the global A load the binary makes of a global after storing a computed value to it is left on the global while the value is read sign-sensitively; otherwise the value and its stores are marked and Merge joins them with the global as before. Fixtures gain w_realias/w_rephi/w_reboth/w_recopy (store, pointer store, load); stage assertions #17-#21, and #5/#6/#9 follow the loads the -O0 binary makes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…on main 363123e (1637 -> 1658) Only the 21 globalvalue keys are new; none of main's keys are missing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
… to keeps printing as the global A load the binary makes of a global after storing a computed value to it is left on the global while the value is read sign-sensitively; otherwise the value and its stores are marked and Merge joins them with the global as before. Fixtures gain w_realias/w_rephi/w_reboth/w_recopy (store, pointer store, load); stage assertions #17-#21, and #5/#6/#9 follow the loads the -O0 binary makes. Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Claude-Session: https://claude.ai/code/session_011shDTp2k5iNyyj9TCjt6vg
mahaloz
added a commit
that referenced
this pull request
Oct 2, 2026
…on main 363123e (1637 -> 1658) Only the 21 globalvalue keys are new; none of main's keys are missing. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Ps66ZCFPLywq9AKHBuDXNU
mahaloz
added a commit
that referenced
this pull request
Oct 14, 2026
…s, and a split cleanup (#1072 delta review) - Restore the guard the round-2 rewrite dropped: once the slot is placed, an address formed into a live byte of the argument area outside it is a local the same `add esp` releases, and the sizing is declined. A frameless `push ecx` local passed as `Fill(&r)` before `Take(*p, r)` printed `Take(v1._0_12_,a0)`; it now prints `Take(*a1,a1[1],v1)` as with the option off. - Decline a cleanup followed by another bare `add esp` before the next call, branch or return (`add esp,8; add esp,4`). - Document the two shapes the stack cannot tell apart: one reservation larger than the class, and a dead pushed local above a trivially copyable aggregate. Fixture msvcbyval_ce_i386 gains podfold, split and a plain-struct control, with stage assertions #19-#21. [AUTOMATED] change made by Claude Code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015sdZpNU5odw5dVyaxeSvvz
mahaloz
added a commit
that referenced
this pull request
Oct 14, 2026
…s, and a split cleanup (#1072 delta review) - Restore the guard the round-2 rewrite dropped: once the slot is placed, an address formed into a live byte of the argument area outside it is a local the same `add esp` releases, and the sizing is declined. A frameless `push ecx` local passed as `Fill(&r)` before `Take(*p, r)` printed `Take(v1._0_12_,a0)`; it now prints `Take(*a1,a1[1],v1)` as with the option off. - Decline a cleanup followed by another bare `add esp` before the next call, branch or return (`add esp,8; add esp,4`). - Document the two shapes the stack cannot tell apart: one reservation larger than the class, and a dead pushed local above a trivially copyable aggregate. Fixture msvcbyval_ce_i386 gains podfold, split and a plain-struct control, with stage assertions #19-#21. [AUTOMATED] change made by Claude Code. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_015sdZpNU5odw5dVyaxeSvvz
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 13, 2026
…ing stores to stray calls The callee walk now follows the stack addresses it loses sight of, for the extent only: one stored in a stack slot and loaded back (`push esp; pop eax`), and one a nested call returns in EAX/EDX. A load or store through a lost address leaves the extent unstated, and so does a stack address written outside the general registers (parked in xmm0) or into part of one. Slots are followed flow-sensitively for the 64 below the return address. The tracking runs only with calleeargs on and never changes a value the pop proof reads, so `calleeargs off` stays identical to the stdcall-purge walk. A trial past a call's bound is no longer dropped where a direct call in the same function whose callee states no extent, but whose window is known (its reached returns' pop or the caller's cleanup), would take the same stored value from past that window. Such a value is a local of the caller (a pushed /GS cookie, a zero-initialised buffer), and dropping it only moved it onto the other call as a stray argument. Indirect and import calls have no window and still take a freed push as their argument (the outer virtual call). TAILCALLSAVED Noelo-Lab#4 pins `sub_100074(2,1)` again, as on main. New stage cases CALLEEARGS Noelo-Lab#21-Noelo-Lab#25 (calleelost_pe_i386, clean-room asm with its recipe): the three lost-read shapes keep both arguments, the cookie-style local stays off the call with no extent, and the GetStdHandle -12 known gap is pinned as it stands. Row text, options.md and spec ch.04 describe both rules and the remaining stray-argument symptom. Stages baseline gains those keys. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz
added a commit
to borancar/kuna
that referenced
this pull request
Nov 16, 2026
…tles every call A block that only its callee's reached returns prove an argument block was expanded whenever that pop could be stated, even with another call in the function whose pop nothing proves. The solver then guesses that call's pop (an internal __stdcall callee that calls through a pointer: nothing), every slot after it moves by four, and the expanded call reads the block through the return address and the caller's next parameter: `guess(r); return take(*r) + k;` printed `sub_4012f0(a0); ... return sub_401040(*v9,...) + a0;`. Such a block is now expanded only when the stated pops leave every call with a pop its prototype states or its returns prove; otherwise it stays a loop, as on main. byvalreuse_pe_i386 gains unsettled/guess; REPFRAMECOPY Noelo-Lab#21 and Noelo-Lab#8 fail without this. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQeLQDThvbHGNoGw8h
mahaloz
added a commit
that referenced
this pull request
Nov 21, 2026
…nother native node starts The interpreter's exit to the function's own code kept the last VPC in its node key, so every virtual exit ran its own copy of the native epilogue: a 32-bit /GS cookie check per return path (cairuh x3 extra, newstar_backdoor). Explorer::leaves_vm mirrors angr's CFGVMDeobfuscation._vm_mode_should_end: a computed jump or return out of the interpreter's context, with no return address pushed, to non-protector code that is not a handler fragment, is an exit once the VPC register holds no virtual PC, or, for a memory-cell VPC (Themida), once the stack depth is back where native code entered the protector (angr's _on_vm_entry_frame). The target is keyed with no VPC, as angr keys post-exit blocks; stack bytes below SP (past the x86-64 red zone), the dead VM context, are dropped there. A jump back into the protector after an exit is keyed by its site (angr's re-entry region tag). Merging same-address exits alone is not enough (the w1 attempt): exits land a few instructions apart in one straight run (blaster 0x4014c8/0x4014ce, cairuh 0x4012c8/0x4012c9, sdl 0x18003e92a/b), and huffman's exit runs into the pre-VM early-return path's node at 0x402303. A node of the function's own code outside the interpreter now ends where another such node starts, as a disassembler splits basic blocks; a start found inside an emulated run forces one more round. With both, every path reaches one epilogue block, as in the reference CFG. Eval (r23-final -> this): huffman_ultra and newstar_backdoor_ultra become correct structure; cairuh x2 calls 0.90 -> 1.00, skeleton 0.78 -> 0.89 (still partial on strings, a reference artifact); blaster_ultra skeleton 0.97 -> 1.00; Themida blasters skeleton +0.03. 11/15 correct, 15/15 devirtualized. Non-devirtualized output is unchanged. Fixture pushan_vm2_x86_64 gains f_epi (two virtual exits into the stub's native tail, one an instruction ahead); kuna-pushan-sound #21/#22 pin one call to fin; stage baseline re-recorded 4841 -> 4843. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQdVZFuvdNY1SVmGFY
mahaloz
added a commit
that referenced
this pull request
Nov 22, 2026
…t tail call off the entry depth Themida (plain) computes every stack and VM-context address from the entry stack pointer and other entry registers through mixed boolean-arithmetic identities, with flags words of junk arithmetic mixed in and cancelled again. The linear normal form and the one-variable three-point probe saw none of them, so loads and stores went to unknown locations and the VM exit's return target was lost (4 rows unresolved, 9 rows over budget). - ExprArena::identity_probe decides `e == base + k` or `e == k` by evaluating the DAG at 96 fixed points (splitmix64, fixed seed) assigning every variable and every innermost boolean atom (as a free bit) at once: 20 structured lane-edge points, 76 uniform; exhaustive at <= 8 open bits. affine_probe uses it for several variables and to confirm the one-variable answer when no atom is involved. A per-node cache of 4 quick points (ExprArena::quick_vals) rejects most values with no walk. - Explorer::same_on_stack: two values whose difference is the constant 0 by that test are no difference at a merge. - ExprArena::decide_atoms: a guard, address or computed target has each atom an identity decides replaced (x == y with x - y constant; ordered compares of constants or of one pointer plus constants). - Linear form: zext(b ^ 1) == 1 - zext(b) for a boolean b. - PushanTarget::user_stack_clear_bits: a second identity run with the stack pointer's top bits clear (Windows x86 without IMAGE_FILE_LARGE_ADDRESS_AWARE: bit 31; Windows x64: bits 47-63); used answers are counted and the header says the function "assumes the stack lies where the platform puts a user-mode stack". - Explorer::misplaced_tail_call: a tail call (to a function or through an import slot) is accepted only with the stack pointer at its entry value; otherwise the exit stays unresolved and the header counts it (newstar_backdoor_themida ended at WSAStartup without a warning). Fixture pushan_vm2_x86_64: f_mba (arguments read through an MBA identity over rbp, rdx and rbx; exit behind an opaque predicate on rsp mixed with the result) and f_spbit (an exit on bit 16 of rsp whose other arm jumps to fin with the VM frame pushed). bin-t1-final2 prints garbage loads plus a bogus `fin(...)` path for f_mba with no warning, and accepts f_spbit's arm as a tail call; now `return a0 + a1;` and an incomplete header. Stage kuna-pushan-sound #19-#21 recounted, #24, #25 new; baseline-stages re-recorded (4957). Spec 02 2.11: identity test, platform stack, tail calls. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0179iMKQR2hseBprKvbvZRUv
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.
Extends the Increment 16
FormatStringAnalyzerhalf-B feature (--option formatstring on, gated OFF by default, GhidrasetDefaultEnablement(false)) from the x86-64 first cut to all four first-class arches. (Increment 25 indocs/analysis-port-log.md.)Which arches type correctly
All four type identically with a single
--option formatstring on(no separate flag):leaadrp+addmaterializes the format addr — existingresolve_const_pointerreads it as-isauipc+addi— same as aboveThe ARM fix (gated, faithful, parity-safe)
On ARM the format pointer is loaded from a read-only literal pool (
ldr r3,[pc,#k]; add r3,pc), so the call's format-arg varnode is a memoryLOADthat only constant-folds underreadonlypropagate(Funcdata::fillin_read_only). This is not aresolve_const_pointergap — the value is genuinely a read-only load the engine declined to fold.IfcDecompilenow enablesreadonlypropagatefor the duration of aformatstring-on decompile and restores the prior value afterward (and on thehas_no_codeearly-return). Faithful to Ghidra'sFormatStringAnalyzer(which reads constant strings out of read-only memory). Gate-safe: the toggle is inert (value unchanged) unless--option formatstring on(default off), so every parity gate — which never setsformatstring— is byte-identical.BEFORE / AFTER per arch
--option formatstring on:printf("%d %s\n",(uint8)a0,*a1)→printf("%d %s\n",a0,(char *)*a1)(the%darg a plainintwith no widening cast; the%sarg cast tochar *).printf("%d %s\n",(uint8)a0,*a1)→ afterprintf("%d %s\n",a0,(char *)*a1)printf("%d %s\n",(int8)a0,*a1)→ afterprintf("%d %s\n",a0,(char *)*a1)printf((char *)(dat_52c + 0x51c),a0,*a1)(the unresolved literal-pool pointer) → afterprintf("%d %s\n",a0,(char *)*a1)Fixtures
Three new fixtures built in the
kuna-devcontainer from the same one-line C asfmt_x86_64(int main(int argc,char**argv){printf("%d %s\n", argc, argv[0]); return 0;}),-O0 -fno-stack-protector, unstripped, with README provenance + pinned consts:fmt_aarch64,fmt_arm,fmt_riscv64. (The RISC-V cross-link needslibc6-dev-riscv64-crossinstalled in-container — recipe in the README.)Tests / gates
kuna-console/tests/verify_formatstring_crossarch.rs— 6 tests (off+on × AArch64/ARM/RISC-V), all actually ran (the per-arch.slaare built; the specs-less skip guard was not hit). The existingverify_s1_formatstring(x86-64) still passes.formatstring+readonlyflags).make test675/675 PARITY OKmake test-stages158/158 PARITY OKmake rust-testgreenkuna catalog --checkcatalog OK🤖 Generated with Claude Code
https://claude.ai/code/session_01FvRnfTgYKoZvS2TEvdYpWb