Ray: Arbitrary code execution via ray.data.read_webdataset default decoder: pickle.loads(value) and torch.load(weights_only=False)
8.8
High
CVSS 3.1 base
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
To exploit it
What it gets
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.
| Package | Ecosystem | Vulnerable | Fixed in |
|---|---|---|---|
ray | pip | < 2.56.0 | 2.56.0 |
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.
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.
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.
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.
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.