TL;DR
Deploying proprietary AI models on edge devices leaves their valuable weights vulnerable to theft if the host operating system is compromised. Hardware-isolated "safe rooms" called Trusted Execution Environments (TEEs) can shield these weights, but they have tiny memory budgets that cannot fit modern neural networks. Onnx2TEE solves this by automatically slicing complex neural networks along natural graph bottlenecks, compiling just the sensitive pieces into lean, standalone C code that slips neatly inside a hardware vault.
What Problem Does This Paper Address?
When you deploy an AI model to an edge device—say, a smart camera or an autonomous drone—you leave the safety of the cloud behind. Even if you encrypt the model on disk, its weights must be decrypted in RAM during inference, where a compromised operating system can easily steal or tamper with them.
To prevent this, engineers turn to Trusted Execution Environments (TEEs) like Arm TrustZone. Think of a TEE as a hardware-enforced VIP room inside the CPU that even a hacked OS (the Rich Execution Environment, or REE) cannot peek into. The catch? That VIP room is tiny—often limited to just a few dozen megabytes of RAM (64 MiB by default on the authors' testbed).
Because modern deep neural networks (DNNs) rarely fit inside a TEE whole, researchers use split inference: running sensitive parts in the TEE and the rest in the normal OS. However, existing tools either assume models are simple, straight-line sequences of layers, modify the model via pruning, or cram bloated ML runtimes into the TEE. Modern networks are tangled webs of skip connections and branches; slicing them naively forces multiple data tensors across the security boundary at once, tanking performance and blowing up memory.
Methods
Onnx2TEE is an automated, framework-agnostic compilation pipeline that turns standard ONNX models into split-inference applications without needing a heavyweight runtime inside the TEE.
- Graph-Aware Segmentation: Instead of thinking in "layers," Onnx2TEE views a feed-forward network as a directed acyclic graph of operators. It greedily groups operators into single-entry, single-exit subgraphs—pinch points where the tangled web of branches collapses down to a single intermediate tensor. Slicing only at these pinch points guarantees that switching between the normal OS and the TEE requires passing just one tensor.
- Ahead-of-Time C Compilation: Rather than stuffing an entire inference engine (like ONNX Runtime) into the secure world, Onnx2TEE uses the
emmtrixcompiler to translate the TEE-bound subgraph directly into standalone C code, baking the weights right in as static arrays. - Secure Templates & Memory Validation: The generated C code is wrapped in GlobalPlatform-compliant templates that enforce security best practices—such as copying shared-memory inputs into private secure buffers to prevent Time-of-Check to Time-of-Use (TOCTOU) attacks. Before compiling, the pipeline estimates weights, activations, and buffer sizes, automatically rejecting partitions that exceed the TEE’s memory budget.
Datasets
No new benchmarks were introduced. The authors trained a small 206,922-parameter CNN on the MNIST dataset and evaluated it on an 8-image subset (MNIST8). To test a complex, branching architecture, they evaluated Ultralytics' 2.4-million-parameter YOLO26n object detector on the COCO8 dataset.
Key Insights and Ideas
- Parameters clump together dramatically: Graph-aware slicing reveals that weights are wildly imbalanced across segments. You don't need to lock up most of the segments to protect most of the intellectual property—targeting a single parameter-dense segment can shield nearly the entire model's learned weights (assuming it fits in RAM!).
- Putting more of a model in the vault can actually use less memory: Intuitively, adding more operations to the TEE should increase its memory footprint. Surprisingly, the opposite can happen! Because the TEE must duplicate boundary tensors into private buffers for security, slicing right before a spatial downsampling layer requires a massive output buffer, whereas extending the TEE partition past the downsampling shrinks that buffer dramatically.
Key Results
Evaluated on an NVIDIA Jetson AGX Orin (ARM Cortex-A78AE with OP-TEE and 64 MiB of dedicated TEE RAM):
- Weight Concentration: In the 10-segment MNIST CNN, 97.06% of parameters landed in Segment 8 (the main linear layer). In the 19-segment YOLO26n, 96.96% of parameters concentrated in Segment 17 (the neck and feature-fusion block). While MNIST's heavy segment easily fit in the TEE, YOLO26n's Segment 17 exceeded the 64 MiB limit, capping the maximum deployable TEE protection for YOLO26n at Segment 10 (1.51% of parameters).
- The Downsampling Memory Trick: In YOLO26n, partition
(P7, P10)exceeded the TEE memory budget and failed to deploy, yet the larger partition(P7, P11)succeeded at 39.8 MiB. Including that extra segment crossed a downsampling step, shrinking the duplicated output buffer from 6,400 KiB down to 1,600 KiB. - Latency Overhead: World-switching and TEE session setup carry a real time tax. On the tiny MNIST model, baseline REE inference took 2.50 ms, while TEE partitions jumped to ~233.66–234.35 ms. On the heavier YOLO26n model, the relative hit was much gentler: baseline REE took 5,350.90 ms, while deployable TEE partitions ranged from 5,584.44 ms to 5,663.09 ms (~4–6% overhead).
Limitations and Future Work
- Bundled Latency Metrics: Current timing wraps Trusted Application (TA) startup/teardown and world-switching together with computation. Keeping the TA persistent in memory across consecutive inferences—and logging internal TEE timestamps—will better reflect real-world edge deployments.
- Single Contiguous Partition & Oversized Segments: Onnx2TEE currently executes only one contiguous block (
pre-REE -> TEE -> post-REE), and complex skip connections can still force a segment (like YOLO26n's Segment 17) to grow larger than available TEE RAM. Future work aims to split protection across multiple non-contiguous TEE islands. - Engineering & Security Nuances: Standalone C generation sometimes requires custom math approximations (which can subtly alter numerical behavior if not careful), changing partitions requires recompiling, and the system does not yet automatically rank which weights are most security-critical—a prime target for future automated selection.
Summary updated