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 (GGUF chat_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

PatternCaseDetail
Missing auth on a privileged endpointMarimo 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 pathStarlette BadHost CVE-2026-48710Host: x? desyncs request.url.path from the routed path. Hits FastAPI, vLLM, LiteLLM and MCP servers. See Python Web Framework Security
Config names a callableNeMo CVE-2025-23304, Uni2TS CVE-2026-22584, FlexTokhydra.utils.instantiate() calls any callable in _target_ from model metadata, even alongside safetensors weights
Template in model fileSGLang 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 referencefsspec CVE-2026-104851Un-sandboxed Jinja2 in ReferenceFileSystem references JSON (xarray.open_dataset("reference://..."))
Template in a packaged artifactBentoML GHSA-v959-cwq9-7hr6bentoml 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 executedLangflow CVE-2026-33873The Agentic Assistant exec’d generated code during validation (fixed in 1.9.0)
LLM output deserializedLangChain 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 templatesArize 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 fallbackCrewAI CVE-2026-2275/2287The Code Interpreter falls back to in-process SandboxPython when Docker is unavailable. See Python Sandbox Escapes
Full-read SSRFMLflow 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 inputsReplicate Cog ≤ 0.23.1cog.File/cog.Path prediction inputs fetch attacker URLs and follow redirects
SSRF in RAG toolsCrewAI CVE-2026-2286RAG search tools don’t validate runtime URLs. The JSON loader (CVE-2026-2285) reads arbitrary files
Unauthenticated deserialization portXoscar ≤ 0.11.2Actor-pool messages deserialized before auth. Fixed in 0.12.0 with a shared XOSCAR_AUTH_KEY
Pickle checkpoints and scannersMLflow, 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-22607Covered in Python Pickle Deserialization
File write → interpreter startup hookOpen-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 releaseMicrosoft 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 with ImmutableSandboxedEnvironment.
  • Never exec LLM 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.

Sources