攻擊 AI 部署
進階3 分鐘閱讀更新於 2026-03-12
AI 部署基礎設施的安全評估,包括容器逃逸、GPU 側通道、推論伺服器漏洞以及資源耗盡攻擊。
AI 部署建立在專用基礎設施上——GPU 叢集、推論伺服器、容器編排——這些都帶來超出模型本身的攻擊面。基礎設施層級被入侵,可能讓攻擊者取得模型權重、使用者資料,甚至更廣的網路。
AI 部署架構
典型生產 LLM 部署:
Load Balancer → API Gateway → Inference Server (vLLM, TGI, Triton)
↓
GPU Cluster (CUDA runtime)
↓
Model Weights (shared storage)
↓
Vector DB / Cache
每個元件都有自己的攻擊面。
推論伺服器漏洞
常見推論伺服器(vLLM、Text Generation Inference、Triton)對外暴露管理介面與處理端點:
# Common inference server endpoints to probe
endpoints = [
"/health", # Health check - may reveal version info
"/metrics", # Prometheus metrics - resource usage, model info
"/v1/models", # Model listing - reveals loaded models
"/v1/completions", # Inference endpoint
"/admin", # Management interface (if exposed)
"/docs", # Auto-generated API docs
]
# Test for unauthenticated access to management endpoints
for endpoint in endpoints:
response = requests.get(f"http://target:8000{endpoint}")
print(f"{endpoint}: {response.status_code}")已知攻擊模式
| 伺服器 | 漏洞類別 | 影響 |
|---|---|---|
| vLLM | 未認證 API | 模型存取、推論濫用 |
| Triton | 模型倉儲遍歷 | 存取其他模型與權重 |
| TGI | 資源耗盡 | 服務阻斷 |
| Ollama | 預設開啟的埠 (11434) | 完整本地模型存取 |
GPU 與記憶體攻擊
GPU 記憶體洩漏
GPU 記憶體不會在請求間自動清除。在 多租戶 環境中,後續請求可能讀到前一位使用者推論的殘留資料:
# Conceptual GPU memory probe
# In a shared GPU environment, allocate memory and read uninitialized values
import torch
# Allocate a large tensor without initialization
probe = torch.empty(1024, 1024, device='cuda')
# probe may contain residual data from previous operations
# including other users' embeddings, activations, or KV cache模型權重萃取
攻擊者若取得部署基礎設施,即可直接複製模型權重:
# Common locations for model weights in containerized deployments
# /models/
# /opt/ml/model/
# /root/.cache/huggingface/
# /data/models/容器安全
AI 工作負載常在高權限容器中執行,以便存取 GPU:
# Common insecure container configuration for GPU workloads
services:
inference:
image: vllm/vllm-openai
# Privileged mode for GPU access - common but dangerous
privileged: true
# Host network - exposes internal ports
network_mode: host
# Volume mounts - may expose sensitive host paths
volumes:
- /data/models:/models
- /var/run/docker.sock:/var/run/docker.sockAI 工作負載特有的容器逃逸路徑:
- 特權模式——常為了 NVIDIA GPU 存取啟用,等同授予完整主機能力
- Docker socket 掛載——有時為容器編排而用,可完全控制 Docker
- 主機 PID 命名空間——為 GPU 驅動相容而共用,可見其他程序
- 可寫的模型目錄——若可寫,攻擊者可替換模型權重
資源耗盡
AI 推論耗資源高,是阻斷服務的絕佳目標:
# GPU memory exhaustion
# Send requests that maximize GPU memory usage
# Long input + long output + large batch size
# Compute exhaustion
# Requests that maximize inference time
# Adversarial inputs that cause maximum attention computation
# Storage exhaustion
# If the system logs prompts/responses, generate volume
# If the system caches KV states, fill the cache相關主題
- AI 基礎設施安全總覽 -- 更廣的基礎設施攻擊面脈絡
- LLM API 安全 -- 座落於推論伺服器前方的 API 層
- 模型供應鏈風險 -- 在部署前入侵模型
- 基礎設施漏洞利用 -- 進階基礎設施攻擊技巧
- 整合:執行與報告 -- 把基礎設施發現納入委託案報告
參考資料
- NVIDIA, "Container Security for GPU Workloads" (2024) -- GPU 容器安全指引
- Tramèr et al., "Stealing Machine Learning Models via Prediction APIs" (2016) -- 透過推論端點的模型萃取
- MITRE, "ATLAS: Adversarial Threat Landscape for AI Systems" (2023) -- AI 威脅分類中的基礎設施層威脅
Knowledge Check
為什麼 AI 容器常被部署為高權限?