MLCapsule: Guarded Offline Deployment of Machine Learning as a Service

Lucjan Hanzlik, Yang Zhang, Kathrin Grosse, Ahmed Salem, Max Augustin, Michael Backes, Mario FritzOpenReview 2018 · DOI · OpenReview

Abstract

Machine Learning as a Service (MLaaS) is a popular and convenient way to access a trained machine learning (ML) model through an API. However, if the user’s input is sensitive, sending it to the server is not an option. Equally, the service provider does not want to share the model by sending it to the client for protecting its intellectual property and pay-per-query business model. As a solution, we propose MLCapsule, a guarded offline deployment of MLaaS. MLCapsule executes the machine learning model locally on the user’s client and therefore the data never leaves the client. Meanwhile, we show that MLCapsule is able to offer the service provider the same level of control and security of its model as the commonly used server-side execution. Beyond protecting against direct model access, we demonstrate that MLCapsule allows for implementing defenses against advanced attacks on machine learning models such as model stealing, reverse engineering and membership inference.

Introduction

Traditional MLaaS platforms, such as Google Cloud AI or AWS SageMaker, present a fundamental conflict between user privacy and provider intellectual property (IP). Users often handle sensitive data that cannot be legally or ethically transmitted to a third-party server. Conversely, service providers cannot simply distribute model weights to clients without risking IP theft or losing the ability to monetize via pay-per-query models.

MLCapsule addresses this by providing a secure, local "black-box" execution environment. The paper introduces a formal security definition for "ML model secrecy," arguing that a local MLCapsule deployment should be indistinguishable from a remote server-side API from the user's perspective.

Methodology

MLCapsule leverages Isolated Execution Environments (IEEs), specifically Intel SGX, to create a secure enclave on the client's machine. This enclave is a protected memory region inaccessible even to the device owner. The deployment process consists of two primary phases:

1. Setup Phase

The client initializes the enclave and performs remote attestation to prove to the provider that the enclave is running untampered MLCapsule code. Upon verification, the provider transmits encrypted model weights directly into the enclave.

The setup phase involves initializing the service app, requesting the model from the provider, and storing it securely on the local machine.

2. Inference Phase

During operation, the client application passes input data to the enclave. The enclave decrypts the model in memory, performs the inference, and returns only the final classification result.

The inference phase handles local model loading, user input processing, and result return, all while maintaining a query counter for monetization.

Guarded Execution and Active Defenses

A key advantage of MLCapsule is the ability to embed active defenses within the enclave. Unlike standard local deployments, the provider can include logic to detect and mitigate attacks. For example, the system can monitor for "model stealing" patterns and refuse service if an attack is suspected. Additionally, to counter Membership Inference Attacks, the authors implement an entropy-based noise injection method. By adding noise to high-confidence output probabilities, the system makes it significantly harder for an adversary to determine if a specific data point was part of the training set.

Experimental Evaluation

The system was evaluated using standard benchmarks including MNIST, CIFAR-100, and GTSRB, as well as large architectures like VGG-16 and MobileNet.

  • Performance: While SGX introduces overhead, the results remain practical. VGG-16 experienced a 1.55x slowdown, and MobileNet a 2.16x slowdown compared to native execution. To handle large models exceeding the 128MB Enclave Page Cache (EPC), a 2MB chunking strategy was successfully implemented.
  • Security: The system achieved 100% accuracy in detecting reverse-engineering attempts. The entropy-based defense successfully reduced the AUC of membership inference attacks from 0.97 to approximately 0.5 (random guessing) with minimal utility loss.

Conclusion

MLCapsule demonstrates that local MLaaS deployment can be both private and secure. While challenges remain regarding side-channel vulnerabilities and the current lack of hardware-accelerated TEEs (Secure GPUs), MLCapsule provides a robust framework for privacy-preserving machine learning in sensitive domains.

Summary updated

Abstract

With the widespread use of machine learning (ML) techniques, ML as a service has become increasingly popular. In this setting, an ML model resides on a server and users can query it with their data via an API. However, if the user's input is sensitive, sending it to the server is undesirable and sometimes even legally not possible. Equally, the service provider does not want to share the model by sending it to the client for protecting its intellectual property and pay-per-query business model. In this paper, we propose MLCapsule, a guarded offline deployment of machine learning as a service. MLCapsule executes the model locally on the user's side and therefore the data never leaves the client. Meanwhile, MLCapsule offers the service provider the same level of control and security of its model as the commonly used server-side execution. In addition, MLCapsule is applicable to offline applications that require local execution. Beyond protecting against direct model access, we couple the secure offline deployment with defenses against advanced attacks on machine learning models such as model stealing, reverse engineering, and membership inference.
BibTeX
@misc{hanzlik2018mlcapsule,
  author = {Lucjan Hanzlik and Yang Zhang and Kathrin Grosse and Ahmed Salem and Max Augustin and Michael Backes and Mario Fritz},
  title = {{MLCapsule: Guarded Offline Deployment of Machine Learning as a Service}},
  year = {2018},
  eprint = {1808.00590},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1808.00590},
  howpublished = {OpenReview},
}
Figure