Rewriting the Response Path: Silent Tampering in BYOK LLM Agents and a Provider-Signature DefenseRewriting the Response Path: Silent Tampering and Provider-Signed Defense in BYOK LLM Agents
The authors propose the response-path integrity gap of BYOK agents: the relay can rewrite execution fields; RTA makes 99.7% of solutions that pass public tests on APPS carry degraded behavior, and sign-c blocks all tampering at 0.0167% overhead.
The attacker is an authorized relay (authorized endpoint) located between agent U and model S in a BYOK deployment, able to observe and replace any message in bidirectional transmission, but the payload must remain schema-valid. The goal is to make U execute attacker-controlled actions while keeping records trustworthy: exec(c′)≠exec(c)∧view(r′)≈view(r). Scope excludes malicious agent software, providers that control model weights, transport-layer MitM and visible destructive actions.
- In BYOK agent frameworks, the user-authorized relay can read and rewrite in plaintext the execution fields returned by the model, and the agent executes them without verifying their provenance; the authors call this the response-path integrity gap, which can lead to False-Green Verification where tests pass but security is silently degraded.
- The authors propose the RTA attack: the relay rewrites a single execution field after alignment is complete, and uses the user's own key to have the model polish the remaining text; on the defense side they propose sign-c, in which the provider gateway and a local shim sign the normalized execution contract κ(c) and verify it bidirectionally, with the relay only reading routing fields.
- On SWE-bench Django and APPS, RTA-PostForge makes 69.0% of forced-edit instances and 99.7% of solutions passing public tests carry security degradation, respectively; on ASB the average ASR is 89.1%, higher than prompt injection's 42.6%; sign-c blocks all tampering with 0.0167% latency overhead and zero false rejections.
- The authors state that sign-c does not authenticate free text, that the confidentiality layer stops at the gateway, and that it relies on key distribution channels the relay cannot control; the numbers in the header row are single-run estimates, and zero false rejections do not cover streaming reassembly and cross-provider normalization; there are 5 models tested in total, and all experiments were conducted on the new-api relay.
- Evaluated models
- GPT-5.4Gemini-3.1-proClaude-opus-4.6GLM-5.1MiniMax-M2.5
- Benchmarks
- SWE-bench Django (SWE-bench Verified)APPSAgentDojoAgent Security Bench (ASB)
- Metrics
- ASRUtilitysecurity-defeatrefusal ratedetection ratefalse rejectionlatency overhead
Researchers propose the Relay Tampering Attack targeting the response path of BYOK LLM agents, and present a provider-signature defense, sign-c. A BYOK agent accesses the model through a user-authorized relay; the relay can rewrite the field carrying execution after alignment is complete, making a patch pass public tests but fail a hidden safety oracle. The paper reports that on SWE-bench Django the safety oracle was defeated in 69.0% of cases, and on APPS 99.7% of solutions passing public tests carried degraded behavior; on AgentDojo and ASB, rewriting a single field still changed agent behavior with success rates of 72.5% and 89.1% respectively, while the user task was completed. sign-c has the model API side sign only the execution-carrying field, with a local shim verifying it; the paper states that on the new-api gateway it rejects all tampered responses with zero false rejections, a median overhead of 2.97 milliseconds, accounting for 0.0167% of inference latency.
Why it was selectedThe paper presents empirical data showing that a BYOK relay rewriting a single execution field can make a patch pass public tests while introducing vulnerabilities, and proposes a lightweight defense that signs only the execution field.
Paper analysis
What problem does this paper attempt to solve?
BYOK agents trust responses forwarded by an authorized relay, but no mechanism binds execution fields to the model that generated them, which the authors call the response-path integrity gap.
Core problem: In BYOK agent frameworks, an authorized relay can rewrite in plaintext the execution fields returned by the model, and the agent executes the fields without verifying their origin; the authors call this the response-path integrity gap.
- Scenario and importance: The authors state that about 88% of mainstream real-world agents use BYOK configurations, with traffic forwarded through a user-authorized relay; among the 60 most-used OpenRouter applications the authors surveyed, 25 support custom backends, and 23 of those accept user credentials. Agents treat received fields as model output and execute them directly.
- Shortcomings of existing methods: The authors state that alignment only constrains tokens generated by the model, and TLS only authenticates hop by hop and provides no end-to-end proof of origin; encryption does not help either, because the relay is a legitimate decryption endpoint required by the architecture; agent-side content detectors check content rather than origin.
- Core observation: The user authorizes the relay to read traffic for routing, but this confidentiality exemption effectively becomes an integrity exemption; the relay only needs to rewrite a single execution field and use the user's own key to have the same model regenerate the remaining text, preserving the model's original style.
- Proposed in the paper: RTA (Relay Tampering Attack), a proof-of-concept attack, and sign-c, a defense in which the vendor-side gateway signs only the execution fields and a local shim verifies them before execution, with mutual authentication and optional encryption of the message body.
- Threat model (§4):
- Target: tool-using agents that parse execution fields into actions such as file, shell, test, and CI actions; coding agents are the highest-privilege instance.
- Attacker knowledge and capability: an authorized endpoint in a BYOK deployment, located between agent U and model S, able to observe and replace any transmitted message in either direction, but the payload must be schema-valid.
- Attack goal: make U execute attacker-controlled actions while records remain trustworthy, i.e., exec(c′)≠exec(c)∧view(r′)≈view(r); the high-value instance is False-Green Verification.
- Out of scope: malicious agent software, vendors controlling model weights, transport-layer MitM, and visible destructive actions; passive confidentiality leakage over plaintext transmission is left unevaluated.
What related research exists?
Related work falls into four groups: relay and supply-chain measurement, prompt injection and agent-side defenses, application-layer authenticity schemes, and verification trust in software engineering.
Relay Infrastructure and Supply-Chain Security
- Liu et al. [43]—probed 428 publicly sold routers, found 9 injecting code and 17 accessing implanted credentials, proposed the Router-in-the-Middle threat model, with defenses relying on anomaly screening and transparency logs. The paper notes they do not authenticate provenance, so schema-valid rewrites still pass; this paper is complementary: they measure relay behavior, this paper analyzes the architectural flaw.
- Ladisa et al. [39], Wang et al. [66]—catalog traditional software supply-chain attacks, noting that LLMs extend the attack surface to model relays, datasets, and execution infrastructure.
- LiteLLM incident [26]—a case of relay software supply-chain poisoning; the paper notes the damage was caused by malicious code inside the relay package, different from the response-path tampering studied here.
Prompt Injection and Agent-Side Defenses
- Direct/indirect prompt injection [11, 30, 54, 56, 75, 76]—induces the model to output unsafe content.
- Boundary-hardening defenses: runtime sandboxing [69], privilege separation (CaMeL [25], Progent [63], PFI [37]), data-flow isolation [21], guardrail classifiers [31, 33, 44, 72], agent-tool permission models [10]. The paper notes these defenses all assume the payload comes from an aligned model, evaluate only content safety and do not authenticate provenance, whereas relay tampering occurs after generation.
Application-Layer Authenticity and Verification Trust
- DKIM [18], HMAC [38], AWS SigV4 [2], HTTP Message Signatures [7]—application-layer signing schemes across intermediaries; the paper notes they sign the raw payload, whose canonicalization cannot survive the relay's benign reserialization, nor resist silent stripping.
- Perry et al. [57], Peng et al. [55], Ren [61], Dai et al. [20]—developers over-trust AI-generated code, and coding agents produce functionally correct but vulnerable patches; the paper says this work shows a response-path attacker can artificially create the same false confidence.
Baselines and Benchmarks: the attack reference is prompt injection (DPI/OPI); defense baselines are Delimiter, Sandwich, KAD, CaMeL, and a perplexity filter, PI-Detector, tool-name filtering, and OPA policy; benchmarks are SWE-bench Django, APPS, AgentDojo, ASB.
Authors' positioning: sign-c ports DKIM-style selective provenance signing to the model-agent response path, with the increment being that canonicalization and per-route pinning make the signature deployable without breaking BYOK routing; the authors say sign-c is the first scheme to bind execution fields to the model-agent boundary while preserving routing.
How does the paper address this problem?
First use RTA to demonstrate that the gap is exploitable, then propose sign-c: the vendor gateway and local shim sign the canonicalized execution contract and verify it bidirectionally, and the relay retains only read permission.
The overall approach has two steps: first, use RTA (Relay Tampering Attack) to show that the response-path integrity gap can be exploited by a minimal-capability attack; then use sign-c to establish a cryptographic binding between execution fields and the model at the application layer.
Problem Formalization
- A response is denoted r=(x, c), where x is the natural language the developer reads and c is the execution field (tool_use block or JSON payload); the agent's next action is determined by c.
- Direct connection guarantees implicit provenance: execution occurs only when auth_S(c)=1; the gap is that the agent computes exec(c) without evaluating auth_S(c), so any schema-valid c′ is executed just like the real c, which the authors call silent trust expansion.
- Three observations: post-hoc detection cannot distinguish tampering from a normal response (the relay can have the model regenerate the surrounding text); the threat is architectural rather than cryptographic (the relay obtains a Dolev-Yao position with user authorization); authentication requires cooperation from both the vendor and the receiving end.
RTA Attack (§5)
- Tactical layer: rewrite only key structured fields, split into semantic tampering (rewriting labels, scores, results) and structural tampering (replacing tool_use names, rewriting parameters, inserting tool_use blocks, switching finish_reason).
- Stealth layer: send the rewritten draft back to the same model via the user's BYOK key for polishing, with the attacked fields locked in place, so the text matches the model's native style; the original request is forwarded through a separate channel and the real output is cached.
- Strategic layer (Chain Attack): decompose the goal into ordered subgoals G=⟨g1,…,gn⟩, check the real output each round, decide whether to forward or intervene, and cache extracted runtime artifacts for later tampering.
sign-c Mechanism (§6)
- Architecture: a gateway in front of the model and a local shim beside the agent, with private keys stored only at the two ends; the gateway signs the fields produced by the model, and the shim symmetrically signs outgoing requests, achieving bidirectional application-layer authentication; an optional sealing layer performs authenticated encryption on the message body, while routing fields (such as the model name) remain in plaintext.
- Signature scope: for a response r=(x,c), the gateway signs the binding b = ⟨ s, t, H(κ(q)), H(κ(c)) ⟩, where s is the session, t is the turn, and H is a collision-resistant hash; prose, usage metadata, and identity fields are not in b.
- Canonicalization: κ(·) reduces the payload to its execution contract—ordered tool calls (identifier, name, parameters) and finish reason—matching the Anthropic and OpenAI wire formats; it is invariant to benign reserialization (field reordering, whitespace normalization, streaming reassembly) and sensitive to any edit that changes execution.
- Verification: the receiving end recomputes the binding and admits the response only when Vrfy_pk(b,σ)=1 and b exactly matches the session, turn, and hashes of κ(q′) and κ(c′); otherwise it rejects with a named error distinguishing rewritten contract, tampered request, or replayed turn.
Key Distribution and Deployment
- Trust bootstrap: the shim can fetch keys and policy directly from a well-known endpoint in the vendor's domain over TLS; in restricted networks, HSTS preload models pin the parameters in the signed shim distribution.
- Downgrade resistance: after policy is pinned per route, stripping signatures, forging signatures, denying signatures, and rerouting to an unpinned model all reduce to verification failure; the only action a relay can take to escape verification is to refuse forwarding, which manifests as visible denial of service (Table 1).
- Adoption path: takes effect per route, with no changes to the agent or model API; the authors propose that vendors can attach a detached signature over H(κ(c)) in a single response header X-Model-Signature, as a path toward standardization.
What experiments did the paper conduct?
Five models, four benchmarks: RTA defeats 69.0% of the safety oracle on Django, and 99.7% of test-passing solutions on APPS carry degradation; sign-c blocks all tampering, with zero false rejections and 0.0167% overhead.
Experimental Setup
- Models tested: gpt-5.4, gemini-3.1-pro, claude-opus-4.6, glm-5.1, MiniMax-M2.5, 5 in total, covering closed-source and open-weight.
- Attacks: RTA-PostForge (post-alignment response-path rewriting, the main subject of this paper) and RTA-PreWrite (query-path variant, used only as an upper-bound reference); the reference attack is prompt injection DPI/OPI.
- Benchmarks and scale: SWE-bench Django (12 of 18 issues force-editable, 60 instances across 5 models) with ControlArena-style CWE security side tasks; APPS 100 problems per model; AgentDojo four suites totaling 949 cases; ASB ten domain agent roles.
- Metrics: Utility (public test pass rate / user task utility), security-defeat (hidden oracle failure rate), ASR, refusal rate, detection rate (at a 5% false-positive budget), false-rejection rate, latency.
- Runtime environment: all attacks and defenses run on the real open-source BYOK relay new-api (over 40k GitHub stars); headline numbers are single-run estimates, with binomial confidence intervals reported.
- Repetitions: the paper reports a single run plus Wilson confidence intervals, and does not report repeated runs.
Main Results
According to Table 3 (Utility is public test pass rate, Sec-defeat is hidden oracle failure rate, same run):
Swipe horizontally to read the table
Method Django Utility Django Sec-defeat APPS Utility APPS Sec-defeat Honest 0.581 0.105 0.654 0.000 Prompt injection 0.477 0.216 0.506 0.166 RTA-PreWrite 0.533 0.556 0.630 0.000 RTA-PostForge 0.517 0.690 0.624 0.997 - The authors say that on Django, RTA-PostForge defeats the security oracle in 69.0% of forced-edit instances (95% Wilson CI [57.6, 77.4]), while the public test pass rate is 51.7%, a difference of 58.5 percentage points from the clean baseline; on APPS, 99.7% (95% CI [98.5, 100.0]) of solutions passing public tests carry degraded behavior.
- The authors say neither prompt injection nor the query-path variant produces False-Green Verification; in the ablation, removing the single execution-field rewrite reduces the effect by 49.3 percentage points, on which basis the authors locate the effect after alignment.
- For post-hoc detection, Model Equality Testing at α=0.05 rejects the same-distribution null hypothesis for only 54.2% of polished response-path runs (90.0% for the query path); the authors say same-model polishing keeps the response a genuine sample of the model.
Endpoint Defense Evaluation (RQ2)
- Vendor side: averaged over five models on ASB, prompt injection DPI/OPI has ASR 42.6%/28.1%, RTA-PostForge 89.1%, and RTA-PreWrite 98.9% (Table 5); the authors note this is not a like-for-like comparison—injection must persuade the aligned model, whereas rewriting bypasses that stage, showing that model-side protections cannot reach the response path.
- On AgentDojo: RTA-PostForge reaches 72.5% success rate on tool-call injection while retaining 50.3% user task utility, versus 11.4% for prompt injection (main text; the Figure 5 trend is consistent across five models).
- Agent-side defenses (Table 6, AgentDojo, claude-opus-4.6): Delimiter/Sandwich reduce average ASR to 52.9%/52.0% at a utility cost of 15.3/18.1 percentage points; KAD leaves 45.6% ASR with 48.3% utility; CaMeL reaches the baseline 14.8% level but average utility drops to 37.9% (0 on Travel), and the authors say a single relay adaptation (injecting the action into the Python code block it executes) restores the success rate to 50.1%.
Content Detectors and Cross-Relay Designs (RQ2/RQ3)
- Detection rate (Table 7, APPS n=353 and Django forced edits, 5% false-positive budget): perplexity filter at most 0.30 (Django 0.09), PI-Detector 0.02/0.09, and Delimiter, Sandwich, KAD, tool-name filtering, and OPA policy all 0.00; sign-c is 1.00/1.00.
- Cross-relay designs (Table 2 and a signature-surface scan of 439 APPS tamperings): full-path encryption hides routing fields and breaks aggregation; whole-response byte signatures falsely reject benign reserialization; the authors say only the canonicalized execution contract maintains zero false rejections under full coverage.
sign-c Effectiveness and Cost (RQ4)
- Integrity: replaying 353 APPS and 58 Django tamperings (across all five models), sign-c rejects all; on clean traffic, 694 verified AgentDojo responses have zero false rejections, and matched clean original responses also have zero false rejections.
- Cost (Table 8, AgentDojo, claude-opus-4.6): p50 total increase of 2.971 ms, 0.0167% of the 17,796 ms median upstream inference; default Ed25519 (median 57 μs signing, 373-byte envelope), which the authors say is 56× faster than RSA-3072.
- Case study (§7.5, Figure 6): on the production Claude Code CLI, a one-line fix for django-16873 was rewritten by the relay into a form that reintroduces stored XSS (CWE-79), with unit tests passing and the agent reporting the fix as verified on all five models; with sign-c enabled, the shim rejects the edit before execution.
Other Ablations and Analyses
- Per-CWE breakdown (12 Django instances): the authors say the defeat rate tracks model capability rather than vulnerability class, with categories the model can complete defeated 80–100% and the two single-instance categories it never passes at 0.
- Stealth-layer cost: same-model polishing adds one model call per tampered turn, and the authors say token usage roughly doubles on these turns, which can serve as a supplementary detection signal.
- Latency: the authors say 74% of the polishing latency overhead falls within the variance of benign relay traffic.
What are some points that can be further explored?
The authors list the scope limitations of sign-c and its key distribution assumptions; the experiments cover 5 models and 4 benchmarks, all run once on the new-api relay.
Limitations and Future Directions Noted by the Authors
- sign-c does not authenticate free-text prose, nor does it remove the one-time vendor onboarding; the confidentiality layer ends at the gateway rather than the model (§8; the authors call this a deliberate scope choice to keep the trusted computing base small).
- Downgrade resistance assumes the shim's pinned keys and policy reach the endpoint through a channel the relay cannot control; if the relay also distributes the client, provenance must be established separately, e.g., a signed distribution independent of the relay (§8).
- Agents that execute code embedded in free-text response bodies require extending κ to that region; the paper says the construction can accommodate this directly but does not instantiate it (§6.3).
- The side-task oracle paired with same-run utility remains a proxy for real security; the paper reports model-invariant trends rather than single-model peaks (§8 Threats to validity).
- The headline numbers are single-run estimates; the zero false-rejection result covers only field reordering and whitespace reserialization on new-api, not streaming reassembly or cross-vendor canonicalization (§8).
- The authors say that as protocols such as MCP are adopted, the unsigned surface will grow, and the gap applies to any agent that parses tool-call fields from an unauthenticated intermediary (§8 Generalizability).
Experimental Coverage
- The models tested are gpt-5.4, gemini-3.1-pro, claude-opus-4.6, glm-5.1, and MiniMax-M2.5, 5 in total (§7 Experimental Setup).
- The benchmarks are SWE-bench Django (60 instances), APPS (100 problems per model), AgentDojo (949 cases), and ASB (ten roles); all attacks and defenses run on the new-api relay.
- The defense evaluation includes Delimiter, Sandwich, KAD, CaMeL, and a perplexity filter, PI-Detector, tool-name filtering, and OPA policy; the agent-side defense evaluation uses only claude-opus-4.6 (Table 6).
- The detection-rate evaluation sample sizes are APPS n=353 and Django forced edits (Table 7); the main Django result is a single run on 60 instances.
- The paper does not report the attack's iteration budget or query-count statistics, the judge model (the security oracle is a CWE-class target; the paper does not state whether judging is by LLM judge or rules), nor repeated runs.
Summarize the main content of the paper
A BYOK relay can silently rewrite execution fields, causing False-Green Verification; sign-c signs the execution contract and blocks all tampering at 0.0167% overhead.
An attack and defense paper on the security of BYOK agent architectures.
- Problem: In BYOK frameworks, the user-authorized relay legitimately decrypts traffic for routing, but the agent does not verify the provenance of execution fields; the authors say this confidentiality exemption effectively becomes an integrity exemption, constituting a response-path integrity gap that alignment, TLS, and agent-side content detection cannot reach.
- Method: The RTA attack rewrites a single execution field after alignment completes and uses the user's own key to have the same model polish the surrounding text; the defense sign-c has the vendor gateway and local shim sign the canonicalized execution contract κ(c) and verify it bidirectionally, and pinning policy per route turns signature stripping into a visible failure, so the relay retains read access but loses write capability.
- Result one: On SWE-bench Django, RTA-PostForge defeats the hidden security oracle in 69.0% of forced-edit instances while public tests still pass; on APPS, 99.7% of solutions passing public tests carry degraded behavior (Table 3).
- Result two: On ASB, the five-model average ASR is 89.1%, higher than prompt injection DPI's 42.6%; on AgentDojo, 72.5% success rate while retaining 50.3% user task utility (Table 5, main text).
- Result three: Content detectors achieve at most 0.30 detection rate at a 5% false-positive budget, and agent-side defenses such as CaMeL either leave room or lose up to 49.3 percentage points of utility; sign-c has detection rate 1.00, zero false rejections, and a p50 increase of 2.97 ms (0.0167% of inference latency) (Table 6–8).
- Authors' conclusion: The authors consider the gap an inherent flaw of the BYOK architecture rather than a behavior problem of an individual relay, requiring protocol-level provenance authentication; the authors say they disclosed to the new-api maintainers and affected vendors (e.g., Anthropic) under a 90-day window and released the full testbed.