Upload README.md with huggingface_hub
Browse files
README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# TensorRT ACE PoC — Arbitrary Code Execution via Embedded Plugin DLL
|
| 2 |
+
|
| 3 |
+
## Vulnerability Summary
|
| 4 |
+
|
| 5 |
+
TensorRT `.engine` files support embedding plugin shared libraries via `plugins_to_serialize`. When such an engine is deserialized with `deserialize_cuda_engine()`, TensorRT **unconditionally** extracts the embedded DLL to a temp file and loads it via `LoadLibrary()` / `dlopen()`. This triggers native code execution (e.g., `DllMain` on Windows, `__attribute__((constructor))` on Linux).
|
| 6 |
+
|
| 7 |
+
**The `engine_host_code_allowed` security flag (which defaults to `False`) does NOT prevent this.** The flag only gates lean runtime loading, not embedded plugin libraries.
|
| 8 |
+
|
| 9 |
+
## Affected
|
| 10 |
+
|
| 11 |
+
- **Product:** NVIDIA TensorRT
|
| 12 |
+
- **Tested Version:** 10.15.1.29
|
| 13 |
+
- **File Format:** `.engine` / `.trt` / `.plan`
|
| 14 |
+
- **API:** `IRuntime::deserializeCudaEngine()` / `trt.Runtime.deserialize_cuda_engine()`
|
| 15 |
+
|
| 16 |
+
## Files
|
| 17 |
+
|
| 18 |
+
| File | Description |
|
| 19 |
+
|------|-------------|
|
| 20 |
+
| `malicious_model.engine` | Pre-built malicious engine file containing embedded DLL |
|
| 21 |
+
| `malicious_plugin.cpp` | Source code for the malicious plugin DLL |
|
| 22 |
+
| `malicious_plugin.dll` | Compiled malicious plugin (Windows x64) |
|
| 23 |
+
| `build_malicious_engine.py` | Script to build the malicious engine from scratch |
|
| 24 |
+
| `load_malicious_engine.py` | Script to demonstrate ACE by loading the engine |
|
| 25 |
+
|
| 26 |
+
## Reproduction Steps
|
| 27 |
+
|
| 28 |
+
### Quick Test (use pre-built engine)
|
| 29 |
+
|
| 30 |
+
```bash
|
| 31 |
+
# Requires: pip install tensorrt (tested with 10.15.1.29)
|
| 32 |
+
python load_malicious_engine.py
|
| 33 |
+
# Check for PWNED.txt — if it exists, ACE was achieved
|
| 34 |
+
```
|
| 35 |
+
|
| 36 |
+
### Build From Scratch
|
| 37 |
+
|
| 38 |
+
1. Compile the malicious plugin DLL (Windows/MSVC):
|
| 39 |
+
```
|
| 40 |
+
cl /nologo /EHsc /LD /Fe:malicious_plugin.dll malicious_plugin.cpp /link user32.lib kernel32.lib
|
| 41 |
+
```
|
| 42 |
+
|
| 43 |
+
2. Build the malicious engine:
|
| 44 |
+
```
|
| 45 |
+
python build_malicious_engine.py
|
| 46 |
+
```
|
| 47 |
+
|
| 48 |
+
3. Test ACE:
|
| 49 |
+
```
|
| 50 |
+
python load_malicious_engine.py
|
| 51 |
+
```
|
| 52 |
+
|
| 53 |
+
## What Happens
|
| 54 |
+
|
| 55 |
+
1. `load_malicious_engine.py` creates a TensorRT runtime with `engine_host_code_allowed = False` (default)
|
| 56 |
+
2. It calls `runtime.deserialize_cuda_engine(engine_data)`
|
| 57 |
+
3. TensorRT extracts the embedded DLL to `%TEMP%\pluginLibrary_*.dll`
|
| 58 |
+
4. TensorRT calls `LoadLibrary()` on the extracted DLL
|
| 59 |
+
5. `DllMain` executes, creating `PWNED.txt` as proof of arbitrary code execution
|
| 60 |
+
6. Deserialization itself fails (no valid plugin creators), but **the code already ran**
|
| 61 |
+
|
| 62 |
+
## Key Evidence from TensorRT Logs
|
| 63 |
+
|
| 64 |
+
```
|
| 65 |
+
[TRT] [V] Local registry attempting to deserialize library from memory
|
| 66 |
+
[TRT] [V] Created temporary shared library C:\Users\...\Temp\pluginLibrary_4cef6c0cb351aa4e.dll
|
| 67 |
+
[TRT] [V] Loaded temporary shared library C:\Users\...\Temp\pluginLibrary_4cef6c0cb351aa4e.dll
|
| 68 |
+
```
|
| 69 |
+
|
| 70 |
+
This occurs even with `engine_host_code_allowed = False`.
|
| 71 |
+
|
| 72 |
+
## Impact
|
| 73 |
+
|
| 74 |
+
- Arbitrary native code execution in any process that loads an untrusted `.engine` file
|
| 75 |
+
- No existing scanner (ModelScan, etc.) detects this
|
| 76 |
+
- Supply chain attack via malicious models on HuggingFace, model registries, etc.
|