Python AI and ML Framework Vulnerabilities
Recurring vulnerability patterns in the Python AI stack (notebooks, agent frameworks, model loaders, inference and MLOps servers). Here model files, metadata and LLM output are effectively code, and services often ship unauthenticated.
How it works
The AI stack keeps reintroducing classic Python sinks through new inputs:
- Model artifacts as code: pickle-based checkpoints, and config or metadata that names callables (Hydra
_target_) or carries templates (GGUFchat_template). - LLM output as code or data structure: generated Python that gets
exec’d, and generated dicts deserialized as trusted framework objects. - Fetch-anything features: webhooks, URL inputs and RAG loaders become SSRF sinks.
- Dev-tool defaults in production: unauthenticated WebSockets and actor ports, and Starlette-based servers exposed without a strict proxy.
Patterns and cases
| Pattern | Case | Detail |
|---|---|---|
| Missing auth on a privileged endpoint | Marimo CVE-2026-39987 (CVSS 9.3, CISA KEV) | /terminal/ws skipped validate_auth(), unlike /ws, giving a pre-auth PTY shell. Exploited within 10 hours of disclosure (credential harvesting, NKAbuse). Affects ≤ 0.20.4; fixed in 0.23.0 |
| Authz on reconstructed path | Starlette BadHost CVE-2026-48710 | Host: x? desyncs request.url.path from the routed path. Hits FastAPI, vLLM, LiteLLM and MCP servers. See Python Web Framework Security |
| Config names a callable | NeMo CVE-2025-23304, Uni2TS CVE-2026-22584, FlexTok | hydra.utils.instantiate() calls any callable in _target_ from model metadata, even alongside safetensors weights |
| Template in model file | SGLang CVE-2026-5760 (9.8) | Jinja2 SSTI via GGUF tokenizer.chat_template on /v1/rerank. Same pattern as llama-cpp-python CVE-2024-34359. See Jinja2 SSTI |
| Template in data reference | fsspec CVE-2026-104851 | Un-sandboxed Jinja2 in ReferenceFileSystem references JSON (xarray.open_dataset("reference://...")) |
| Template in a packaged artifact | BentoML GHSA-v959-cwq9-7hr6 | bentoml containerize rendered the imported archive’s Dockerfile.template in an unsandboxed Jinja2 Environment with jinja2.ext.do/debug, running code on the host before Docker. Fix: SandboxedEnvironment GHSA |
| LLM output executed | Langflow CVE-2026-33873 | The Agentic Assistant exec’d generated code during validation (fixed in 1.9.0) |
| LLM output deserialized | LangChain Core CVE-2025-68664 (9.3) | dumps()/dumpd() didn’t escape user dicts containing the internal "lc" key, so they were revived as trusted objects, leading to secret extraction. The JS equivalent is CVE-2025-68665 |
| Format-string templates | Arize Phoenix (CVE-2026-53998; 13.0.0 up to but not including 15.7.0) | str.format attribute traversal in applyChatTemplate leaked PHOENIX_SECRET, leading to JWT forgery. See Unsafe Python Functions |
| Sandbox fallback | CrewAI CVE-2026-2275/2287 | The Code Interpreter falls back to in-process SandboxPython when Docker is unavailable. See Python Sandbox Escapes |
| Full-read SSRF | MLflow CVE-2026-64849 (9.3, KEV) | Webhook delivery 3.3.0–3.15.0 is unauthenticated and follows redirects, and is exposed to DNS rebinding |
| SSRF via typed inputs | Replicate Cog ≤ 0.23.1 | cog.File/cog.Path prediction inputs fetch attacker URLs and follow redirects |
| SSRF in RAG tools | CrewAI CVE-2026-2286 | RAG search tools don’t validate runtime URLs. The JSON loader (CVE-2026-2285) reads arbitrary files |
| Unauthenticated deserialization port | Xoscar ≤ 0.11.2 | Actor-pool messages deserialized before auth. Fixed in 0.12.0 with a shared XOSCAR_AUTH_KEY |
| Pickle checkpoints and scanners | MLflow, Ultralytics, Qlib, Detectron2, fairseq, Megatron-LM (ZDI-26-8xx/9xx); Qiskit QPY CVE-2026-116499; picklescan CVE-2025-1716 (pip.main not on the denylist); Fickling CVE-2026-22607 | Covered in Python Pickle Deserialization |
| File write → interpreter startup hook | Open-source medical-imaging AI app (zero-day, Sept 2026) | Path traversal in an upload filename let Cairn agents write sitecustomize.py, which Python imports at startup; calling a training endpoint spawned a new interpreter that ran it as root. Any arbitrary write into site-packages plus a “spawn a worker” endpoint is RCE Help Net Security |
| Startup hook in an SDK release | Microsoft agent-framework 1.26.1/1.26.2 (PYSEC-2026-4388) | .pth stealer on every interpreter start; targets Azure, CI and AI-provider credentials near agent code; Elastic flagged it six minutes after publish Elastic VeritasChain |
Defenses
- Authenticate every endpoint, including WebSockets and inter-process ports. Don’t expose notebook, MLOps or inference servers directly.
- Load weights only (safetensors,
torch.load(weights_only=True)). Allowlist_target_modules and render model-supplied templates withImmutableSandboxedEnvironment. - Never
execLLM output in-process, and treat LLM-produced structures as untrusted input to any (de)serializer. - For LLM apps, decide in code which tools an intent may use, validate every model-produced argument with pydantic, hold destructive calls for approval, and check output before rendering. See Prompt Injection six layers.
- SSRF guards must pin the resolved IP and re-check on every redirect hop. See SSRF Prevention and DNS Rebinding.
- Don’t rely on pickle scanners (picklescan, Fickling) as a security boundary. Both have had denylist and classification bypasses.
Related
- Python Security
- Unsafe Python Functions
- Python Sandbox Escapes
- Python Web Framework Security
- Python Pickle Deserialization
- AI and LLM Security
- MCP Security
- Agentic AI Risks
- Prompt Injection
- Webhook SSRF
- Malicious Packages
Sources
- Marimo RCE Flaw CVE-2026-39987 Exploited Within 10 Hours · original
- Critical flaw in Marimo Python notebook exploited · original
- BadHost: one character and your AI agent switches sides · original
- RCE With Modern AI/ML Formats and Python Libraries · original
- SGLang CVE-2026-5760 RCE via malicious GGUF · original
- fsspec ReferenceFileSystem SSTI leads to RCE · original
- CVE-2026-33873: Langflow Agentic Assistant RCE · original
- CVE-2025-68664: LangChain secret extraction · original
- Arize Phoenix: format string injection · original
- CrewAI contains multiple vulnerabilities · original
- MLflow unauthenticated full-read SSRF in webhook delivery · original
- Replicate Cog through 0.23.1 SSRF · original
- Xoscar unauthenticated RCE through actor message deserialization · original
- CVE-2025-1716 picklescan bypass · original
- CVE-2026-22607: Fickling · original
- Qiskit SDK QPY deserialization · original
- Arize Phoenix CVE-2026-53998 GraphQL format-string secrets leak · original
- BentoML GHSA-v959-cwq9-7hr6: SSTI via unsandboxed Jinja2 · original
- The Credential Was Valid. The Publisher Was Not. (agent-framework) · original
- How to Prevent Prompt Injection in Python LLM Apps: 6 Layers · original
- Open-source AI pentesting framework Cairn keeps turning up in real-world attacks · original
- Elastic — We caught the agent-framework PyPI compromise six minutes after it published · original