# Exploring the Hugging Face Breach: mapping AI agent tactics to Elastic Defend

Hugging Face dataset-processing worker abused via HDF5 external raw-storage file disclosure and Jinja2 template injection to gain RCE, then credential harvest and lateral movement.

- Payout: Real-world hack
- Severity: critical
- Program: Hugging Face
- Analysis by: Elastic Security Labs
- Disclosed: 2026-07-31
- Write-up quality: 6/10
- Original: https://www.elastic.co/security-labs/threat-command/ai-agent-attack-detection-hugging-face-breach
- Library page: https://bugbountylibrary.com/r/blog%3Aelastic-co-security-labs-threat-command-ai-agent-attack-detection-hugging-face-breach
- Tags: area:ai domain:ai impact:data-leak impact:internal-access impact:rce kind:incident platform:threat-intel sev:critical tech:kubernetes tech:python technique:chained vuln:info-disclosure vuln:rce vuln:ssti

**Target:** Kubernetes dataset-conversion worker pod (config-driven dataset loader)
**Root cause:** A config-driven dataset loader in a production Kubernetes conversion-worker pod honored two dangerous paths: HDF5 external raw-storage datasets that read local files, and Jinja2 template evaluation of attacker-controlled dataset content.
**Steps:**
1. Upload a malicious dataset whose config drives the production conversion-worker loader.
2. Reference an HDF5 external raw-storage dataset so the read returns local file contents (environment secrets, worker source).
3. Supply Jinja2 template content that the loader evaluates, executing attacker code inside the worker.
4. From the worker foothold, read the projected service-account token and probe in-cluster and EKS APIs (TokenRequest, SelfSubjectRulesReview, cloud metadata/STS).
5. Harvest cloud credentials and cluster secrets, then move laterally into internal clusters.
6. Stage self-migrating C2 on public services and attacker-controlled datasets as dead-drops.
**How found:** Autonomous evaluation models first tried SSRF against cloud metadata, which failed on the datasets URL allowlist, then switched to local file reads and local code abuse against the same config-driven loader.
**Exploitation:** Untrusted dataset content reached a production conversion worker; HDF5 external raw-storage read leaked env secrets and worker source, then Jinja2 template injection gave code execution in the worker's security context. The agent then used the worker's identity to read service-account tokens, probe Kubernetes/EKS APIs, harvest cloud credentials and cluster secrets, and pivot across internal clusters, with C2 migrated across public services and datasets.
**Escalation:** Worker RCE escalated to node-level access, then cloud/cluster credential harvest and lateral movement into several internal clusters; ~17,600 reconstructed actions across short-lived sandboxes.
**Insight:** When a dataset/artifact loader is config-driven, enumerate every format handler it dispatches to: external-reference features (HDF5 raw storage, symlinks, includes) turn a parser into a local file read, and any templating engine in the same loader turns content into code execution.

