Understanding Model Threats
This resource is designed to provide detailed information on various threat categories, helping you understand and mitigate potential risks in AI and machine learning systems.
Deserialization Threats
Deserialization threats occur when untrusted data or code is used to reconstruct objects, leading to potential exploitation. In AI and machine learning systems, this can result in malicious actors injecting harmful code during the deserialization process, exploiting vulnerabilities to gain unauthorized access or manipulate your systems behavior. Understanding deserialization threats is crucial for securing data integrity and preventing unauthorized code execution in your AI models.
Overview
NVIDIA TensorRT optimizes trained models for fast inference on NVIDIA GPUs. A TensorRT engine file (often .engine or .plan) is a serialized, hardware-specific build of a model that the TensorRT runtime loads directly.
TensorRT can be extended with plugins: custom layers implemented as native code, typically C++ and CUDA, for operations TensorRT does not support natively. An engine file records the name of each plugin it uses, but it does not contain the plugin's code. When the engine is deserialized, TensorRT looks up each plugin by name in the plugin libraries loaded into the process and runs that native code. Native plugin code runs with the full permissions of the loading process, outside any Python-level protections.
The scan reads the plugin names referenced in the engine file and compares them with a list of known plugins.
If a model reportedly has this issue, it means:
- The model is a TensorRT engine file.
- The engine references a plugin that is not on the list of known plugins.
Key Points
- TensorRT engines can use plugins, which are custom layers implemented in native code.
- Plugin code runs when the engine is deserialized and used for inference, with the full permissions of the process.
- The engine file references plugins by name; the code itself is supplied separately, for example as a shared library distributed alongside the model.
- An unknown plugin means the model requires native code that the scan could not identify.
- Only load models and plugin libraries from trusted sources.
Background Information
Further reading:
Impact
To use this engine, you will need to load the plugin library that implements the unknown plugin. An attacker who distributes a model together with a malicious plugin library could:
- Execute arbitrary native code on your system with the permissions of the inference process
- Access sensitive information (e.g., SSH keys, cloud credentials, data passed to the model)
- Use the compromised system as a vector for broader attacks
Note: Malicious plugin code can run alongside the plugin's legitimate computation, so the model can keep producing correct results while the attack happens.
How The Attack Works
Best Practices
You should:
- Only load and execute models from trusted sources
- Only load TensorRT plugin libraries that you have built or vetted yourself
- Implement a vetting process for third-party models before use
- Use sandboxing techniques when loading untrusted models
- Where possible, build TensorRT engines yourself from a vetted model in a safe format such as ONNX or SafeTensors, rather than using prebuilt engines
Remediation
Identify the plugin named in the scan result and confirm where its implementation comes from. Only use the engine if the plugin's source code is available and you have reviewed it, or the plugin comes from a vendor you trust.
If possible, build the TensorRT engine yourself from the original model, so that you control which plugins it uses.
If not possible, reach out to the model creator and alert them that the model has failed our scan. You can even link to the specific page on our Insights Database to provide our most up to date findings.
The model provider should also report what they did to correct this issue as part of their release notes.