Randomized Layouts as Free Labels for Binary Structure Recovery

When a program is compiled, the compiler fixes the order of the fields inside every data structure — a struct that declares fields A, B, C will always store them in that order, at predictable offsets. Both attackers and analysis tools lean on this predictability: exploits overwrite a function pointer at a known offset, and reverse-engineering systems recover the shapes of data structures in stripped binaries by recognizing those same fixed layouts. A family of defenses called randomized memory layout breaks this by shuffling field order and inserting garbage padding at compile time, so every build of the same program has a different internal memory geometry. The technique was built to defeat attackers, and one early evaluation showed it also degrades an automated structure-inference tool, Laika, dropping its structural mixture ratio to "0.57 without pointers and 0.63 with pointers" on a randomized bot Polymorphing Software by Randomizing Data Structure Layout. What nobody has done is ask the question from the other side: can modern learned analysis systems be made robust to layout randomization — and can randomization itself, perversely, become a resource that helps with the field's most painful bottleneck, the scarcity of labeled binaries?

The proposal has three connected parts. First, a standardized benchmark of randomized-layout binaries, because the field's evaluations are fragmented across ad-hoc workloads and no existing type-recovery system has ever been tested on randomized code — no reported result found on Lacuna for any structure-recovery system evaluated under layout randomization. Second, a simple observation that turns the defense into a data engine: when you compile a program with a different randomization seed, you get a brand-new binary whose correct ground-truth structure definition (field types and randomized offsets) is known exactly from the compiler's own bookkeeping. One labeled program therefore becomes many labeled programs at zero annotation cost — a direct attack on label scarcity, in the same spirit as CuBERT's finding that pre-training lets a model fine-tuned on "just 33% of the data" match baselines trained on all of it Learning and Evaluating Contextual Embedding of Source Code. Third, a frozen evaluation protocol, because benchmarking inconsistency has repeatedly manufactured false conclusions elsewhere: standardizing the protocol alone lifted PointNet++ from "90.0% to 93.3%" on ModelNet40 Revisiting Point Cloud Shape Classification with a Simple and Effective Baseline, and PUBench exposed how weakly supervised evaluations "cheat" with validation data that cannot exist in deployment Accessible, Realistic, and Fair Evaluation of Positive-Unlabeled Learning Algorithms.

Core Claim

The claim is twofold. (1) Current state-of-the-art binary structure and type recovery — XTRIDE, which reaches "90.15% overall accuracy" on the DIRT benchmark at "0.04 ms per function" Practical Type Inference: High-Throughput Recovery of Real-World Structures and Function Signatures, and ByteTR, which reaches "76.18%" precision on the TYDA dataset of 163,643 binaries Beyond the Edge of Function: Unraveling the Patterns of Type Recovery in Binary Code — degrades sharply on randomized layouts, because XTRIDE matches against a closed vocabulary of fixed instruction contexts that field shuffling destroys, and ByteTR detects structure membership but explicitly does not reconstruct internal field offsets. (2) Training a graph-based recovery model on randomized-layout compiles of the same labeled programs substantially restores that lost accuracy and improves sample efficiency, because the randomizer manufactures correctly labeled training diversity for free.

Research Program

The first deliverable is the benchmark. We take the open-source C/C++ projects underlying DIRT and TYDA and recompile them with a reimplementation of the Data Structure Layout Randomization (DSLR) transformation — member reordering plus pseudo-random garbage padding, originally a GCC 4.2.4 extension reporting "around 2% on average" compile overhead and "less than 4% on average" runtime overhead Polymorphing Software by Randomizing Data Structure Layout — ported to a modern toolchain, alongside the source-level alternative TASA where toolchain modification is undesirable TASA: toolchain-agnostic static software randomisation for critical real-time systems. The benchmark crosses three axes: the existing TYDA axes (four architectures, four optimization levels), plus randomization seed and padding entropy, all with the compiler emitting exact ground-truth field offsets per seed. Splits are project-disjoint, following the repository-level deduplication discipline Chirkova et al. used to keep near-duplicate code out of both sides of the split Empirical Study of Transformers for Source Code, and additionally seed-disjoint, so that test-time layouts were never seen in training — this is what separates genuine layout invariance from memorizing a larger set of fixed layouts.

The second deliverable is the augmentation-trained model. We build a graph neural network along ByteTR's lines — an inter-procedural variable propagation graph lifted to static single assignment form, fed to a gated graph network — but trained on a mixture of standard and randomized compiles, with the loss target being the seed-specific ground truth (structure identity, member types, and actual offsets). The augmentation is a pure data transformation: for each labeled binary, the randomizer emits $k$ new labeled binaries without a single additional human annotation. This composes naturally with self-supervised pre-training on unlabeled binaries in the CuBERT style, which we treat as an orthogonal, compatible ingredient rather than a competitor.

The third deliverable is the protocol: fixed augmentation, fixed loss, model selection on a held-out project split with no test-set feedback (the exact failure Goyal et al. documented in point cloud classification Revisiting Point Cloud Shape Classification with a Simple and Effective Baseline), and proxy-based tuning without labeled negative validation data in the spirit of PUBench's Proxy Accuracy Accessible, Realistic, and Fair Evaluation of Positive-Unlabeled Learning Algorithms. Metrics are structure identification accuracy, a new field-offset recovery score (per-member correctness of both type and offset), throughput, and sample-efficiency curves.

Baselines

The do-nothing reference point is the published tool applied unchanged: XTRIDE and ByteTR, first re-run under our frozen protocol on standard-layout binaries to reproduce their reported numbers (XTRIDE's "90.15% overall accuracy" on DIRT; ByteTR's "76.18%" precision on TYDA), then pointed at randomized test binaries with no retraining. This quantifies the collapse that motivates everything else. Beating it means only one thing: significantly smaller degradation from standard to randomized layouts at matched binaries and matched compute.

The strongest competitor is XTRIDE, because on clean layouts nothing else combines its accuracy and its throughput ("70x to 2,300x faster" than competing tools). To make the comparison fair rather than a strawman, we run two versions: the published system, and a strengthened variant whose closed vocabulary is deliberately extended with the randomized variants of every known structure from our training seeds — if n-gram matching can be rescued by giving it more vocabulary, this version will show it. ByteTR is the strongest learning-based competitor for the long-tail type distribution, and we retrain its architecture on our training split with the same tuning budget as our model. Our model wins only if it beats both on seed-disjoint randomized tests and does not regress on standard layouts.

The key-ingredient ablation is a single architecture trained three ways on identical labeled projects: standard layouts only; optimization-level diversity only (−O0 through −O3, which TYDA already spans); and full DSLR augmentation. This isolates layout randomization from ordinary compile-config diversity — the ablation that decides whether the core claim is real.

Why not just…?

Why not just use fast n-gram matching, as XTRIDE already does? On non-randomized firmware it is likely the right tool, and we do not claim otherwise. But XTRIDE's authors state it cannot infer novel or modified structures, and field reordering plus garbage padding rewrites exactly the local instruction contexts its closed vocabulary depends on; the DSLR evaluation already showed a related collapse for unsupervised inference (Laika's mixture ratio falling to 0.57–0.63) Polymorphing Software by Randomizing Data Structure Layout. The vocabulary-augmented XTRIDE baseline in our experiments settles whether matching can be patched; our expectation is that unseen seeds still break it, but that is an empirical question we answer rather than assume.

Why not just vary compiler optimization levels as your augmentation? This is the most serious alternative, and we treat it as a real threat. TYDA already spans four optimization levels and four architectures, and ByteTR trains across them — yet still cannot reconstruct internal field layouts. Optimization diversity changes generated code while leaving field order and padding untouched, so it trains a different invariance than the one randomized layouts require. But rather than argue this, the three-arm ablation decides it: if the optimization-only arm matches the DSLR-augmentation arm on seed-disjoint tests, our core claim fails and the contribution reduces to the benchmark itself. We would report that honestly.

Why not just prompt a large language model zero-shot on the decompiled code? The measurements in the XTRIDE paper put LLM-based inference at "8 seconds per function" — unusable on firmware images with tens of thousands of functions — and document hallucinated layouts that violate physical memory alignment Practical Type Inference: High-Throughput Recovery of Real-World Structures and Function Signatures. Separately, LLM probing work shows zero-shot evaluation is a "Wild West" of prompting and inference confounds Standardizing Evaluation Protocols in Machine Learning, so any LLM numbers would need our frozen protocol anyway. We still include an LLM arm on a subsample as a reference point, under the same protocol.

Proposed Experiments

Experiment one measures the collapse. XTRIDE and ByteTR, as published, are evaluated across the randomized benchmark's axes (seed, padding entropy, architecture, optimization level), reporting structure identification accuracy and field-offset recovery. The hypothesis is a large drop from the reproduced clean-layout numbers; the interesting scientific output is where the drop concentrates (closed-vocabulary misses for XTRIDE, offset errors for ByteTR).

Experiment two tests the augmentation. Our graph model is trained with DSLR augmentation and evaluated on seed-disjoint, project-disjoint randomized tests, against the three-arm ablation. The decisive comparison is arm (c) versus arm (b): if layout augmentation does not beat optimization-level diversity, the mechanism claim is dead regardless of absolute numbers.

Experiment three tests sample efficiency. We plot accuracy against the fraction of labeled projects used, from 10% to 100%, with and without DSLR augmentation at fixed $k$ compiles per project. The reference phenomenon is CuBERT's 33%-data result Learning and Evaluating Contextual Embedding of Source Code; we hypothesize augmentation shifts the curve so that comparable accuracy is reached with a substantially smaller labeled set, and we state no target number in advance — the curve is the result.

Experiment four sweeps padding entropy to find the feasibility threshold: as the space of possible layouts grows, at what entropy does recovery accuracy cross below a fixed bar for every method, including ours? This echoes the open question the Timeliner work raised — its authors note randomizing allocation destroys spatial-to-temporal mapping entirely Tipped Off by Your Memory Allocator: Device-Wide User Activity Sequencing from Android Memory Images — and gives the security community a calibrated answer to how much randomization is enough, in both directions: enough to defeat adversaries, not so much that legitimate forensic analysis becomes impossible even with learning.

A final regression check guards the deployment story: the augmented model must not lose accuracy on standard, non-randomized binaries relative to arm (a), since real-world corpora are mostly unrandomized today. If augmentation helps only under randomization and hurts elsewhere, the practical case narrows to randomized targets — still useful, but a weaker claim, and one we will state plainly.