ModelObfuscator: Obfuscating Model Information to Protect Deployed ML-based Systems

Mingyi Zhou, Xiang Gao, Jing Wu, John Grundy, Xiao Chen, Chunyang Chen, Li Li · DOI

TL;DR

On-device machine learning deployment (like TensorFlow Lite) protects user privacy but leaves model weights and architectures fully exposed to reverse engineering. To counter this, ModelObfuscator introduces a novel defense framework that obfuscates both the model file and its runtime library, effectively neutralizing white-box attacks and intellectual property theft with negligible impact on latency.

What Problem Does This Paper Address?

Deploying deep learning (DL) models directly on edge devices and mobile apps has become standard practice to minimize latency and protect user privacy. However, hosting models locally introduces a massive security flaw: anyone can unpack a mobile application package (APK/IPA) and extract the underlying model file (e.g., a .tflite file).

Once an attacker extracts the model, they gain full access to its internal structure and weights. This exposure enables highly effective "white-box" adversarial attacks, backdoor injections, and intellectual property theft. While existing defenses protect against cloud-based query attacks or side-channel analysis, they fail to safeguard local model files against direct software reverse engineering.

Figure 1: The typical scenarios of attacking on-device models. Our approach can disable the reverse engineering (i.e., RE).

Methods

The authors propose ModelObfuscator, an end-to-end tool that automatically obfuscates TFLite models and generates a customized, compatible runtime library.

Figure 2: The working process of our ModelObfuscator on-device DL model obfuscation tool. ‘a’: the process of producing TFLite model. ‘b’: the framework of the proposed ModelObfuscator.

Instead of relying solely on standard code obfuscation, ModelObfuscator applies five distinct model-level obfuscation strategies:

  1. Renaming: Standard layer names (e.g., Conv2D) are replaced with randomized, meaningless strings (e.g., Tozwyu). The corresponding library code is duplicated and renamed so the runtime treats these as custom layers.
  2. Parameter Encapsulation: To prevent attackers from extracting weights and biases, ModelObfuscator removes them from the model file entirely and embeds them directly into the customized C++ source code of the TFLite library, which can then be compiled and obfuscated using traditional binary protection tools.
  3. Neural Structure Obfuscation: The apparent shapes of tensors in the model file are randomized or aligned to the largest layer tensor, masking the true architecture of the network without altering actual execution.
  4. Shortcut Injection: Dummy connections (shortcuts) are added between random layers. These connections are visible to static analysis tools but are completely ignored by the modified runtime library during inference.
  5. Extra Layer Injection: Fake, computationally lightweight layers are inserted into the model graph to disrupt the spatial relationships of the network, further confusing reverse-engineering tools.
Figure 3: Example of five obfuscation strategies for the TFLite model obtained from a real-world fruit recognition app. (a) part of the original model. (b) the corresponding obfuscated model. ‘➀’: renaming. ‘➁’: parameter encapsulation. ‘➂’: neural structure obfuscation. ‘➃’: shortcut injection. ‘➄’: extra layer injection. This visualization is generated by Netron [35], which is a well-known visualization platform for neural networks.

Datasets

The framework was evaluated using 10 distinct TFLite models spanning various architectures and tasks:

  • Two real-world models extracted from Android applications: a fruit recognition model and a skin cancer diagnosis model.
  • Eight standard benchmark models from TensorFlow Hub: MobileNet, MNASNet, SqueezeNet, EfficientNet, MiDaS, LeNet, PoseNet, and SSD.

Key Insights and Ideas

  • The Hybrid Model-Library Approach: Traditional code obfuscation cannot protect a standalone model file because the file format itself dictates how data is read. By modifying both the model file and the underlying compilation library, ModelObfuscator shifts the critical intellectual property (the weights) from an open file format into a compiled binary.
  • Exploiting Custom Operators: TFLite naturally supports custom C++ operators. ModelObfuscator cleverly hijacks this feature to turn every standard layer into a unique "custom layer," breaking the automated parsing capabilities of standard reverse-engineering tools.
  • Structural Camouflage: By injecting fake shortcuts and dummy layers, the structural graph similarity between the obfuscated model and the original model drops significantly. This prevents attackers from using graph-matching techniques to find differentiable surrogate models on the internet.

Key Results

  • Attack Resilience: ModelObfuscator successfully thwarted all tested model format conversion tools (TF-ONNX, TFLite2ONNX, TFLite2TF) and buffer-parsing tools. It completely blocked white-box gradient attacks (FGSM, BIM, PGD) because the models could no longer be converted into a differentiable format like PyTorch.
  • Zero Accuracy Loss: The obfuscation process preserves the exact mathematical output of the original model, resulting in an obfuscation error of absolute zero.
  • Negligible Latency Overhead: Across all 10 models, the runtime latency increase was roughly 1% on average, making it perfectly viable for real-time edge applications.
  • Acceptable Memory & Storage Trade-offs: The memory (RAM) overhead increased by an acceptable ~20%. While the .tflite model file size shrank dramatically (as weights were removed), the compiled TFLite library size increased (ranging from +3.2 MB to +59.8 MB) due to the addition of custom layer APIs.

Limitations and Future Work

The primary limitation of ModelObfuscator is the increase in the compiled library size, which directly impacts the final mobile application package size. For massive networks with thousands of unique layers, renaming and encapsulating every single layer could cause the library binary to swell significantly.

Additionally, while the approach completely neutralizes white-box reverse engineering, it does not defend against black-box query-based attacks (where an attacker probes the model via inputs/outputs). The authors note that future work will focus on optimizing the obfuscation strategies to minimize the footprint on the recompiled library size.

Summary updated

BibTeX
@inproceedings{zhou2023modelobfuscator,
  author = {Mingyi Zhou and Xiang Gao and Jing Wu and John Grundy and Xiao Chen and Chunyang Chen and Li Li},
  title = {{ModelObfuscator: Obfuscating Model Information to Protect Deployed ML-based Systems}},
  booktitle = {In Proceedings of the 32nd ACM SIGSOFT International Symposium on Software Testing and Analysis (ISSTA'23)},
  year = {2023},
  url = {https://openreview.net/forum?id=RBNDq3OvUZ},
}
Figure