Hub rules-pytorch

rules-pytorch

v3 public Verified

PyTorch

PyTorch is an open-source machine learning library based on the Torch library. These rules govern tensor computation, deep learning model architecture, and GPU-accelerated training.

@sigmashakeinc 2 pulls 6 rules published Apr 8, 2026 synced Oct 11, 2026 sigmashakeinc/rules/rulesets/rules-pytorch →
Severity
3 error 3 warn 0 info
demo.cast
PyTorch is an open-source machine learning library based on the Torch library. These rules govern tensor computation, deep learning model architecture, and GPU-accelerated training.

Rules index

6 governance rules

Indexed from the repository's .rules files, grouped by technology. Expand any rule to read the raw source.

pytorch

no-torch-from-numpy-unvalidated warning log

RISK: torch.from_numpy() on externally supplied data of uncontrolled shape can allocate GPU memory proportional to attacker input, enabling resource exhaustion. FIX: validate shape and dtype bounds before creating tensors from untrusted input.

Rule source requires an active Pro or Enterprise subscription.
no-torch-hub-load-untrusted error log

RISK: torch.hub.load() downloads and executes hubconf.py from a remote GitHub repo (arbitrary code execution). FIX: pin the exact commit hash as the third argument and review hubconf.py before loading from any repo you do not control.

Rule source requires an active Pro or Enterprise subscription.
no-torch-load-unsafe error block

RISK: torch.load() without weights_only=True uses pickle under the hood and can execute arbitrary code when loading untrusted checkpoints (CWE-502). FIX: pass weights_only=True — torch.load(path, weights_only=True) — or use torch.load with map_location and a trusted path only.

Rule source requires an active Pro or Enterprise subscription.
no-torch-load-weights-only-false error block

RISK: torch.load(..., weights_only=False) explicitly opts into pickle deserialization, enabling RCE from malicious checkpoints. FIX: remove weights_only=False or use weights_only=True. Only load checkpoints from fully trusted sources.

Rule source requires an active Pro or Enterprise subscription.
no-torch-set-num-threads-unbounded warning log

ADVISORY: torch.set_num_threads() can over-subscribe CPU cores and cause resource contention in multi-process / containerised deployments. FIX: derive the thread count from os.cpu_count() or the OMP_NUM_THREADS env var rather than hardcoding.

Rule source requires an active Pro or Enterprise subscription.
no-torch-variable-deprecated warning log

torch.autograd.Variable is deprecated since PyTorch 0.4 — tensors now track gradients natively. FIX: replace Variable(t) with t and set t.requires_grad = True where needed.

Rule source requires an active Pro or Enterprise subscription.

Version metadata

Published metadata

The hash-locked record of this published ruleset. When source contents change, the maintainer resyncs and the version bumps.

Version
v3
Published
Apr 8, 2026
Source commits
0
Synced
Oct 11, 2026
Hash
d5867e99c41a0741fcf3fdf048bda58d616925223003d7a207176a424ce2e76c
Signature
Verified (publisher key)
Tested with
claude-code@current
Plan
Starter (free)
Visibility
Public

Source history

Recent commits

Latest commits touching rulesets/rules-pytorch/.sigmashake/rules in sigmashakeinc/rules/rulesets/rules-pytorch. The published version only bumps when a maintainer resyncs.

No commit history available.