Loading an attacker-supplied CHGNet model file with CHGNet.from_file(path) runs arbitrary code as the user. The method calls torch.load(path, ..., weights_only=False) , which uses the full pickle unpickler, so a __reduce__ gadget anywhere in the saved dict runs during the load, before the model is built. Impact is high (code execution); delivery is local and needs the victim to load the file.
chgnet/model/model.py:684-688 :
from_file is the documented way to load a fine-tuned CHGNet: Trainer.save() writes {"model": model.as_dict(), "optimizer": ..., "scheduler": ..., "training_history": ..., "trainer_args": ...} to a .pth.tar , and users pass that file to from_file for StructOptimizer , CHGNetCalculator and MD runs. weights_only=False explicitly turns off the restricted unpickler that PyTorch uses by default since 2.6, so every callable named in the stream runs. The dict the trainer writes holds tensors and plain Python values, so weights_only=True is sufficient for it. Related loads without the flag ( chgnet/trainer/trainer.py:344 and :679 , chgnet/graph/crystalgraph.py:167 ) are restricted on torch 2.6 and later but not on older torch.
Benign payload: it runs id and writes a marker file. The file has the trainer's output format plus one extra entry.
/tmp/chgnet_poc.txt holds the id output and a working CHGNet is returned. Control: the same file without the note entry loads the same model and runs nothing. Tested with chgnet 0.4.2 (built from the sdist), torch 2.15.0+cpu, Python 3.13, Linux; main b9a6c158 has the same code.
Fine-tuned CHGNet checkpoints are shared between groups and published with papers and on model hubs. Anyone who loads one from an untrusted source runs the file author's code with their privileges, usually on HPC or GPU machines with access to research data and credentials.
Load with weights_only=True . The change is one argument in CHGNet.from_file() in chgnet/model/model.py ; CHGNet.load() reads the bundled pretrained weights through the same method, so those files should be checked to load under the flag (any extra types can be allowed explicitly with torch.serialization.add_safe_globals ). Passing weights_only=True explicitly in trainer.py and crystalgraph.py keeps those loads safe on older torch as well.
Project:
Source: chgnet/chgnet/model/model.py Line 687 in b9a6c15 state = torch . load ( path , map_location = torch . device ( "cpu" ), weights_only = False )
chgnet/chgnet/model/model.py
Affected versions: <= 0.4.2 and main b9a6c158
Patched versions: none
Severity: CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H (7.8)
Dilanka Kaushal Hewage (r3vpwnx) [email protected]
bowen-bd added a commit that references this issue on Nov 29, 2026 Load checkpoints with weights_only=True ( #259 ) 5403c44
Load checkpoints with weights_only=True ( #259 )
bowen-bd closed this as completed in #259 on Nov 29, 2026
The full story
This article is one source in a clustered incident — the cluster page carries the summary, timeline and every other outlet covering it.
