When a program moves sensitive code into a hardware enclave — a sealed region of the processor whose memory is encrypted so that even the machine's owner cannot read it — the hard part is no longer protecting the code inside. It is the bridge: the marshaling interface through which the untrusted host operating system calls into the enclave and receives results back. That bridge is exactly where two well-documented failure classes live. A confused deputy arises when the enclave performs a privileged operation on behalf of an untrusted caller without re-checking the caller's authority — the same pattern that let untrusted web scripts drive native Android APIs through WebView bridges in 4,997 apps with over three billion installs BabelView. An Iago attack arises when the untrusted host lies through the interface itself, returning manipulated system-call results to steer enclave control flow BesFS: Mechanized Proof of an Iago-Safe Filesystem for Enclaves.
Tools that automatically port code into enclaves now exist and work well: AUTOTEE uses an LLM refinement loop to translate sensitive Java and Python functions into Rust enclave code, achieving 91.8% transformation success on Java Automated TEE Adaptation With LLMs. But its refinement oracle is only the Rust compiler plus functional-equivalence tests, and it explicitly assumes that enclosing a leaf function in an enclave makes the resulting host-facing interface safe. The evidence says otherwise: compilers and functional tests cannot see semantic authority bugs, and AI-assisted developers iterating without an independent security oracle produced vulnerable SQL-injection code 36% of the time versus 7% for unassisted humans Do Users Write More Insecure Code with AI Assistants?. Meanwhile, signature- and pattern-based detectors fail precisely on this class of problem, because architectural permission conflation at a novel interface is a zero-day by construction — there is no historical pattern to match, and static analyzers break on reflection, dynamic loading, and native transitions BabelView; classic tools like Cppcheck and Flawfinder missed such bugs entirely on large C projects Devign.
Core Claim
The claim of this proposal is that confused-deputy and Iago blindspots at host–enclave bridges can be found and fixed automatically, by replacing the compiler-and-tests oracle in enclave code generation with an adversarial execution oracle: an iterative refinement loop in which a red-team agent attacks the generated bridge from the untrusted side, a critic with structured disagreement filters false findings, and a patcher refines the bridge against the attacker as a regression test. The three prior works nearest to this idea each stop short: AUTOTEE generates bridges but never audits them Automated TEE Adaptation With LLMs; Co-RedTeam attacks code with execution feedback but only inside a neutral Docker sandbox whose "adversary" is a benign environment, and only against CWE/OWASP-cataloged flaws in conventional software Co-RedTeam; Proof-of-Guardrail uses enclaves to certify that a safety check ran, while conceding that attesting execution says nothing about whether the check is effective — its enclave-hosted guardrail scored an F1 of only 0.56 Proof-of-Guardrail in AI Agents and What (Not) to Trust from It. Nobody has aimed closed-loop adversarial refinement at the enclave boundary itself, where the threat model is unusual: the attacker is the host, the very party that all ordinary execution environments treat as trusted infrastructure.
Research Program
The program has three components, each built on techniques the corpus supplies.
The first component is a benchmark, which we call EnclaveBridgeBench. We extend AUTOTEE's pipeline — its 68-repository corpus of sensitive leaf functions and its LLM-driven Rust translation — to also emit the host-facing port interface it constructs, and we seed a portion of those bridges with a taxonomy of boundary blindspots drawn from the literature: unvalidated caller authority (the BabelView confused-deputy pattern BabelView), unchecked host-controlled return values (the Iago pattern BesFS), permission conflation where one bridge port serves callers of differing trust (the monolithic-origin problem in browser storage Least Privilege Access for Persistent Storage Mechanisms in Web Browsers and capability leaks across origins Cross-Origin JavaScript Capability Leaks), type-confused marshaling across the serialization boundary, and check-time-of-use gaps on data crossing the perimeter. Each seeded blindspot ships with a ground-truth exploit and a functional specification so that detection and repair can both be scored. Unseeded, unmodified AUTOTEE output is retained as a held-out set to estimate how often these blindspots arise without any seeding. No reported result found on Lacuna for the blindspot rate of unaudited generated enclave bridges; measuring that prevalence is itself a contribution.
The second component is the attack harness: a compromised-host simulator that wraps the enclave and can, by construction, manipulate anything the enclave consumes from the outside — return values of interface calls, bytes of input buffers, timing of responses. This is the piece Docker-based red-teaming cannot express, because in an ordinary container the "environment" is honest by default; here the environment is the adversary. The red-team agent operates Co-RedTeam-style, planning and executing exploit steps against the bridge and parsing execution traces as feedback, which Co-RedTeam's own ablations identified as its single most critical component Co-RedTeam. Because LLM agents under conversational pressure agree on wrong answers — false consensus — every claimed finding must survive a critic that demands concrete, line-cited disagreement evidence before the finding is accepted, a protocol shown to lift complex repair performance over both zero-shot and larger unconstrained teams Adversarial Review. A finding counts only when the agent produces a reproducible proof-of-concept execution trace through the simulator, never on textual reasoning alone.
The third component closes the loop on the generation side. The patcher refines bridge code — adding return-value validation, per-caller authority checks modeled on the object-tagged, whole-call-stack permission design of Beast in the Cage, and tighter marshaling contracts — with the attacker replayed after every patch as the regression oracle. This directly targets the "Model Close" trap documented by Perry et al.: iteration without an independent external semantic validator amplifies security flaws. Since iterative refinement is known to plateau or actively erode non-targeted invariants after a few rounds Yan et al., SlopCodeBench, the patcher tracks functional-equivalence scores and rolls back to the last stable checkpoint on regression, following the verification-score rollback design of Fang et al..
Baselines
The naive reference point is shipping AUTOTEE's output unaudited, which is the current de facto practice: AUTOTEE reports 91.8% transformation success on Java and 84.3% on Python, but no reported result found on Lacuna for any boundary-security measurement of its generated interfaces, so the do-nothing baseline is expected to sit at or near zero detection with an unknown, possibly high, true blindspot rate on the held-out unseeded set. The first real competitor is static taint analysis in the style of BabelView, which rewrote Android bytecode so that a taint tracker (FlowDroid) could flag confused-deputy flows from web content to native APIs; on its own WebView dataset it reached 90% precision at 66% recall BabelView. We will port this approach to the bridge interface-definition language so it examines the same host–enclave call surface, with the same per-interface analysis budget our method gets. It is the strongest competitor among non-LLM tools because confused-deputy detection is exactly what it was built for; beating it means higher PoC-confirmed recall, especially on the seeded cases involving dynamic typing, serialization type confusion, and host-controlled return values, where taint tracking has no source of truth. The second competitor is a graph-guided LLM audit in the style of GMLLM, which compresses a whole project to a high-attention subgraph (an average of 640 tokens) before LLM reasoning and achieved over 95% recall on malicious PyPI packages Efficient Code Analysis via Graph Representation Learning-Guided Large Language Models; it is the strongest static semantic detector in the corpus, and we will run it on the bridge subgraphs with the same model and token budget. The strongest overall competitor, and simultaneously the key ablation, is a Co-RedTeam-style execution-feedback agent run vanilla on our benchmark — same backbone, same Docker execution, same memory tiers, but without the compromised-host simulator and without the structured-disagreement critic. Co-RedTeam is the closest existing system to ours: it solved 63.7% of Cybench challenges and 65% of BountyBench with a Gemini-3-Pro backbone Co-RedTeam. We will run it at matched token and wall-clock budgets on identical bridge targets. Beating it means at least a 15-point gain in PoC-confirmed recall on seeded blindspots with a false-positive rate under 10% on clean bridges; if it matches us, the proposal's contribution collapses to the benchmark and harness, and we will report that honestly. Two further ablations isolate our ingredients: removing only the host simulator (agent runs in an honest environment) separates the value of modeling the host-as-adversary from the value of execution feedback itself, and swapping the patcher's oracle from adversarial replay back to AUTOTEE's compiler-plus-equivalence tests isolates the security-oracle claim.
Why not just…?
Why not just run a static analyzer on the generated bridges? Because the corpus documents static analysis failing on precisely the features these bridges have. FlowDroid, the engine behind the strongest static confused-deputy detector, struggles with reflection, dynamic loading, and native transitions BabelView — and a host–enclave bridge is by definition a native, dynamically marshaled transition. Cppcheck and Flawfinder missed vulnerabilities entirely on large real-world C projects where Devign's semantic graphs gained over 10% accuracy Devign, and decades of rule-based security-API checking have left misuse rates between 25% and 100% in analyzed apps Detecting Misuse of Security APIs: A Systematic Review. We still run the static baselines, so the head-to-head numbers will settle this rather than the prior literature alone.
Why not just prompt a frontier model with a strong security-audit prompt? The evidence against single-turn auditing is strong and specific. Unguided model interaction produced more vulnerable code than no assistance at all on security tasks, while inflating developer confidence to 4.0 out of 5 Do Users Write More Insecure Code with AI Assistants?. Zero-shot pass rates trailed structured adversarial review 77% to 87% on LiveCodeBench and 71.6% to 75.2% on SWE-bench Verified Adversarial Review, and whole-codebase prompting suffers attention drift that subgraph filtering had to fix GMLLM. More decisively, an Iago blindspot is invisible without executing the enclave against a lying host: no amount of reading the bridge code reveals what the code does when the return value it trusts is false. Our zero-shot and GMLLM baselines quantify the gap directly.
Why not just improve AUTOTEE's existing refinement loop with better tests? This is the most serious alternative, because it is cheaper than our full pipeline. But AUTOTEE's oracle is the compiler plus functional-equivalence tests, and a confused-deputy bug is functionally correct — the enclave does exactly what it was asked, by the wrong caller. Perry et al. showed that iterative fixing without an independent semantic validator magnifies exactly this class of flaw Perry et al.. Our oracle-swap ablation makes the comparison concrete: identical patcher, identical budget, oracle either rustc-plus-equivalence or adversarial replay. If the test-enriched AUTOTEE loop closes the seeded blindspots as well as ours, the simpler design wins and we will say so; our hypothesis, grounded in the functional-correctness argument, is that it will close the marshaling type-confusion cases and miss the authority and Iago cases.
Why not just use bigger sandboxes instead of modeling TEE semantics? Ordinary containers isolate the target from the agent's environment, but our threat model needs the reverse: the environment itself must be adversarial while the enclave holds its ground. A kernel-level or container-level escape is a different bug class from an Iago return-value lie, and Co-RedTeam's Docker harness has no mechanism to express the latter Co-RedTeam. Software sandboxes also cannot offer the hardware attestation that, in the Proof-of-Guardrail evaluation, caught 100% of code and output tampering Proof-of-Guardrail — relevant to our stretch goal of emitting an attested audit report, though we treat that as secondary to the detection result.
Proposed Experiments and Decisive Checks
Experiment one measures detection. On the seeded portion of EnclaveBridgeBench, we report PoC-confirmed recall (seeded blindspots with a reproducible exploit trace), precision on clean bridges, tokens and iterations consumed, and wall-clock per bridge, for our full loop against the four baselines and the host-simulator ablation, all at matched budgets and the same backbone model. The decisive check is whether the full loop beats vanilla Co-RedTeam by at least 15 points of PoC-confirmed recall with under 10% false positives; the host-simulator ablation tells us whether the gain comes from modeling the lying host or merely from execution feedback that Co-RedTeam already provides.
Experiment two measures prevalence. On the held-out unseeded AUTOTEE-generated bridges, our loop and the static baselines audit interfaces with no ground truth; every finding is manually confirmed, giving the first published estimate of how often automatically generated enclave bridges ship with exploitable boundary blindspots. Even a modest rate here is a finding, since AUTOTEE-style porting is presented as a security enhancement.
Experiment three measures repair. The patcher runs on seeded bridges under both oracles, and we track blindspot closure (adversarial replay success rate across iterations), preservation of functional equivalence against AUTOTEE's test harness, and erosion of non-targeted invariants in the spirit of SlopCodeBench, with the rollback mechanism from Fang et al. engaged. The decisive check is that the adversarial oracle closes authority and Iago blindspots that the compiler-plus-tests oracle leaves open, without losing functional correctness.
Experiment four calibrates difficulty against the human scale. We label each seeded blindspot with the time a human auditor would plausibly need and examine where the agent's success falls off, using the framing of Cybench, which found agents competent on tasks humans solve in under 11 minutes and near-zero on marathon tasks. If our boundary blindspots sit mostly below the agent's wall, that is a practical result: this audit class is automatable today, and hardware-rooted isolation can finally be paired with an audit proportional to its promises.
References
- BabelView: Evaluating the Impact of Code Injection Attacks in Mobile Webviews
- BesFS: Mechanized Proof of an Iago-Safe Filesystem for Enclaves
- Automated TEE Adaptation With LLMs: Identifying, Transforming, and Porting Sensitive Functions in Programs
- Do Users Write More Insecure Code with AI Assistants?
- Devign: Effective Vulnerability Identification by Learning Comprehensive Program Semantics via Graph Neural Networks
- Co-RedTeam: Orchestrated Security Discovery and Exploitation with LLM Agents
- Proof-of-Guardrail in AI Agents and What (Not) to Trust from It
- Least Privilege Access for Persistent Storage Mechanisms in Web Browsers
- Cross-Origin JavaScript Capability Leaks: Detection, Exploitation, and Defense
- Adversarial Review: Structured Disagreement for Grounded Agentic Code Review
- Beast in the Cage: A Fine-grained and Object-oriented Permission System to Confine JavaScript Operations on the Web
- CodeTransOcean: A Comprehensive Multilingual Benchmark for Code Translation
- SlopCodeBench: Measuring Code Erosion Under Iterative Specification Refinement
- MEIC: Re-thinking RTL Debug Automation using LLMs
- Efficient Code Analysis via Graph Representation Learning-Guided Large Language Models
- Detecting Misuse of Security APIs: A Systematic Review
- Cybench: A Framework for Evaluating Cybersecurity Capabilities and Risks of Language Models