Pickle file scanner
Drop a .pkl, .pt, .bin or .ckpt file and see what it imports when loaded, without running it. Flags os.system, eval and other code execution.
The file is parsed in your browser and never loaded or run. It is not uploaded.
Everything you type here stays in your browser. Nothing is sent to HardenKit or to anyone else.
How to use the pickle file scanner
- Drop the model file, or load an example. Large files are fine: only the pickle part is read.
- Check the verdict: a critical finding means do not load the file.
- Read the full import list for anything you do not recognise.
- For files you keep using, convert them to safetensors.
About this tool
Python’s pickle format is not data in the way JSON is. A pickle is a list of instructions for the unpickler, and two of them say "import this function" and "call it". That is how a class is rebuilt on load, and it is also how a model file can run os.system the moment someone calls torch.load or pickle.load on it. Malicious models built this way have been found on public model hubs.
This scanner reads the opcodes without executing anything. It lists every import the file would make (the GLOBAL, STACK_GLOBAL and INST opcodes) and sorts them: callables that run commands, code or network requests are critical; names outside the usual ML libraries are worth a look; tensor rebuilders, OrderedDict and numpy arrays are what a checkpoint should contain. PyTorch .pt and .ckpt files are zip archives, so it finds the data.pkl inside and reads only that.
The parser and its lists mirror the model-file check in HardenKit Scan. It is a list of known patterns: a pickle with no flagged import is not proven safe. The lasting fix is a format that cannot hold code: safetensors stores only tensors and a JSON header, and most libraries can read and write it.
Sources
Questions
Unpickling can import any module and call any function with arguments the file chooses. A file that names os.system and a command runs that command as soon as it is loaded, before your code sees any object. The Python documentation says to never unpickle data from an untrusted source.
Yes. A .pt or .pth file saved by torch.save is a zip archive with a data.pkl that describes the object, plus the raw tensor data. Since PyTorch 2.6, torch.load defaults to weights_only=True, which only allows tensors and basic types; older versions and weights_only=False unpickle everything.
A file format from Hugging Face that holds a JSON header and raw tensor bytes, and nothing else. There is no instruction to import or call anything, so loading it cannot run code. It also loads fast because tensors can be memory-mapped.
It is less likely to be hostile, not proven safe. The scan compares imports with a list of known dangerous callables, and attackers look for ones that are not on such lists. Prefer safetensors, load with weights_only=True, and load untrusted files in a sandbox.