Skip to content

feat: add pytorch loader for pickle opcode security analysis#198

Open
GangGreenTemperTatum wants to merge 1 commit intomainfrom
feat/pytorch-loader
Open

feat: add pytorch loader for pickle opcode security analysis#198
GangGreenTemperTatum wants to merge 1 commit intomainfrom
feat/pytorch-loader

Conversation

@GangGreenTemperTatum
Copy link
Collaborator

@GangGreenTemperTatum GangGreenTemperTatum commented Feb 24, 2026

Summary

  • Adds a new pytorch loader that statically scans PyTorch .pt/.pth checkpoint files for malicious pickle opcodes without executing anything
  • Detects dangerous opcodes (GLOBAL, REDUCE, BUILD, etc.), classifies global imports as known-safe/unknown/suspicious, validates ZIP archive structure, and flags path traversal in zip entries
  • Adds view_extra() dispatcher to view.py with pytorch-specific rendering (file structure, pickle analysis, global imports, color-coded findings)

Test plan

  • poetry run ruff check dyana — lint clean
  • poetry run ruff format --check dyana — format clean
  • poetry run mypy --ignore-missing-imports --no-error-summary dyana — type check clean
  • poetry run pytest dyana -v — 187 tests pass (20 new pytorch tests + 6 new view_extra tests)
  • CI pipeline passes

🤖 Generated with Claude Code

Generated Summary:

  • Updated the README to reflect that PyTorch checkpoints are now supported for profiling in Dyana.
  • Added new functionality for analyzing PyTorch checkpoint files, which includes:
    • A new loader for PyTorch files that checks file structure and scans for suspicious pickle opcodes.
    • Ability to handle both ZIP format and legacy pickle files.
    • Various safety checks for dangerous opcodes within the pickle data.
  • Incorporated a new command-line interface for analyzing PyTorch files, including usage examples.
  • Added comprehensive tests around PyTorch loading and analysis, ensuring error handling and detection of known safe and dangerous imports.
  • Minor code cleanups and refactoring for improved readability and maintainability, particularly in error handling messages and logging outputs.

This summary was generated with ❤️ by rigging

Static analysis of PyTorch .pt/.pth checkpoint files — scans pickle
bytecode for dangerous opcodes (GLOBAL, REDUCE, BUILD, etc.) without
executing anything. Detects suspicious module imports (os, subprocess),
validates ZIP structure, and flags path traversal in archive entries.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@dreadnode-renovate-bot dreadnode-renovate-bot bot added type/docs Documentation updates and improvements type/core Changes to core repository files and configurations labels Feb 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type/core Changes to core repository files and configurations type/docs Documentation updates and improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant