/

CVE-2026-31238

Severity:

CRITICAL RISK

(9.8)

Unsafe Deserialization in Ludwig Model Serving

CVE-2026-31238

Deferred

Vulnerability type

Category:

Unsafe Deserialization

CWE:

CWE-502

Impact:

Remote Code Execution

Severity:

CRITICAL RISK

(9.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

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, without weights_only=True or 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.

Sources

SourceLink
github.comgithub.com/ludwig-ai/ludwig
notion.sonotion.so/CVE-2026-31238-35d1e1393188819ea77ee98ca85a2878

Frequently asked

questions

It can be, depending on how models are supplied. If an attacker can upload or influence model artifacts that are later served (for example, via a web UI, API, or compromised artifact store), they can trigger code execution when the server loads the model.

The attacker must be able to provide, modify, or replace the model file that Ludwig will load. This might involve access to shared storage, CI/CD outputs, model registries, or any pipeline step that controls the final model artifact.

Use a restricted deserialization mode that loads only tensors and weights, combined with schema or format validation, and treat any deserialization capable of instantiating arbitrary Python objects as unsafe for untrusted data.

Establish a policy that all deserialization in serving paths is security-reviewed, prefer data-only formats for model artifacts, enforce provenance and integrity checks for models, and integrate static analysis or code search rules to flag unsafe deserialization APIs before they reach production.

Find out what's already
exploitable in your codebase.