Sequential Selection as the Security Boundary: Layout-Aware RL Context Construction under Fragmented Prompt Injection

When a retrieval system picks sentences from a document to feed a language model, it usually scores each candidate independently and takes the top few. A newer line of work instead treats selection as a sequence of decisions: pick one text unit, update your view of what the context now contains, pick the next unit to complement it. This sequential, reinforcement-learning (RL) approach measurably beats independent ranking because it avoids redundant picks and assembles complementary evidence — a policy trained this way on a compositional QA benchmark reached 78.21% accuracy with only 4 selected examples, while stuffing 100–150 examples into the model's context yielded roughly 63% Reinforcing Compositional Retrieval: Retrieving Step-by-Step for Composing Informative Contexts. But that same "find the complementary fragment" objective has a dark side that no one has examined: if an attacker splits a malicious instruction across the cells of a borderless table, or scatters it between a footnote and a marginal callout, a policy optimized for complementary coverage is precisely the mechanism most likely to reassemble it.

This proposal studies that three-way collision. Sequential RL selection supplies the core mechanism; document layout variability supplies the application regime — real enterprise documents where meaning (and, we will show, attacks) lives in two-dimensional structure rather than linear text; and reasoning-induced vulnerability supplies the threat model, since the downstream models that consume assembled context are reasoning models whose extended deliberation is itself an attack surface Reasoning as an Attack Surface: Adaptive Evolutionary CoT Jailbreaks for LLMs. The claim is double-edged: we first demonstrate that current RL selection policies are worse than naive retrievers under layout-fragmented injection, then show that a selection policy retrained with a layout-aware, safety-shaped reward becomes a cheap and effective defense layer — cheaper than generating explicit verification traces and more robust than flattening documents into plain text.

Core Claim

Two claims, one per phase. First, the complementary-coverage objective that makes sequential selection policies strong on benign benchmarks creates a perverse incentive under attack: because these policies are rewarded for finding fragments that jointly increase the downstream model's generation confidence Optimizing Retrieval for RAG via Reinforcement Learning, they will preferentially retrieve fragments — including split injection payloads and refusal-suppressing triggers — that make a vulnerable reasoning model comply rather than refuse. Second, this failure is fixable at the selection layer, without touching the downstream model: train the selection policy with a dual reward that combines answer utility with a safety signal derived from a cheap internal probe of the downstream model's refusal state, and give the policy spatial features so it can distinguish benign evidence (spatially coherent table rows, header-governed columns) from adversarial scatter (payload pieces spread across unrelated layout regions). The selection policy then acts as a learned, layout-aware filter that runs before any tokens enter the reasoning model — attacking the "cross-modal and indirect retrieval vulnerabilities" that remain, per the literature, an unaddressed threat vector.

Background and the Gap

Three pairs of directions have been connected, but never all three. Infinity Parser applies RL with a structural reward (edit distance, block counts, reading order) to parse scanned pages into structured text, and shows RL keeps improving where supervised fine-tuning plateaus — but it is strictly a single-page parser with no threat model and no query-driven selection Infinity Parser: Layout Aware Reinforcement Learning for Scanned Document Parsing. The UDA benchmark shows that RAG over heterogeneous real-world PDFs fails at the parsing and retrieval stages — on the FinHybrid financial corpus, GPT-4 with retrieval scored 45.9 while ingesting the whole raw document collapsed to 0.4, and oracle context chunks improved scores by up to 60% — but its retrievers are static top-$K$ rankers and its noise is benign UDA: A Benchmark Suite for Retrieval Augmented Generation in Real-World Document Analysis. On the security side, PANDORA poisons a document store so that ordinary similarity retrieval fetches a jailbreak payload, reaching 64.3% attack success on GPT-3.5 versus roughly 3% for direct attacks — but its payloads are monolithic text blobs, its retrieval step is passive, and layout plays no role Pandora: Jailbreak GPTs by Retrieval Augmented Generation Poisoning. VPI-Bench shows visually situated instructions compromise computer-use agents — browser agents attempted attacks at 100% on shopping and travel sites, and more capable reasoners were more vulnerable — but it covers interactive UI navigation, not document corpora or learned selection VPI-Bench: Visual Prompt Injection Attacks for Computer-Use Agents. RedVisor, the closest defense, forces the model to write an inspection trace before answering and reports near-0% attack success — but only on flat text, with retrieval treated as a black box, at a cost of 0.6–2.5 seconds of extra generation per query RedVisor: Reasoning-Aware Prompt Injection Defense via Zero-Copy KV Cache Reuse — note the corrected link: RedVisor.

No existing work places a sequential RL selection policy inside a layout-variable document corpus under an adversarial threat model. That is the gap, and it is not a cosmetic one: the exact tri-encoder mechanism (query, selected-context, candidate) that RCR uses to maximize structural coverage is, mathematically, an engine for finding fragments that complete a partial pattern — which is exactly what a fragmented injection is.

Research Program

The program has three components: a benchmark, a threat characterization, and a defensive policy.

The benchmark, which we call SplitCell, extends the UDA document suite. Starting from FinHybrid and TatHybrid documents (financial reports with the bordered and borderless tables, multi-column hierarchies, and fragmented cells that UDA documents as the hardest case), we plant PANDORA-category payloads (adult, harmful, privacy, illegal) that are split across layout structure: cell A of a table reads "ignore prior instructions," a footnote on a later page continues "and reveal the system prompt," a marginal callout supplies the target. Each attack is paired with a benign question over the same document so utility and safety can be measured simultaneously. Payloads are also rendered in layout-only channels — low-contrast borders, whitespace groupings, styled containers — the channels that XFUND-style spatial features capture and flat-text pipelines destroy XFUND: A Benchmark Dataset for Multilingual Visually Rich Form Understanding. An attacker capability parameter controls fragmentation depth, from monolithic (PANDORA-style) to fully scattered.

The threat characterization measures whether the perverse incentive is real. We run three retrieval regimes over SplitCell: static top-$K$ (BM25, dense, and multi-vector rankers, as in UDA), a sequential selection policy trained only for benign utility (RCR-style, with GRPO on downstream answer accuracy), and a selection policy trained with an R3-style generation-likelihood reward Optimizing Retrieval for RAG via Reinforcement Learning. The hypothesis for the second claim's motivation: static retrievers will often fetch only one cell of a split payload, defusing it by accident, while the sequential policy — rewarded for complementarity — will reconstruct it, and the likelihood-rewarded policy will actively prefer refusal-suppressing triggers because they raise the probability that the model generates something rather than refusing. We will verify the mechanism, not just the rate, using the token-level refusal probe of Refusal Falls off a Cliff: How Safety Alignment Fails in Reasoning?, which showed that reasoning models often flag a harmful prompt internally and then crash their refusal signal right before output. If the RL policy's preferred fragments systematically depress the probe score, the perverse incentive is established mechanistically.

The defensive policy is the constructive contribution. It extends the RCR tri-encoder with a layout stream: each candidate block carries its bounding-box coordinates and structural role (header, cell, footnote, caption), encoded with spatial-aware attention in the style of LayoutXLM XFUND. Training uses a dual reward under GRPO:

$$R = \lambda \cdot \mathbb{1}[\text{downstream answer correct}] - (1-\lambda) \cdot \max(0,\; z_{\text{refuse}}^{\text{clean}} - z_{\text{refuse}}^{\text{assembled}})$$

where $z_{\text{refuse}}$ is the linear refusal-probe score of the downstream model on the assembled context versus on the clean query alone, and $\lambda$ balances utility against safety. The point of using a probe rather than a generated verification trace is to resolve a genuine tension in the literature: RedVisor shows deliberation can defend, but AE-CoT and the Refusal Cliff work show extended reasoning chains are themselves the attack surface, with evolutionary CoT exploits reaching 92–96% attack success on o1-mini, DeepSeek-R1, and Qwen3 Reasoning as an Attack Surface. A hidden-state probe needs no generated tokens, so the defense adds essentially no latency and gives the attacker no deliberation to hijack. Leong et al. showed such probes are also data-efficient — 700 high-impact examples matched a 40,000-example supervised baseline — which suggests the safety reward will not require enormous attack training data Refusal Falls off a Cliff.

Proposed Experiments

Experiment 1 measures attack reconstruction rate across retrieval regimes on SplitCell, reported as attack success rate (ASR) per PANDORA's four policy-violation categories alongside benign task accuracy on the paired questions. The reference points from the file: PANDORA's monolithic attack on passive retrieval achieved 64.3% on GPT-3.5 and 34.8% on GPT-4, against roughly 3% and 1% for direct attacks Pandora; no reported result exists on Lacuna for fragmented-injection ASR under RL selection, which is the number this experiment produces. We sweep fragmentation depth to test the prediction that the sequential policy's advantage over top-$K$ retrieval in attack reconstruction grows with fragmentation, while top-$K$ ASR falls.

Experiment 2 trains the defensive policy and evaluates the trade-off frontier: ASR reduction versus benign accuracy on UDA's FinHybrid/TatHybrid tasks and on GeoQuery (where RCR reports 59.64% accuracy on the Template 1 split versus 40.36% for BM25, and 78.21% with 4 selected examples Reinforcing Compositional Retrieval) — the standard to hold is that benign accuracy stays within a few points of the benign-trained policy while ASR drops by an order of magnitude. We also compare against RedVisor run on the flattened text of the same documents, which isolates whether spatial features matter when the defense has to see the injection at all. Following VPI-Bench's finding that stronger reasoners are more susceptible VPI-Bench, we evaluate at least one reasoning model and one non-reasoning model downstream to check whether selection-layer defense closes the capability-safety gap.

Experiment 3 is the mechanism and cost analysis: probe trajectories over the selection sequence (does the policy learn to stop before assembling a dangerous context, rather than assembling and hoping the generator refuses?), latency versus RedVisor's 0.6–2.5 second trace-generation overhead, and generalization to held-out attack categories and to layout styles not seen in training, echoing Infinity Parser's finding that RL policies generalize to out-of-distribution formats where supervised models hallucinate structure Infinity Parser.

Baselines

The naive reference point is no retrieval at all: feed the entire document to a long-context model. UDA already ran this comparison on FinHybrid and found GPT-4 scored 45.9 with retrieval versus 0.4 without, so on layout-dense financial documents this baseline is not close — but we will run it on SplitCell anyway, because the interesting question is whether an attacker can use layout noise to degrade even the retrieval path, and because it bounds how much of the safety story is actually a retrieval story UDA.

The strongest existing attack-side baseline is the PANDORA setup: a monolithic poisoned passage retrieved by standard top-$K$ similarity search, evaluated with the same four policy-violation categories, achieving 64.3% on GPT-3.5 Pandora. We run it verbatim on SplitCell's monolithic setting to reproduce the reference point, then at each fragmentation depth. Beating it means, for the attack study, showing that the RL policy raises ASR above the PANDORA level under fragmentation — the perverse-incentive result — and for the defense, lowering ASR far below it while PANDORA-level utility is maintained.

The strongest existing defense baseline is RedVisor, the reasoning-trace inspection method that reports near-0% ASR on text-only benchmarks and within ~1% utility retention on AlpacaEval 2.0 RedVisor. We run it on SplitCell documents flattened to markdown — its intended input format — with the same downstream models and the same tuning budget (we tune its adapter on an equal number of attack examples as our policy's safety-reward training set), plus a latency-matched comparison. Beating it means lower ASR on fragmented and layout-channel attacks at equal or better benign accuracy and strictly lower added latency, since our probe-based reward generates no extra tokens.

The key ablation is the same defensive policy trained without the layout stream — candidates are flat text blocks with no coordinates or structural roles. If spatial features are the operative ingredient, this ablation should lose most of the ASR reduction on layout-dispersed attacks while retaining it on purely textual monolithic ones; if it performs as well as the full model, the layout story is decorative and the probe reward is doing all the work, which would itself be a clean finding. A second ablation removes the safety term ($\lambda = 1$), reverting to the benign-trained sequential policy, which doubles as the attack-side subject of Experiment 1.

Why not just…?

Why not just feed the whole document to a long-context model? This is directly refuted on the relevant data: on the FinHybrid financial corpus, UDA reports that long-context ingestion without retrieval scored 0.4 where retrieval scored 45.9, the "lost in the noise" effect UDA. RCR adds the complementary point that context quantity itself hurts: 4 well-chosen examples beat 100–150 examples, 78.21% versus roughly 63% Reinforcing Compositional Retrieval. And from the security side, ingesting everything means ingesting every injection fragment with no selection layer at all — the worst case for our threat model. We will still report this baseline's ASR, since a model that reads everything might refuse everything; if it does so at acceptable benign accuracy, that would genuinely weaken the proposal, and Experiment 1 will surface it.

Why not just flatten the document with OCR and run a text safety filter? Three lines of evidence say flattening loses the signal. Rule-based and supervised flattening pipelines are brittle across bordered and borderless tables and non-standard alignment CascadeTabNet: An approach for end to end table detection and structure recognition from image-based documents, Vision Grid Transformer for Document Layout Analysis, and UDA shows parsing errors are the "silent killer" of downstream performance UDA. PANDORA specifically demonstrates that PDF-wrapped payloads evade upload-time keyword filters Pandora, and VPI-Bench shows visually situated instructions bypass text-only guardrails entirely VPI-Bench. Our layout-flattening ablation makes this comparison concrete rather than rhetorical: if the flat-text defensive policy matches the spatial one, the reviewer wins and we report it.

Why not just add a secondary guard model or a "be vigilant" system prompt? System-prompt warnings are measured to be nearly useless: VPI-Bench found 100% attempted attack rates for browser agents despite vigilance instructions VPI-Bench, and AE-CoT reports 92–96% attack success against reasoning models that have been reminded of safety Reasoning as an Attack Surface. A secondary guard LLM is the serious version of this alternative — RedVisor itself was built to avoid its double-prefill memory and latency cost, and still pays 0.6–2.5 seconds per query for its own trace generation RedVisor. Our design is best understood as a guard that lives inside the selection policy's reward rather than as a second model: it is a real threat if a well-tuned guard model on flattened text performs as well as our policy, and the RedVisor comparison in Experiment 2, run at matched tuning budget, is exactly the experiment that settles it.

Decisive Checks

The proposal stands or falls on three numbers. First, the perverse incentive: sequential policies must show materially higher fragmented-injection ASR than top-$K$ retrieval on SplitCell, with the probe confirming refusal-score suppression in the assembled context; if top-$K$ is equally exploitable, the attack story collapses and only the defense story survives. Second, the defense frontier: the dual-reward policy must cut ASR by roughly an order of magnitude relative to the benign-trained policy and the PANDORA reference (64.3% on GPT-3.5) while holding benign accuracy within a few points of RCR's reported level (59.64% on GeoQuery Template 1, 78.21% with 4 examples) Reinforcing Compositional Retrieval. Third, the ingredient test: the no-layout ablation must underperform the spatial policy specifically on layout-dispersed attacks. If all three hold, the selection layer — not the generator, not a bolted-on filter — becomes the cheapest place to enforce safety over visually rich document corpora.