Skip to content
CHGNet torch.load weights_only=False allows code execution via crafted model files

CHGNet torch.load weights_only=False allows code execution via crafted model files

First seen 30 Nov 2026, 07:19 UTC •

Article Content

Browse articles
ThreatCluster AI
ThreatCluster •November 30, 2026 at 07:20 UTC
  • •CHGNet.from_file() calls torch.load with weights_only=False, allowing arbitrary code execution when a crafted model file is loaded.
  • •Delivery is local and requires the victim to load the attacker-supplied file.
  • •A pull request passing weights_only=True at four loading sites is published alongside the report.
  • •The fix is described as rejecting non-allowlisted objects, which may break legacy checkpoints that contain numpy arrays or custom classes.
  • •No CVE, CVSS score, or in-the-wild exploitation is reported in these sources.

A GitHub issue reports that CHGNet.from_file(path) calls torch.load(path, weights_only=False), so loading an attacker-supplied CHGNet model file can run arbitrary code as the user via a pickle __reduce__ gadget during the load.

The reporter states the flaw is reached when a victim loads a file locally, and that the same flaw exists in other loads without the flag (trainer.py and crystalgraph.py), which are restricted only on torch 2.6 and later.

The reporter tested with chgnet 0.4.2 and torch 2.15.0+cpu, using a benign payload that ran id and wrote a marker file.

A separate GitHub pull request, published the same day, passes weights_only=True explicitly at four loading sites in CHGNet.from_file, Trainer.load, the best-checkpoint reload in Trainer.train, and CrystalGraph.from_file.

That PR states it adds tests/test_safe_loading.py confirming crafted payloads are rejected at three entry points, and that the three bundled pretrained models still load.

The PR notes that legacy checkpoints containing non-allowlisted objects (numpy arrays, custom classes) are now refused, with torch.serialization.add_safe_globals() as the stated workaround. Neither source reports exploitation in the wild, a CVE identifier, or a CVSS score.

Start a free Starter trial for enhanced analysis

Ask AI about this cluster

Or ask in your own assistant: ClaudeChatGPTPerplexityGemini

Timeline

2026-11-30
Vulnerability reported in CHGNet issue 258
The issue describes code execution via CHGNet.from_file() using torch.load with weights_only=False, tested on chgnet 0.4.2 and torch 2.15.0+cpu.
github.com
2026-11-30
Fix proposed in CHGNet pull request 259
The pull request passes weights_only=True at four torch.load sites and adds tests/test_safe_loading.py covering rejection of crafted payloads.
github.com

More articles in this cluster (2)

Common questions

Am I affected?
Users who load CHGNet model files from untrusted sources via from_file, Trainer.load, or CrystalGraph.from_file are affected according to the report. The reporter notes the other loads without the flag are restricted only on torch 2.6 and later.
How urgent is this?
The reporter rates impact as high (code execution) but delivery as local and requiring the victim to load the file. No exploitation in the wild is reported.
What should I do?
Only load CHGNet model files from trusted sources until a release containing the weights_only=True change is available. Check whether your code depends on legacy checkpoints that the fix may now refuse to load.