CVE-2026-58659: Lightning PyTorch Lightning Allows Arbitrary Code Vulnerability

HIGH
Advisory Identifier: GHSA-qqmf-gpg7-g8gw
CVSS 7.8
CWE-470
Published
Advisory Summary

CVE-2026-58659 is a HIGH (CVSS 7.8) pytorch lightning allows arbitrary code vulnerability (CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')) affecting Lightning libraries in the PyPI ecosystem. The issue involves pytorch lightning allows arbitrary code execution through checkpoint _instantiator hyperparameters. Remediation is available by upgrading affected packages to version 2.6.6.

CVE-2026-58659 at a Glance

CVE Identifier CVE-2026-58659
GHSA Identifier GHSA-qqmf-gpg7-g8gw
Severity HIGH
CVSS v3.1 Base Score 7.8
CWE Classification CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection')
Affected Product Lightning
Package Ecosystem PyPI
Published Date
Last Updated

Security Impact

CVSS: 7.8

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability High (A:H)

How to Fix CVE-2026-58659

To remediate this vulnerability, upgrade all affected Lightning dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

lightning fixed: 2.6.6
pip install lightning>=2.6.6
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

pip show lightning

How to Check if You Are Affected

To determine whether your Python environment is affected by CVE-2026-58659, inspect your installed packages using pip:

pip show lightning

Analyze the terminal output to locate any version of Lightning in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.6.6), your application is affected.

Note: The pip show lightning command checks currently installed packages in your active Python environment.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection'), where the product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code. In Lightning, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

PyTorch Lightning through 2.6.5, fixed in commit d710d68, contains a remote code execution vulnerability in the _load_state function that imports and executes attacker-controlled module names from checkpoint _instantiator hyperparameters. Attackers can craft malicious checkpoint files that bypass weights_only=True protections to execute arbitrary code when LightningModule.load_from_checkpoint is called.

CVE-2026-58659 Affected Lightning Versions

1 component(s)
Fixed Versions:
2.6.6
Product / Package Ecosystem Affected Versions Fixed Version
lightning
PyPI
< 2.6.6
2.6.6

References

Frequently Asked Questions

What is CVE-2026-58659?
CVE-2026-58659 is a security vulnerability in Lightning involving PyTorch Lightning allows arbitrary code execution through checkpoint _instantiator hyperparameters under CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection').
Which Lightning versions are affected?
Affected versions include releases prior to 2.6.6 across affected packages: lightning.
What version fixes CVE-2026-58659?
Upgrading to 2.6.6 (or the latest patched release for your respective branch) resolves the vulnerability.
Is lightning affected?
Yes, lightning is affected in releases prior to 2.6.6. Upgrade your dependency to 2.6.6 or later.
What is the CVSS score of CVE-2026-58659?
CVE-2026-58659 has a CVSS v3.1 base score of 7.8 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H.
What CWE is associated with CVE-2026-58659?
CVE-2026-58659 is classified under CWE-470: Use of Externally-Controlled Input to Select Classes or Code ('Unsafe Reflection') (The product uses external input with reflection to select which classes or code to use, but it does not sufficiently prevent the input from selecting improper classes or code.).
How can I check PyPI dependencies for CVE-2026-58659?
Run the dependency tree command: 'pip show lightning'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-qqmf-gpg7-g8gw",
  "modified" : "2026-09-24T15:39:46Z",
  "published" : "2026-07-15T18:31:58Z",
  "aliases" : [ "CVE-2026-58659" ],
  "summary" : " PyTorch Lightning allows arbitrary code execution through checkpoint _instantiator hyperparameters",
  "details" : "PyTorch Lightning through 2.6.5, fixed in commit d710d68, contains a remote code execution vulnerability in the _load_state function that imports and executes attacker-controlled module names from checkpoint _instantiator hyperparameters. Attackers can craft malicious checkpoint files that bypass weights_only=True protections to execute arbitrary code when LightningModule.load_from_checkpoint is called.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:N/UI:R/S:U/C:H/I:H/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:L/AC:L/AT:N/PR:N/UI:A/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "PyPI",
      "name" : "lightning"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.6.6"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-58659"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Lightning-AI/pytorch-lightning/issues/21822"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Lightning-AI/pytorch-lightning/pull/21832"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Lightning-AI/pytorch-lightning/commit/d710d689510d50e800f53b3cd773cbca20b1f86f"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/Lightning-AI/pytorch-lightning"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/Lightning-AI/pytorch-lightning/releases/tag/2.6.6"
  }, {
    "type" : "ADVISORY",
    "url" : "https://github.com/advisories/GHSA-qqmf-gpg7-g8gw"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/lightning/PYSEC-2026-3624.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pypa/advisory-database/tree/main/vulns/pytorch-lightning/PYSEC-2026-3967.yaml"
  }, {
    "type" : "WEB",
    "url" : "https://www.vulncheck.com/advisories/pytorch-lightning-arbitrary-code-execution-via-instantiator-hyperparameter"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-470" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-09-03T19:51:19Z",
    "nvd_published_at" : "2026-07-15T18:16:48Z"
  }
}