# Hugging Face works with Wiz to strengthen AI cloud security

Malicious pickle model uploaded to Hugging Face Inference API achieved RCE, then IMDS abuse escalated to EKS node role and cross-tenant access.

- Payout: unconfirmed
- Severity: critical
- Program: Hugging Face
- Found by: Shir Tamari, Sagi Tzadik
- Disclosed: 2024-04-04
- Write-up quality: 8/10
- Original: https://www.wiz.io/blog/wiz-and-hugging-face-address-risks-to-ai-infrastructure
- Library page: https://bugbountylibrary.com/r/blog%3Awiz-io-blog-wiz-and-hugging-face-address-risks-to-ai-infrastructure
- Tags: area:ai domain:ai domain:cloud impact:integrity impact:internal-access kind:bounty platform:blog sev:critical tech:aws tech:docker tech:kubernetes technique:chained vuln:deserialization vuln:rce

**Target:** Hugging Face Inference API, Inference Endpoints, Spaces, internal container registry
**Root cause:** Inference API deserializes untrusted pickle models without adequate sandboxing, and pods can reach node IMDS to obtain the EKS node IAM role; Spaces build network reaches an unscoped internal container registry.
**Steps:**
1. Clone legitimate gpt2 model with config.json
2. Modify pickle to execute reverse shell on load, upload as private model
3. Trigger inference via Inference API to get reverse shell in pod
4. Query `169.254.169.254` IMDS to obtain node IAM role credentials
5. Use `aws eks get-token` with role; discover cluster name via `DescribeInstances` tags
6. Use node token with kubectl to list pods and `kubectl get secrets` for lateral movement
7. For Spaces: submit Dockerfile with malicious `RUN` instruction to execute during build
8. From build, `netstat` reveals internal container registry; pull/push all images due to insufficient scoping
**How found:** Team focused on isolation in AI-as-a-service; reasoned that models are code and asked whether uploaded models run sandboxed and multi-tenant. Tested by uploading a malicious pickle and observing execution, then applied their EKS misconfiguration playbook (IMDS reachability, get-token, DescribeInstances) and inspected netstat during Spaces build.
**Exploitation:** Attacker uploads a crafted pickle model to the public hub and invokes it via Inference API, gaining code execution in a shared pod. From there, IMDS yields the node role, `aws eks get-token` produces a Kubernetes token, and secrets are read for lateral movement. Separately, a malicious Spaces Dockerfile executes during build and reaches an internal registry with write access to all customer images, enabling supply chain overwrite.
**Escalation:** Pickle RCE -> IMDS node role -> EKS cluster token -> secrets/lateral movement; Spaces build RCE -> unscoped registry write -> supply chain attack on other tenants.
**Insight:** Treat model uploads as code execution: test whether inference pods can reach 169.254.169.254 and whether the node role can mint EKS tokens; also run netstat during CI/build steps to find internal registries reachable from untrusted build containers.

