Summary
Ludwig model serving up to version 0.10.4 insecurely deserializes model weight files using torch.load() without security restrictions, allowing embedded Python objects to be unpickled.
If an attacker can supply or influence the PyTorch model file used by ludwig serve, they may achieve arbitrary code execution on the system hosting the model server.
Affected context
This vulnerability affects deployments that use the ludwig serve command to host models whose weight files are loaded via torch.load() without weights_only=True.
The issue becomes relevant when model artifacts are obtained from semi-trusted or untrusted sources, shared storage, CI/CD artifacts, or any pipeline where an attacker might replace or inject a malicious .pt / model file.
In such environments, the model loading process implicitly trusts the serialized content and executes deserialization logic during server startup.
Exploit preconditions
- Attack surface: Model loading pathway invoked by
ludwig serve. - Required access: Ability to provide, modify, or replace the PyTorch model file (e.g., write access to model artifact storage, compromised training pipeline, or control over model distribution channel).
- Trigger point: Server startup or model reload, when Ludwig calls
torch.load()on the supplied model weights. - Why exploitation is possible:
torch.load()uses Python's pickle mechanism by default and, withoutweights_only=Trueor equivalent restrictions, will deserialize arbitrary objects whose constructors can execute attacker-controlled code.
Why this happens
The core issue is insecure use of a general-purpose deserialization API for loading data originating outside the immediate trust boundary.
Ludwig's model serving component calls torch.load() on model weight files without applying security-hardening options (such as weights_only=True) or validating that only primitive tensors are being loaded.
This behavior maps directly to CWE-502: Deserialization of Untrusted Data, where untrusted serialized input is fed to a deserializer capable of instantiating arbitrary objects, allowing execution of embedded logic during the loading process.
Potential impact
- Arbitrary code execution under the privileges of the Ludwig model server process.
- Full compromise of the host running model serving (e.g., access to local files, environment variables, API keys).
- Pivoting into adjacent services, data stores, or internal networks accessible from the compromised host.
- Manipulation of model behavior or predictions to produce targeted incorrect outputs.
- Introduction of persistent backdoors into ML infrastructure or CI/CD pipelines via malicious model artifacts.
General mitigation guidance
Mitigation typically centers on treating model files as untrusted input and constraining how they are deserialized:
- Prefer secure-loading options that restrict deserialization to tensors and weights only (e.g., using APIs or flags analogous to
weights_only=True) instead of full object graphs. - Introduce strict validation and allowlists for model artifact formats and structures before loading, rejecting files that do not conform to expected schemas.
- Enforce strong provenance controls around model artifacts, such as signing, checksum verification, and controlled artifact repositories, to reduce the chance of tampering.
- Isolate model serving in hardened, least-privilege environments (e.g., containers with minimal filesystem access and restricted outbound connectivity) so that impact is limited if deserialization is abused.
- Separate training and serving roles so that unreviewed or experimental models are not directly exposed to production serving endpoints.
How teams detect issues like this
Detection is best approached by combining code-level analysis with operational monitoring:
- Use static analysis or code search to flag uses of
torch.load()(or similar APIs) that do not employ restrictive options and that accept external or runtime-supplied file paths. - During code review, treat any deserialization in model loading as a security-sensitive operation, and scrutinize assumptions about who controls the model artifacts.
- Incorporate policy checks in CI/CD pipelines to prevent merges that introduce or retain unsafe deserialization patterns in serving components.
- Monitor model artifact repositories and deployment logs for unexpected changes in model files or unusual server restarts correlated with new artifacts.
- Consider automated security scanning tools that recognize and alert on unsafe deserialization sinks in Python ML frameworks.

