﻿# PyTorch CVE-2025-32434: the weights-only legacy-loader bypass

A historical PyTorch bypass affected weights_only loading before 2.6.0. Read the legacy-format fix and preserve the effective loader environment.

Author: Retrivium editorial team
Updated: 2026-11-05
Canonical URL: https://retrivium.ai/journal/pytorch-cve-2025-32434-weights-only-legacy-loader-boundary/
Language: en

## The restricted option had a concrete bypass

CVE-2025-32434 concerns loading an untrusted PyTorch checkpoint even with `weights_only=True`. The [project advisory](https://github.com/advisories/GHSA-53q9-r3pm-6pq6), published on 17 April 2025, lists versions below 2.6.0 as affected and 2.6.0 as patched. This identifies a specific historical bypass of a restriction that users could reasonably have expected to be active.

For an incident review, the useful question is therefore which library actually processed the artifact. The presence of a protective argument in application code does not establish that an affected implementation enforced it correctly. Preserve the exact environment used for loading, rather than checking only the version installed in an unrelated development notebook.

## The fix distinguishes a legacy archive path

The [linked patch](https://github.com/pytorch/pytorch/commit/8d4b8a920a2172523deb95bf20e8e52d50649c04) rejects the legacy tar loading path when the restricted unpickler is selected. Its regression check expects rejection for that combination. The change is more specific than a ban on every older checkpoint or every file carrying a familiar extension.

This gives a useful explanation for a compatibility failure after an update: rejection can be the intended security outcome. A workflow that responds by automatically retrying with unrestricted deserialization would change the trust decision at exactly the point where the restriction mattered. Any compatibility conversion should have its own reviewed source and environment, rather than silently becoming part of ordinary inference startup.

## Restricted loading still has a bounded contract

The [current serialization documentation](https://docs.pytorch.org/docs/2.15/notes/serialization.html) says the restricted unpickler limits executable reconstruction and does not dynamically import arbitrary modules. It also explicitly excludes denial-of-service protection and discusses possible memory-corruption risks. The documented default changed in version 2.6 when no custom pickle module is supplied; an explicit caller choice still needs examination.

These boundaries prevent two opposite reporting mistakes. A patch for this CVE should not be presented as proof that all checkpoint handling is harmless. Conversely, the historical bypass does not establish that every current load using the restricted path remains vulnerable to this same defect. Record the named issue, affected version and actual loading behavior separately.

An allowlist also deserves a specific explanation. Adding a requested class solely to make an error disappear is an authorization decision about reconstruction, rather than an ordinary change to tensor shape. The accepted functions and their provenance belong beside the artifact record.

## Verify remediation without running an unknown payload

A reviewable remediation record connects the checkpoint digest, library build, application entry point and effective arguments. Include wrappers and conversion utilities that may load the same artifact before the main inference process. A patched serving environment would not explain a separate preprocessing job that still uses an affected environment.

The [artifact-validation guide](/journal/safetensors-artifact-validation/) distinguishes serialization from separately loaded repository code. The [checksum guide](/journal/guide-storage-object-checksum/) explains the different question of byte identity. Together they support a scoped conclusion: the accepted artifact was handled by the reviewed path and version. This article inspected the advisory, patch and documentation; it did not execute an exploit, inspect private systems or establish any real compromise.
