Sanaan Fayaz Wani

ray-project/ray

CVE-2026-57516

Ray: Arbitrary code execution via ray.data.read_webdataset default decoder: pickle.loads(value) and torch.load(weights_only=False)

CVE-2026-57516

8.8

High

CVSS 3.1 base

  1. 2026-07-01Published by the maintainer

What to do

If you run ray before 2.56.0, upgrade to 2.56.0 or later.

Anyone who can reach it over the network, with no account, if a user takes some action, can read and change sensitive data and make it unavailable.Read from the CVSS 3.1 vector

CVSS 3.1 metrics

To exploit it

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
Required

What it gets

Confidentiality
High
Integrity
High
Availability
High
Scope
Unchanged

Open this vector in the FIRST calculator ↗

Weakness
CWE-94, CWE-502 Improper Control of Generation of Code · Deserialization of Untrusted Data
CVE
CVE-2026-57516
Vector
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H

My analysis of this finding: root cause, the vulnerable code, the impact and the fix, in the site’s format. The official advisory of record is linked above.

Affected versions

Package Ecosystem Vulnerable Fixed in
ray pip < 2.56.0 2.56.0

Summary

Ray Data’s WebDataset reader, ray.data.read_webdataset(), deserializes files out of a tar archive based purely on their extension. A .pkl or .pickle member is fed to pickle.loads(), and a .pt or .pth member is fed to torch.load(weights_only=False). Both are textbook arbitrary-code-execution sinks, and the default decoder applies them with no opt-in, no restricted unpickler, and no warning. Any tar the pipeline reads, from S3, HTTP, Hugging Face Hub, or a shared drive, can run code on the Ray worker that processes it. I confirmed execution against ray v2.55.1.

Where it lives

The decoding happens in _default_decoder, python/ray/data/_internal/datasource/webdataset_datasource.py:213 through :223:

elif extension in ["pt", "pth"]:    import torch     # PyTorch 2.6 changed torch.load default weights_only=True, which    # breaks loading general Python objects previously serialized for    # WebDataset .pt payloads.    sample[key] = torch.load(io.BytesIO(value), weights_only=False)elif extension in ["pickle", "pkl"]:    import pickle     sample[key] = pickle.loads(value)

The bugloads tar members with torch weights_only explicitly disabledThe bugunpickles any .pkl member straight from the tar

extension is key.split(".")[-1] (line 188), so the choice of sink is driven entirely by the attacker-chosen filename inside the tar. The torch.load call explicitly passes weights_only=False, overriding the safe default PyTorch 2.6 introduced precisely to stop this attack class.

This path is on by default. read_webdataset declares decoder: ... = True in python/ray/data/read_api.py:2291, and WebDatasetDatasource wires _apply_list(self.decoder, sample, default=_default_decoder) when a decoder is set (webdataset_datasource.py:366 to :367). A caller who never touches the decoder argument gets the unsafe decoder.

Impact

An attacker who can place or modify a tar file read by a Ray Data WebDataset pipeline gets remote code execution on the Ray worker. In ML workflows this is realistic: training datasets routinely come from object storage, public hubs, and shared mounts, where write access or poisoning is often within reach of a far weaker attacker than one who already controls the cluster.

My PoC builds a tar holding sample0001.pkl whose pickle __reduce__ returns (os.system, ("id > /tmp/ray_webdataset_pwned ...",)). Reading it with ray.data.read_webdataset(tar_path) and iterating batches drops the marker file. A standalone check calls _default_decoder directly on a crafted sample dict and triggers the same os.system through pickle.loads(), isolating the sink from the rest of Ray.

This is the same class of bug as GHSA-mw35-8rx3-xf9r / CVE-2026-41486, which Ray accepted and fixed for Parquet Arrow extension types in v2.55.0. The WebDataset code path was left untouched. It is a deserialization-to-code-execution flaw (CWE-502): network reachable, no privileges needed, and it runs on the worker that loads the tar.

Fix

Stop deserializing untrusted bytes by default. Switch .pt/.pth to torch.load(..., weights_only=True), and either skip .pkl/.pickle with a UserWarning or gate pickle on an explicit opt-in, the same way the earlier Arrow fix added an opt-in environment variable. Users who genuinely need pickle from a trusted source can supply their own decoder.

References

The record

Weakness
CWE-94 Improper Control of Generation of Code
CWE-502 Deserialization of Untrusted Data
Affected
ray before 2.56.0
Fixed in
2.56.0
Disclosure
2026-07-01 Published
Advisory
GHSA-hhrp-gw25-jr43
CVE-2026-57516

About this writeup

Sanaan Fayaz Wani (GitHub sfwani) reported this vulnerability to the ray maintainers under coordinated disclosure and is credited as a reporter in GHSA-hhrp-gw25-jr43, published 2026-07-01.

All published findings: advisory index.