Skip to content

ShadowNet: A Secure and Efficient On-Device Model Inference System for Convolutional Neural NetworksShadowNet: A Secure and Efficient On-device Model Inference System for Convolutional Neural Networks

arXiv· arXiv:2011.05905· S&P 2023· Zhichuang Sun, Ruimin Sun, Changming Liu, Amrita Roy Chowdhury, Long Lu, Somesh JhaGoogle; Florida International University; Northeastern University; University of California, San Diego; University of Wisconsin-MadisonIndexed by this site · 27 days ago· Originally publishedDefenses

Quick read

Defenses

Based on the paper PDF (AI-generated); refer to the original

The authors propose ShadowNet: use the TEE to protect CNN model weights and outsource transformed linear layers to an untrusted accelerator; on five CNNs, inference time increases by 0.6×–1.6×.

Threat modelThe attacker controls the Normal World (including the OS) and can observe everything exposed to the Normal World (including GPU tasks); the goal is to protect model privacy, and the attacker should not obtain any model information beyond the query API (Y = M(X)). Reasoning integrity and side-channel attacks against the TEE are not considered.

Questions
Thousands of private models are deployed on untrusted mobile devices, and prior research states that 41% of models are stored in plaintext and can be stolen; cryptographic approaches are slow, MPC requires networking, and existing TEE approaches struggle to simultaneously achieve model privacy, performance, and GPU acceleration.
Methods
ShadowNet quantizes CNN linear-layer weights into a finite field and then applies a linear transformation (adding random filters, random scalars, and permutations, with an adjustable obfuscation ratio r), outsourcing it to the Normal World/GPU; inputs and outputs are protected with one-time masks, and the nonlinear layers and result recovery are all done inside the TEE. It is implemented based on TensorFlow Lite and OP-TEE.
Experiments and results
On the five CNNs, inference time increases by 0.6×–1.6×, with accuracy comparable to the original models (YOLOv4-tiny mAP 55.90% vs. 57.06%); Top-1 agreement is 88%–98%; black-box extraction attacks that reuse the transformed weights achieve accuracy no better than the random baseline.
Limitations and future work
The authors state that reasoning integrity and TEE side channels are not covered, and that for learning-based black-box model extraction they give only a conjecture plus empirical evidence from two attacks; experiments are limited to five CNNs and one Hikey960 development board, and LSTM is only a proof-of-concept.
Experimental setupMobileNet、ResNet-44 et al. · ImageNet-2012、CIFAR-10 et al. · Top-1/Top-5 accuracy、Consistency et al.
Evaluated models
MobileNetResNet-44ResNet-404YOLOv4-tinyMiniVGGfour layer fully-connected CNNLSTM
Benchmarks
ImageNet-2012CIFAR-10VOC2007 testing datasetCIFAR-100
Metrics
Top-1/Top-5 accuracyConsistencymAP (50% IoU)model inference timemodel sizeattack accuracy
AI summaryShadowNet is an on-device model inference system that uses a trusted execution environment (TEE) to protect model privacy: linear-layer weights are transformed and outsourced to an untrusted accelerator, results are recovered inside the TEE, and nonlinear layers also remain inside the TEE. The prototype is based on TensorFlow Lite and evaluated on five CNNs—MobileNet, ResNet-44, MiniVGG, ResNet-404, and YOLOv4-tiny—with strong security guarantees and reasonable performance.

ShadowNet is an on-device model inference system that uses a trusted execution environment (TEE) to protect model privacy: linear-layer weights are transformed and outsourced to an untrusted accelerator, results are recovered inside the TEE, and nonlinear layers also remain inside the TEE. The prototype is based on TensorFlow Lite and evaluated on five CNNs—MobileNet, ResNet-44, MiniVGG, ResNet-404, and YOLOv4-tiny—with strong security guarantees and reasonable performance.

Paper analysis

6 questions; open one to read the full answer

  1. What problem does this paper attempt to solve?

    Protect the privacy of CNN model weights on untrusted mobile devices while not losing hardware acceleration capabilities such as the GPU.

    Core problem: How to protect the privacy of a deployed model's weights on untrusted mobile/edge devices while still using the device's untrusted AI accelerators for efficient inference.

    • Scenario and importance: The authors cite their prior research [67] stating that thousands of mobile apps use on-device ML, of which 41% of models are stored in plaintext and can be downloaded with the app package; even apps with encrypted storage may have the decrypted model extracted from memory at runtime, and 54% of ML apps use GPU acceleration. The authors argue that model leakage causes commercial loss.
    • Shortcomings of existing approaches (per the paper): HE-based cryptographic methods are several orders of magnitude slower than non-secure inference; MPC methods require multiple parties to be networked, making them unsuitable for real-time or offline tasks; existing TEE methods are limited by small TEE secure memory (e.g., only about 14MB available in OP-TEE on Hikey960, whereas the ResNet-404 model is 28MB), moving the entire inference framework into the TEE enlarges the TCB, and the TEE does not cover the GPU/NPU, losing hardware acceleration.
    • Core observation: CNN linear layers account for the vast majority of computation—the authors observe that MobileNet's linear layers account for about 95% of model weights and 99% of inference time, so linear layers can be securely outsourced while only nonlinear layers remain in the TEE.
    • Proposed approach: ShadowNet, an on-device secure model inference system: apply a linear transformation to linear-layer weights and outsource them to the untrusted world (including the GPU), recovering results inside the TEE; nonlinear layers also remain inside the TEE. The authors implemented a prototype based on TensorFlow Lite and OP-TEE and provide an automatic model conversion tool; the authors state that ShadowNet has been open-sourced.
    • Threat model (Sec. III-B):
      • Attacker capability: Controls the Normal World (including the OS) and observes everything exposed to the Normal World (including GPU tasks).
      • Attacker goal: Obtain information about model M(·) beyond what its query API (Y = M(X)) leaks, i.e., steal the model weights; the model input and final output are themselves known to the attacker.
      • Defense goal: Protect model privacy; the paper provides a formal security analysis (Sec. VI-D).
      • Out of scope: Model inference integrity is not considered (stated as achievable using Slalom's verification technique), and side-channel attacks against the TEE are not considered; the TEE is assumed to protect the confidentiality and integrity of its internal programs and data.
  2. What related research exists?

    Related work falls into three categories: TEE-based secure inference, cryptographic secure inference, and black-box model stealing attacks; the authors state that ShadowNet is the only solution that simultaneously satisfies all four goals.

    TEE-based secure model inference

    • Slalom [70]: outsources linear layers to the GPU and keeps the remaining layers inside SGX, protecting inputs with masks; the authors note that Slalom protects user input privacy rather than model weights (its model privacy protection is only described conceptually, with no implementation or evaluation), and that ShadowNet's masking design is similar but protects model weights.
    • OMG [32], MLCapsule [44], DarkneTZ [56]: OMG runs unmodified models on mobile devices based on the Sanctuary enclave; the authors state it is only a proof-of-concept, cannot be directly integrated into existing applications, and its trust assumption includes the entire software stack; MLCapsule runs inference inside SGX to prevent model leakage to the client; DarkneTZ runs some layers inside TrustZone. The authors state that none of the three supports secure GPU acceleration and that their TCBs are larger than ShadowNet's.
    • Graviton [72], Secloak [54]: Graviton proposes TEE extensions for GPUs but requires changes to GPU hardware; Secloak partitions the GPU into the Secure World at high performance cost. ShadowNet neither modifies nor partitions the GPU.
    • TensorSCONE [53], TF Trusted [27]: secure inference frameworks for cloud SGX; the authors state that TensorSCONE is evaluated only on Inceptionv4, has 3.1× time overhead and 330MB memory consumption, and targets the cloud rather than mobile devices; TF Trusted requires more TEE resources and does not support GPU acceleration.
    • YerbaBuena [42], SecureNets [37]: YerbaBuena splits the model into frontnets/backnets, placing the former in SGX to protect inputs; SecureNets matricizes inputs and linear-layer matrices and then performs matrix transformation and outsourcing; the authors state it is unclear whether it supports depthwise convolutions and convolutions with stride, whereas ShadowNet requires no matricization and is compatible with existing linear operations.

    Cryptography-based secure inference

    • CryptoNets [41], TF Encrypted [25], SafetyNets [40], etc.: secure inference based on HE or MPC. The authors state that ShadowNet's performance is several orders of magnitude better than such methods: classifying a single image with CryptoNets takes about 570 seconds on a PC, whereas ShadowNet takes less than 1 second on a smartphone.

    Black-box model extraction attacks (used for security evaluation)

    • Knockoff Nets [57]: the authors describe it as a SOTA black-box attack with an adaptive query strategy, selecting 10K queries from out-of-distribution data (CIFAR-100).
    • MixMatch [33], Jagielski et al. [47]: the authors cite survey [38] as stating that MixMatch is currently the method with the highest attack accuracy; it is based on semi-supervised learning and uses 8K labeled points plus 8K unlabeled points.
    • Tramèr et al. [71], Papernot et al. [59]: learning-based (shadow model) model extraction attacks, cited as background for the attack taxonomy.

    Baselines and benchmarks: the baseline for the security evaluation is a shadow model that knows nothing about the victim model (ResNet-18 for Knockoff, Wide-ResNet-28 for MixMatch), plus a random baseline with randomly initialized convolutional layers; the victim model is a four-layer fully connected CNN trained on CIFAR-10. The performance comparison target is the original (untransformed) model.

    Positioning: the authors use Table I to compare ShadowNet with the above work on four items—"model privacy, mobile TEE, performance, GPU access"—and state that ShadowNet is the only scheme satisfying all four.

  3. How does the paper address this problem?

    Quantize linear-layer weights, apply a linear transformation, and outsource to the untrusted world; add one-time masks to inputs and outputs; keep nonlinear layers and result recovery inside the TEE.

    Overall idea: ShadowNet exploits the observation that "linear layers account for the vast majority of CNN computation" by applying a linear transformation to linear-layer weights and outsourcing them to the Normal World (which can use GPU acceleration), then recovering the results inside the TEE; nonlinear layers, masking/unmasking, and transform recovery are all executed inside the TEE, and security is guaranteed by the TEE.

    Quantization and linear-layer transformation

    • Quantization: All inputs and weights are quantized to fixed-point numbers (x̃ = round(2^l · x)) and embedded into a finite field Zp (p large enough to avoid wraparound); this is a prerequisite for the formal security guarantee. After linear-layer computation, dequantization is performed by 2^(−l).
    • Standard/pointwise convolution layers: Let F be a random filter and Λ a random diagonal matrix; the transformation is ŴT = WT · Λ + F. By linearity, the original result can be recovered inside the TEE as Y = (Conv(X, Ŵ^T) − Conv(X, F)) · Λ^(−1), where Conv(X, F) is computed in the Normal World.
    • Depthwise convolution layers: Transform both the input and the convolution kernel—scale each channel by a random scalar λi and shuffle the channel order with a random permutation π; recover inside the TEE using the inverse permutation matrix.
    • Dense/fully connected layers: Treated as pointwise convolution, applying the standard convolution transformation.

    Input/output privacy (masking layers)

    • Mask: Offline-generate a random mask M with the same shape as the input, X′ = X + M; because values are embedded in a finite field, the authors state this is equivalent to a one-time pad. A new mask is used for each layer and each inference round.
    • Unmask: Recover inside the TEE as Y = Y′ − Conv(M, W); Conv(M, W) is precomputed offline and stored.
    • Boundary: Per the threat model, the model input (first-layer input) and model output (last-layer output) are known to the attacker, so the first layer masks only the output and the last layer masks only the input (Fig. 2).

    Optimized implementation and obfuscation ratio r

    • Obfuscation ratio r: Set m = ⌈r·n⌉, mix the n original kernels with m−n random "masking kernels," randomly permute them, and outsource; the permutation prevents the attacker from distinguishing which kernels correspond to the original weights. The authors state that r is analogous to a security parameter in cryptographic protocols: a larger r gives a larger feasible set and better security, at higher overhead.
    • Recovery implementation: The recovery process can be implemented as a pointwise convolution with n (1,1,m) filters; all transformation steps can be precomputed offline.

    System implementation

    • Architecture (Fig. 3): The model is split into Part A (transformed linear layers, running in TF Lite in the Normal World) and Part B (the remaining layers, running in the TA in the Secure World); the CA handles communication between the two.
    • Model conversion in two steps: Step I introduces four new layers—LinearTransform, ShuffleChannel, PushMask/PopMask—to replace each linear layer; Step II replaces all nonlinear layers between two linear layers with a placeholder layer TeeShadow, and branch structures (e.g., ResNet shortcuts) are handled with TeeMerge. The tool is fully automatic and based on TensorFlow 2.2.
    • TCB: The CA and TA add 480 and 2,100 lines of C code respectively, and the code for new operations added to the TCB is fewer than 200 lines; the authors state that TF Lite has tens of thousands of lines of code, and porting it entirely into the TEE would require a larger TCB.
    • Performance optimization: Cache the page mappings of the TA code/data segments (ResNet-44 inference reduced from 106ms to 57ms); static memory allocation inside the TA with double-buffer rotation; use Arm Neon to optimize sqrt, Batchnorm, AddMask, ReLU6, etc. (Table II: MobileNet TA execution time progressively optimized from 1500ms to 81ms); TEE secure memory adjusted from 16MB to 64MB, shared memory from 2MB to 8MB.

    Security goals and determination

    • Formal goal: Theorem 1 states that, given the Normal World view, the attacker cannot distinguish any two filters within the feasible set F(Ŵi), i.e., the feasible set serves as a "shadow region" for the original weights.
    • Conjecture on model stealing: Conjecture 1 conjectures that the number of queries q′ required to attack ShadowNet is of the same order as the number of queries q required for black-box model stealing (O(q)), i.e., the attacker cannot do better than standard learning-based black-box stealing; the authors provide empirical support using two black-box attacks (see Question 4).
  4. What experiments did the paper conduct?

    On Hikey960, measure correctness, efficiency, and the effect of the obfuscation ratio on five CNNs, and conduct a security empirical study using two black-box stealing attacks.

    Experimental setup

    • Models tested: Five CNNs—MobileNet, ResNet-44, ResNet-404, MiniVGG, and YOLOv4-tiny; the security empirical study additionally uses a four-layer fully connected CNN on CIFAR-10 as the victim model; the appendix gives an LSTM proof-of-concept.
    • Hardware and system: Hikey960 development board (Kirin 960 SoC, 4×Cortex A73 + 4×Cortex A53, ARM Mali G71 MP8 GPU, 3GB RAM), with Android P running in the Normal World and OP-TEE OS 3.9.0 running in the Secure World.
    • Parameters: Field Zp (p = 2^24 − 3), fixed-point representation l = 8, obfuscation ratio r = 1.2.
    • Datasets: MobileNet uses ImageNet-2012 (50K images); ResNet-44, ResNet-404, and MiniVGG use CIFAR-10 (10K images); YOLOv4-tiny uses the VOC2007 test set.
    • Metrics: Correctness uses Top-1/Top-5 accuracy, agreement with the original model's Top-1 prediction, and for YOLOv4-tiny mAP at 50% IoU; efficiency uses end-to-end model inference time for a single image (Fig. 7 reports the mean of 100 trials).
    • Security evaluation: Knockoff (10K CIFAR-100 queries, adaptively selected via reinforcement learning) and MixMatch (8K labeled + 8K unlabeled CIFAR-10 samples); the baseline shadow models are ResNet-18 and Wide-ResNet-28 respectively; the ShadowNet-adapted attack copies the victim model's transformed weights into an attack model of the same architecture and freezes the convolution layers, with an additional random baseline where convolution layers are randomly initialized.

    Main results

    Correctness (Fig. 6 and main text; the bar heights in Fig. 6 are not readable in the text, so the main-text numbers are used) and efficiency (main text, r = 1.2):

    Swipe horizontally to read the table

    ModelTop-1 agreementCPU overheadGPU inference time reduction
    MobileNet88%252ms (1.6×)15ms (4%)
    ResNet-4497%30ms (1.1×)5ms (9%)
    MiniVGG98%5ms (0.6×)1ms (8%)
    ResNet-40496%281ms (1.5×)8ms (2%)
    YOLOv4-tiny94%451ms (0.7×)30ms (3%)
    • The authors state that ShadowNet's accuracy is comparable to the original model: YOLOv4-tiny's mAP is 55.90% (original model 57.06%), with the roughly 1% drop attributed to quantization numerical error.
    • MobileNet's agreement is relatively low (88%): the authors explain this as 95% agreement on inputs the original model predicts correctly and 74% on inputs it predicts incorrectly, with quantization error mainly affecting inputs where the original model has low confidence (ImageNet has 1K classes).
    • The authors state that GPU acceleration benefits ShadowNet models less than the original model because the development board's GPU speedup (about 2×) is smaller than in the cloud, and alternating execution between the CPU (TEE) and GPU incurs extra overhead; the authors argue that ShadowNet's significance lies in opening the door to future on-device accelerators.

    Model size and offline overhead

    • Model size (Table III): Taking MobileNet as an example, the original model has 17MB of Conv weights and 0.175MB of others; the ShadowNet model has 20MB of Conv and 37MB of others (the AddMask layer weights occupy the largest space, and updating the 37MB of mask weights takes about 200ms; ResNet-44's mask is 3.3MB and updating takes about 18ms).
    • Offline time: Model conversion time ranges from 10min 59s for MiniVGG to 31min 23s for MobileNet; regenerating mask weights for 100 instances ranges from 2.19s for MiniVGG to 127.9s for ResNet-404.

    Effect of obfuscation ratio (Fig. 9, MobileNet)

    • As r varies from 1.0 to 2.0, Top-1 and Top-5 accuracy remain almost unchanged, on which basis the authors state that ShadowNet's accuracy does not depend on the obfuscation ratio.
    • Model size and inference time grow linearly with r (the authors state this is consistent with weights and computation growing linearly with r).
    • The authors state that choosing r = 1.2 is a "sweet spot": even with n = 16 and p = 2^24 − 3, the feasible set size already reaches the order of 2^268.

    Security empirical study (Table IV, CIFAR-10 victim model)

    • Knockoff: Victim model accuracy 81.6%; attack baseline 36.6%, ShadowNet-adapted attack 31.1%, random baseline 36.2%.
    • MixMatch: Victim model accuracy 98.1%; attack baseline 95.8%, ShadowNet-adapted attack 92.3%, random baseline 92.4%.
    • The authors state that attacks reusing the transformed weights do not outperform the baseline after the same number of queries, and are even worse than random initialization, which they take to indicate that the transformed weights contain no useful information about the original weights, supporting Conjecture 1. The authors also note that functionally-equivalent stealing is mathematically impossible under ShadowNet (masks are refreshed each round, Lemma 2), while learning-based black-box stealing itself is outside ShadowNet's protection scope.

    Other ablations and analysis

    • TA optimization (Table II, MobileNet): With six optimizations incrementally stacked, TA execution time drops from 1500ms to 81ms.
    • sqrt implementation (Appendix Table V): For 3,200,000 sqrt operations, Arm Neon takes 6.62ms, GNU libc 3.53ms, and the TA's original Newton software implementation 194.04ms; the Neon implementation was ultimately chosen.
    • Page mapping cache: ResNet-44 inference time drops from 106ms to 57ms (2×).
    • LSTM proof-of-concept (Fig. 10): Input (12,30), 1640 parameters, r = 1.2, 3640 parameters after conversion; inference time from 33ms to 41ms (1.24×).
    • Memory usage (Sec. VII): ShadowNet requires 4MB and 5MB of TEE memory for MiniVGG and ResNet-44 respectively, whereas running the unmodified models requires at least 44MB and 10MB respectively; MobileNet requires 48MB due to its depthwise/pointwise structure, which the authors state is still lower than the 61MB required to run the unmodified model inside the TEE.
  5. What are some points that can be further explored?

    The authors discuss the infeasibility of running the original model inside the TEE and extension directions such as LSTM/cloud/per-layer protection; the protection scope excludes learning-based stealing and side channels.

    Limitations and future directions noted by the authors

    • Reasoning integrity is out of scope (Sec. III-B): the paper does not consider model reasoning integrity, stating it can be achieved through the verification technique proposed by Slalom.
    • TEE side channels are out of scope (Sec. III-B): side-channel attacks against the TEE are not considered; the TEE is assumed to protect internal programs and data.
    • Only a conjecture is given for learning-based black-box extraction (Sec. VI-D): defending against such attacks is "beyond the scope of ShadowNet"; Conjecture 1 (q′ is O(q)) is only a conjecture, and the authors use empirical evidence from two attacks as support rather than proof.
    • GPU gains are limited by hardware (Sec. VI-B): the authors state that on-device GPU acceleration is still an evolving research direction, and ShadowNet's benefit is that it can take advantage of future advances in on-device accelerators.
    • Extension directions (Sec. VII): ShadowNet can be used for LSTM (a proof-of-concept is given); the CA/TA can be modified to support cloud TEEs (e.g., SGX), which the authors expect to use less memory than existing SGX schemes and to be able to use the GPU on the same machine; Layerwise ShadowNet can be applied only to sensitive layers to improve performance (based on transfer learning research showing that lower-level features are more sensitive).

    Experimental coverage

    • The models tested are five CNNs: MobileNet, ResNet-44, ResNet-404, MiniVGG, and YOLOv4-tiny; a four-layer CNN on CIFAR-10 additionally serves as the victim model for the security evaluation; LSTM is only a proof-of-concept (Sec. VI, Sec. VII).
    • All on-device experiments are conducted on a single Hikey960 development board (Kirin 960, Mali G71 MP8), with parameters fixed at p = 2^24 − 3, l = 8, r = 1.2 (Sec. VI).
    • Inference time is reported as the mean of 100 trials (Fig. 7 caption); correctness is evaluated using 50K ImageNet-2012 images, 10K CIFAR-10 images, and the VOC2007 test set.
    • The security evaluation covers only two black-box attacks, Knockoff and MixMatch, each with one victim model configuration; the paper does not report ShadowNet's performance under adaptive attacks designed specifically against its transformation structure.
    • The obfuscation ratio analysis is given only on MobileNet (Fig. 9); the paper does not report end-to-end results for values other than r = 1.2 on the remaining models.
  6. Summarize the main content of the paper

    ShadowNet uses a TEE to protect CNN weights and outsources the transformed linear layers to an untrusted accelerator, with overhead of 0.6×–1.6× on five CNNs.

    ShadowNet is an on-device CNN secure inference system that resolves the contradiction of "models deployed on untrusted devices are easily stolen, but protecting privacy loses GPU acceleration."

    • Problem: The authors cite prior research stating that 41% of mobile models are stored in plaintext and can be downloaded directly, and that encrypted storage may also be extracted by runtime attacks; HE/MPC schemes are too slow or require network connectivity, and existing TEE schemes are limited by memory, TCB, and accelerator access.
    • Method: Leveraging the observation that linear layers account for the vast majority of CNN computation (MobileNet accounts for about 95% of weights and 99% of inference time), the linear layer weights are quantized to a finite field and then linearly transformed (the obfuscation ratio r is adjustable) and outsourced to the Normal World/GPU, with inputs and outputs protected by one-time masks, while nonlinear layers and result recovery are all inside the TEE; implemented based on TensorFlow Lite and OP-TEE, the TA adds only 2,100 lines of C code, and a fully automated model conversion tool is provided.
    • Correctness: Accuracy on five CNNs is comparable to the original models, with YOLOv4-tiny mAP 55.90% (original model 57.06%); Top-1 consistency is MobileNet 88%, ResNet-44 97%, MiniVGG 98%, ResNet-404 96%, YOLOv4-tiny 94%.
    • Efficiency: In CPU mode, inference time increases by 0.6×–1.6× (r = 1.2); the GPU can reduce inference time by 1–30 ms, but the authors say the benefit is limited by the development board's GPU and the CPU/GPU alternation overhead.
    • Security: Theorem 1 provides a formal guarantee that an attacker cannot distinguish among filters within the feasible set; against the two black-box stealing attacks Knockoff and MixMatch, the attack accuracy when reusing transformed weights (31.1%, 92.3%) is no better than the random baseline (36.2%, 92.4%), which the authors use to support the conjecture that "an attacker cannot do better than standard black-box stealing."
    • Authors' conclusion: The authors state that ShadowNet has reasonable performance overhead under strong security guarantees, is a practical solution for on-device secure inference, and has been open-sourced; its optimizations such as page-mapping caching may have independent value to the OP-TEE community.

Related papers

Show 3 more papers
Read originalS&P 2023