Summary
vLLM's model resolution process loads Hugging Face auto_map dynamic modules without properly enforcing the trust_remote_code gate, enabling execution of attacker-controlled Python code bundled with a model repository or local path.
If an attacker can influence which model repo or directory vLLM loads, they can run arbitrary code on the vLLM host during server startup, before any API requests are processed.
Affected context
This vulnerability affects vLLM deployments that automatically resolve and load models from:
- Remote Hugging Face repositories, or
- Local directories that may be writable or controlled by less-trusted parties.
The issue appears when auto_map-based dynamic modules in a model's configuration are imported and executed during model resolution without honoring trust_remote_code.
It is most relevant in environments where:
- Model paths can be influenced by users, CI/CD pipelines, or external configuration, and
- vLLM runs with meaningful host privileges (e.g., access to secrets, GPUs, internal networks).
Exploit preconditions
- Attack surface: vLLM model loading pathway (server startup or model hot-load), not the HTTP/GRPC inference API itself.
- Required access:
- Ability to control or modify the model repository or local model directory that vLLM is instructed to load, or
- Ability to point vLLM's configuration/parameters to a malicious or compromised model repo/path.
- Trigger point: Occurs automatically when vLLM resolves and loads the model, importing
auto_map-referenced Python modules. - Why exploitation is possible: The model loading logic imports and executes dynamic Python modules associated with the model configuration without gating this behavior behind
trust_remote_code, causing untrusted model metadata to be treated as executable code.
Why this happens
This is an example of CWE-94: Improper Control of Generation of Code (Code Injection) in the context of model loading.
Instead of treating model repositories and their configuration as data, the implementation implicitly trusts auto_map entries that reference Python modules and imports them without an explicit trust check.
The insecure pattern is:
- Coupling configuration-driven module resolution with implicit
import/execution - Lacking a strong, default-deny mechanism (such as strict
trust_remote_codeenforcement) for remote or untrusted model sources
Conceptually, executable code is being loaded from a content repository (models) that is often treated as data, enabling an attacker-controlled model repo/path to inject arbitrary behavior at load time.
Potential impact
- Arbitrary code execution on the vLLM host during model load
- Theft of environment variables, API keys, and other secrets accessible to the vLLM process
- Unauthorized access to internal services or lateral movement within the hosting environment
- Persistence mechanisms deployed on the host via the vLLM process
- Tampering with model behavior, logging, or response content for downstream users
General mitigation guidance
Effective mitigation focuses on treating model repositories as untrusted content by default and constraining dynamic code loading:
- Enforce a strict trust boundary around model loading: only allow dynamic module loading from model sources that are explicitly marked as trusted.
- Prefer configurations and loading paths that do not rely on
auto_map-style dynamic modules; favor pure-data model formats and well-defined, vetted architectures. - Apply a default-deny policy for remote code execution in model loaders, requiring explicit opt-in and clear operator visibility when enabling any remote code.
- Run vLLM with least privilege:
- Minimize file system access where possible (e.g., read-only volumes for models).
- Limit access to secrets and internal networks from the vLLM process.
- Isolate vLLM instances that load externally supplied or dynamically selected models using containerization, sandboxes, or separate security domains.
- Implement strong configuration management so that model paths and repository references cannot be arbitrarily overwritten by less-privileged users or automated processes.
How teams detect issues like this
Organizations can detect and monitor this class of issue using a combination of code-level and operational approaches:
- Static analysis and code review:
- Flag patterns where model configuration or metadata drives dynamic imports or
auto_map-style resolution. - Review model loading code paths for any imports or executions that are not gated by explicit trust flags or allowlists.
- Policy and configuration checks:
- Enforce policies that require
trust_remote_code-like controls to be honored in all model loading pipelines. - Validate deployment manifests and runtime configs to ensure model sources are restricted to vetted repositories.
- Runtime monitoring:
- Instrument vLLM containers or hosts to log dynamic imports and unexpected module loads during startup.
- Monitor for anomalous file system writes, network connections, or process behavior originating from vLLM processes during model initialization.
- Automated security review tools can be integrated into CI/CD workflows to scan for insecure dynamic code loading patterns before deployment.

