A Leader in the 2026 Gartner® Magic Quadrant™ for Endpoint Protection. Six years running.Six years. Gartner® Magic Quadrant™ Leader.Find Out Why
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2026-31221

CVE-2026-31221: PyTorch Lightning RCE Vulnerability

CVE-2026-31221 is a remote code execution flaw in PyTorch Lightning's checkpoint loading mechanism that allows attackers to execute arbitrary code. This article covers the technical details, affected versions, and mitigation.

Published: May 17, 2026

CVE-2026-31221 Overview

CVE-2026-31221 is an insecure deserialization vulnerability [CWE-502] in PyTorch-Lightning versions 2.6.0 and earlier. The LightningModule.load_from_checkpoint() method internally calls torch.load() without setting the weights_only=True parameter. This default behavior permits deserialization of arbitrary Python objects through the Pickle module. An attacker who supplies a malicious checkpoint file can trigger arbitrary code execution when a victim loads that file. The flaw affects machine learning workflows that consume third-party model checkpoints, including pretrained models shared via public repositories or model hubs.

Critical Impact

Loading an untrusted PyTorch-Lightning checkpoint results in arbitrary code execution with the privileges of the running process, compromising confidentiality, integrity, and availability of the host.

Affected Products

  • PyTorch-Lightning 2.6.0 and earlier (Python package)
  • LightningModule.load_from_checkpoint() API consumers
  • Lightning AI training and inference pipelines using torch.load() defaults

Discovery Timeline

  • 2026-05-12 - CVE-2026-31221 published to NVD
  • 2026-05-15 - Last updated in NVD database

Technical Details for CVE-2026-31221

Vulnerability Analysis

PyTorch-Lightning relies on PyTorch's serialization layer to persist and restore model state. The framework's LightningModule.load_from_checkpoint() helper wraps torch.load() to reconstruct model weights, optimizer states, and hyperparameters from a .ckpt file. PyTorch's default deserializer uses Python's pickle module, which can instantiate arbitrary objects and invoke methods such as __reduce__ during unpickling. When a checkpoint contains attacker-controlled pickle opcodes, those opcodes execute as Python code the moment the file is loaded. The attack does not require the model to run inference; the act of loading the checkpoint is sufficient.

Root Cause

The root cause is the omission of the weights_only=True argument when PyTorch-Lightning invokes torch.load(). PyTorch introduced weights_only to restrict deserialization to tensor data and a small allowlist of safe types. Because Lightning does not pass this flag, the underlying call falls back to unrestricted pickle deserialization. Any object graph stored in the checkpoint is reconstructed, including malicious callables embedded by an attacker.

Attack Vector

Exploitation requires a user to load an attacker-supplied checkpoint, which aligns with the User Interaction requirement in the CVSS vector. Common delivery channels include compromised or typosquatted model repositories, malicious pull requests adding pretrained weights, shared research artifacts, and supply-chain tampering of model registries. Once load_from_checkpoint() is called on the malicious .ckpt file, code execution occurs in the context of the data science workstation, training cluster, or inference service that performed the load. There are no public proof-of-concept exploits referenced in the advisory.

The vulnerability mechanism mirrors prior pickle-based attacks against ML serialization formats: a crafted object overrides __reduce__ to return a tuple invoking os.system, subprocess.Popen, or another Python callable during deserialization. See the GitHub PyTorch Lightning Repository for the checkpoint loading implementation.

Detection Methods for CVE-2026-31221

Indicators of Compromise

  • Unexpected child processes spawned by Python interpreters that recently invoked torch.load() or load_from_checkpoint().
  • Outbound network connections from training or inference hosts immediately after checkpoint loads.
  • .ckpt or .pt files originating from untrusted sources, public mirrors, or unsigned model registries.
  • New persistence artifacts (cron entries, systemd units, shell profile modifications) on ML workstations after model downloads.

Detection Strategies

  • Inspect checkpoint files with pickletools or fickling to flag unsafe opcodes such as GLOBAL, REDUCE, or references to os, subprocess, builtins.eval, and builtins.exec.
  • Hunt for Python processes executing shell binaries (sh, bash, cmd.exe, powershell.exe) as direct children of training jobs.
  • Audit code repositories for calls to LightningModule.load_from_checkpoint() and torch.load() that omit weights_only=True.

Monitoring Recommendations

  • Forward endpoint process telemetry from ML workstations and GPU servers into a centralized data lake for behavioral analysis.
  • Alert on Python processes that load checkpoint files and subsequently establish outbound network sessions or modify filesystem locations outside the project directory.
  • Track downloads of .ckpt, .pt, and .pth artifacts from non-allowlisted hosts.

How to Mitigate CVE-2026-31221

Immediate Actions Required

  • Upgrade PyTorch-Lightning to a version later than 2.6.0 that enforces weights_only=True when one becomes available from the maintainers.
  • Treat all externally sourced checkpoints as untrusted and load them only inside sandboxed, network-restricted environments.
  • Replace pickle-based checkpoint distribution with safetensors where the workflow permits.
  • Inventory and review every code path that calls load_from_checkpoint() or torch.load() on third-party files.

Patch Information

No vendor advisory or fixed version is listed in the NVD record at publication time. Monitor the GitHub PyTorch Lightning Repository for an official patch and release notes. Until a fix is published, apply the workarounds below.

Workarounds

  • Pass weights_only=True explicitly to torch.load() and avoid LightningModule.load_from_checkpoint() for untrusted files.
  • Verify checkpoint integrity with cryptographic signatures or hash allowlists before loading.
  • Run model loading in isolated containers with no network egress and minimal filesystem privileges.
  • Pre-scan checkpoints with tools such as fickling or picklescan in CI pipelines before promotion.
bash
# Configuration example: safer manual checkpoint load
python - <<'EOF'
import torch
# Restrict deserialization to tensor data and safe types
state = torch.load("model.ckpt", weights_only=True, map_location="cpu")
print(list(state.keys()))
EOF

# Pre-flight scan untrusted checkpoints in CI
pip install fickling
fickling --check-safety model.ckpt

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechPytorch Lightning

  • SeverityHIGH

  • CVSS Score7.8

  • EPSS Probability0.18%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityHigh
  • AvailabilityHigh
  • CWE References
  • CWE-502
  • Technical References
  • GitHub PyTorch Lightning Repository

  • Notion CVE-2026-31221 Details
  • Related CVEs
  • CVE-2024-5452: PyTorch Lightning RCE Vulnerability

  • CVE-2024-8019: PyTorch Lightning RCE Vulnerability

  • CVE-2024-5980: PyTorch Lightning Path Traversal Flaw
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the Most Advanced Cybersecurity Platform

See how the world’s most intelligent, autonomous cybersecurity platform can protect your organization today and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English