Learning When to Snapshot: A Recurrent Oracle for State Selection in Fuzzing

Testing stateful software — protocol daemons, smart-contract virtual machines, file systems — means navigating an execution state that only exists after a long history of inputs. Modern fuzzers solve the cost of reaching deep states with snapshots: instead of replaying the whole input prefix, they save a memory image of the running process once and reload it in constant time. But snapshots are expensive to keep, so every snapshot-based system must answer the same hard question with crude heuristics: which execution states are worth saving, and which saved state should be restored next? Meanwhile, a seemingly unrelated literature has shown that recurrent neural networks — models that carry a compressed memory vector across sequence steps — are remarkably good at exactly this kind of problem: inferring hidden state from raw sequential signals without any hand-written rules.

This proposal argues these two threads belong together. The core claim is that a small gated recurrent network (an LSTM or GRU), trained online on the fuzzer's own execution traces, can serve as a snapshot oracle: its hidden state compresses the full input-and-execution history of the target into a continuous vector that captures implicit state (heap contents, protocol negotiation progress, transient balances) that static rules cannot see, and a small prediction head on top of that vector decides when a state is worth snapshotting and which snapshot is worth restoring. Nothing in the indexed literature does this. ItyFuzz decides snapshot retention with hand-crafted dataflow and branch-distance voting rules; SGFUZZ tracks developer-named enum variables; MuFuzz plans snapshotting as unaddressed future work; and the only works joining the literal words "snapshot" and "RNN" are optical imaging papers that reconstruct video from compressed camera measurements, not software state restoration.

Background and the Exact Gap

Three snapshot-based systems establish the current state of the art. ItyFuzz: Snapshot-Based Fuzzer for Smart Contract gives Ethereum Virtual Machine fuzzing $O(1)$ state teleportation using a Rust EVM with LibAFL, but chooses which states to snapshot using two heuristic rules: "dataflow waypoints" (a memory slot was written and later read) and "comparison waypoints" (a voting scheme over branch distances). SNPSFuzzer: A Fast Greybox Fuzzer for Stateful Network Protocols using Snapshots checkpoints protocol processes at pre-defined protocol states via CRIU, bypassing socket replay. QUIC-Fuzz: An Effective Greybox Fuzzer For The QUIC Protocol snapshots at a single "latest safe point" after initialization. In all three, snapshot selection is either fixed in advance or driven by static rules.

Two adjacent systems show the alternative being considered and rejected. Stateful Greybox Fuzzing (SGFUZZ) mines enum variables from source and builds a state transition tree — but its own authors report that 32% of tracked enums are non-state noise, and the approach structurally misses implicit state in heap structures, file systems, and databases. MuFuzz: Sequence-Aware Mutation and Seed Mask Guidance for Blockchain Smart Contract Fuzzing uses static read-after-write dependency analysis to order transaction sequences, but re-executes every sequence from scratch; its authors explicitly name state snapshotting as future work.

On the recurrent side, the motivating evidence is that recurrent hidden states become usable state representations without manual annotation. NeuralHydrology - Interpreting LSTMs in Hydrology shows individual LSTM memory cells correlate strongly ($p > 0.5$) with unobserved physical reservoir states like snow water equivalent. Automatic Construction of a Recurrent Neural Network based Classifier for Vehicle Passage Detection shows an LSTM learning latent temporal patterns from raw, noisy, multi-channel binary signals, outperforming a hand-tuned rule system (Pass Quality 0.923–0.952 versus 0.914) and degrading gracefully when a sensor channel fails. And Evaluation of Load Prediction Techniques for Distributed Stream Processing documents the property this proposal depends on: recurrent models have slow training but near-instantaneous inference. That asymmetry is what makes an RNN compatible with a fuzzing loop that restores states in microseconds.

The proposal differs from the closest existing work in one specific way: ItyFuzz already restores snapshots in constant time, but its selection policy is a static rule over raw read/write events. We keep its restoration engine and replace the policy with a learned recurrent model that (a) consumes the full execution trace, not just read-write collisions, (b) captures implicit state that no static rule enumerates, and (c) predicts future value of a state rather than reacting to past events.

Research Program

The system, which we call RSnap, has three components built on top of an ItyFuzz-style snapshot engine.

First, a trace encoder: a single-layer GRU or LSTM that reads, at each execution step, a compact event vector — the executed operation or message type, the top of the stack or parsed message fields, and a coarse indicator of the memory region touched. The recurrent hidden state $h_t$ is by construction a compressed summary of everything that happened so far, which is precisely the representation SGFUZZ's enum mining and ItyFuzz's dataflow rules try and fail to approximate.

Second, a value head: a small linear map from $h_t$ to a scalar prediction $v_t$ of the expected coverage gain from continuing execution (or restoring) at this state, trained on the fuzzer's own history where the target is the realized new-branch count observed within $k$ steps:

$$v_t = w^\top h_t + b, \quad \text{trained on } \big(h_{t'},\ \text{new coverage within } k \text{ steps of } t'\big) \text{ pairs collected by the fuzzer.}$$

A state is snapshotted when $v_t$ exceeds a memory-budgeted threshold (highest-$v$ states evicted first); a snapshot is restored with probability proportional to predicted value. This is the recurrent analogue of ItyFuzz's voting scheme, but predictive rather than reactive.

Third, an asynchronous training loop: the trace buffer, value targets, and gradient updates run in a separate process from the snapshot engine, so the fuzzer's hot loop only ever pays the cost of a single forward pass per step — the fast-inference property documented in Evaluation of Load Prediction Techniques for Distributed Stream Processing. Training is periodic, not per-execution, and we measure the throughput tax explicitly.

The analysis program has two parts. Empirically, we compare RSnap against ItyFuzz's waypoint heuristics, SGFUZZ-style enum tracking, and snapshot-everything/never extremes under fixed memory budgets. Scientifically, we ask whether the learned hidden state is an interpretable state representation: following NeuralHydrology - Interpreting LSTMs in Hydrology, we correlate individual memory cells with externally defined execution states (EVM storage slots, protocol handshake stages) to test whether the network discovers state structure that the enum heuristic misses — the software-systems version of their finding that cells track upper and lower zone storage.

Baselines

The naive reference point is snapshot-everything and snapshot-never. Snapshot-everything saves a full memory image at every step; it maximizes state access but exhausts memory within minutes, which is the open problem ItyFuzz's pruning heuristics exist to manage. Snapshot-never is MuFuzz's regime, re-executing every transaction sequence from scratch, which its authors identify as the dominant overhead. Both will be run with the same restoration engine and the same compute and time budget as RSnap, and they bound the question: any selection policy must beat both extremes to be interesting.

The strongest existing competitor is ItyFuzz's heuristic waypoint policy (ItyFuzz: Snapshot-Based Fuzzer for Smart Contract), which on the 42 real-world DeFi exploits benchmark found concrete exploits for 36 of 42 in an average of 13.8 seconds, and on the B1 ERC20 dataset reached near-total instruction coverage in 10 seconds. It is the strongest competitor because it is the only system in the file that already combines $O(1)$ restoration with a non-trivial selection policy on these benchmarks. We will run RSnap and ItyFuzz on identical benchmarks (B1, the 42-exploit suite, and the D1 corpus of 21,147 real-world contracts from MuFuzz), with the same restoration engine, the same time and memory budgets, and the same tuning effort spent on each system's hyperparameters. Beating ItyFuzz means finding strictly more exploits on the 42-exploit suite within the same wall-clock budget (more than 36 of 42, or equal exploits at lower average time), or matching its coverage with a materially smaller snapshot memory footprint. On the network-protocol side the analogous comparison is against SNPSFuzzer (SNPSFuzzer: A Fast Greybox Fuzzer for Stateful Network Protocols using Snapshots), which on ProFuzzBench improved path coverage by an average of 24.45% over AFLNet and found 133.3% more unique crashes.

The key ablation isolates the learned ingredient. We run the identical architecture and training loop, but with the input event vector replaced by SGFUZZ-style enum-assignment events (Stateful Greybox Fuzzing) instead of raw execution traces. If RSnap beats ItyFuzz but the enum-input variant does not, the gain comes specifically from modeling implicit, non-enumerated state — the ingredient no existing system has. A second ablation replaces the recurrent encoder with a feedforward network over a fixed window of recent events, testing whether the recurrent memory (rather than mere learned value prediction) is doing the work.

Why not just…?

Why not just use static data-flow analysis? This is MuFuzz's approach, and it is a real threat: static read-after-write analysis is free at runtime and took MuFuzz to 90% branch coverage on small contracts and 195 detected vulnerabilities on the D2 corpus. But its own authors report that static data flows are "spurious," steering the fuzzer down unproductive paths, and static analysis cannot observe dynamic runtime values at all. More decisively, static analysis answers a different question: it ranks function sequences, while snapshot selection requires a prediction of future value conditional on the runtime state actually reached. The D1 comparison in our experiments settles this directly by running MuFuzz's static guidance as a snapshot-selection policy inside the same engine.

Why not just track enum variables like SGFUZZ? Enum tracking needs source code, fails on heap- and file-implicit state, and admits 32% noise per SGFUZZ's own evaluation (Stateful Greybox Fuzzing). The enum-input ablation above is the honest test: if the enum variant matches RSnap, the reviewer is right and the contribution collapses to "ItyFuzz with a learned voting scheme." We report that result either way.

Why not just use a classical time-series model or a simpler regressor? Evaluation of Load Prediction Techniques for Distributed Stream Processing found Triple Exponential Smoothing competitive on smooth load series, but it also found the GRU clearly ahead on shorter, noisier intervals (SMAPE 0.47 at 15-minute sampling), and exponential smoothing structurally handles a single scalar series — it cannot encode a multi-channel execution trace. The feedforward-window ablation is the stronger version of this objection, and if a windowed regressor matches the recurrent encoder on exploit-finding, we will report that the recurrence is unnecessary and the useful part is the learned value head. That would still be a novel result, but a different one, and we treat it as a live possibility.

Why not just use an LLM? QUIC-Fuzz already evaluated ChatAFL and found generative LLM guidance loses badly on low-level stateful protocol grammars against deterministic snapshot execution — 84% branch-coverage advantage and roughly 25 executions per second (a 125× speedup over Fuzztruction-Net) for the snapshot-based tool (QUIC-Fuzz: An Effective Greybox Fuzzer For The QUIC Protocol). A compact recurrent model doing one matrix multiply per execution step is the right size class for a microsecond-scale loop; an LLM call per snapshot decision would invert the throughput economics entirely. We do not compare against LLM guidance directly — the cited evaluation already covers it.

Why not worry that RNN training stalls the fuzzer? This is the most serious objection: ItyFuzz finds the Nomad Bridge exploit in 0.3 seconds, and any per-step backpropagation would erase that. Our design concedes the point in advance: training happens asynchronously on a replayed trace buffer, and the hot loop pays only a forward pass, whose cost the load-prediction literature measures as near-instantaneous (Evaluation of Load Prediction Techniques for Distributed Stream Processing). We will nevertheless report executions-per-second with the oracle attached versus the raw engine, and if the tax exceeds a stated threshold (say 20% of ItyFuzz's throughput), the design fails on its own terms.

Proposed Experiments

The primary evaluation is smart-contract fuzzing, where the strongest snapshot baseline and the richest benchmarks exist. On the 42 real-world DeFi exploits benchmark, the target to beat is ItyFuzz's 36 of 42 exploits at 13.8 seconds average (ItyFuzz: Snapshot-Based Fuzzer for Smart Contract); we report exploits found, mean time-to-exploit, and peak snapshot memory at matched budgets. On the B1 ERC20 dataset the comparison is time-to-near-total-coverage versus ItyFuzz's 10 seconds. On MuFuzz's D1 corpus (21,147 real-world contracts) we report branch coverage against MuFuzz's 90% on small and 82% on large contracts (MuFuzz: Sequence-Aware Mutation and Seed Mask Guidance for Blockchain Smart Contract Fuzzing), and on D2 (155 vulnerable contracts) and D3 (500 complex contracts) we report detected vulnerabilities and precision against MuFuzz's 195 detected and 94% precision respectively. The secondary evaluation ports the oracle to protocol fuzzing on ProFuzzBench (the Tinydtls and Kamailio targets used by SNPSFuzzer), where the reference gains are 112.0–168.9% execution speedup and 24.45% average path-coverage improvement over AFLNet (SNPSFuzzer: A Fast Greybox Fuzzer for Stateful Network Protocols using Snapshots); here the oracle must also handle the non-determinism artifacts (connection IDs, nonces) that QUIC-Fuzz documents as restoration hazards.

The decisive checks are three. First, the memory sweep: plot exploit discovery and coverage against snapshot memory budget for RSnap, ItyFuzz waypoints, and snapshot-everything — the claim is that learned selection dominates the trade-off curve, not just one point on it. Second, the throughput audit: executions per second with and without the oracle in the loop, verifying the asynchronous design keeps the tax below 20%. Third, the interpretability test: following the correlation methodology of NeuralHydrology - Interpreting LSTMs in Hydrology, test whether individual memory cells align with defined execution states (EVM storage slots, protocol handshake stages). If cells align with states that no enum variable names, that is direct evidence the model captures implicit state — the specific gap SGFUZZ's authors identified and left open.