The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
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-31900

CVE-2026-31900: Black Python Formatter RCE Vulnerability

CVE-2026-31900 is a remote code execution flaw in Black Python code formatter's GitHub Action that allows malicious pull requests to execute arbitrary code and access secrets. This article covers technical details, impact, and mitigation.

Published: March 13, 2026

CVE-2026-31900 Overview

CVE-2026-31900 is a high-severity arbitrary code execution vulnerability in Black, the widely-used uncompromising Python code formatter. The vulnerability exists in Black's GitHub Action, which provides automated code formatting in CI/CD workflows. When the use_pyproject: true option is enabled, the action reads the Black version to install from the repository's pyproject.toml file. A malicious actor could craft a pull request that modifies this configuration file to specify a direct URL reference pointing to a malicious package repository, resulting in arbitrary code execution within the GitHub Action context.

Critical Impact

Attackers can achieve arbitrary code execution in GitHub Actions workflows, potentially gaining access to repository secrets, workflow permissions, and CI/CD pipeline compromise.

Affected Products

  • Black GitHub Action (versions prior to 26.3.0)
  • Black Python code formatter with use_pyproject: true configuration
  • CI/CD pipelines utilizing Black's GitHub Action for code formatting

Discovery Timeline

  • 2026-03-11 - CVE CVE-2026-31900 published to NVD
  • 2026-03-12 - Last updated in NVD database

Technical Details for CVE-2026-31900

Vulnerability Analysis

This vulnerability stems from improper input validation (CWE-20) in Black's GitHub Action version parsing mechanism. The action's main.py file uses a regular expression to validate and extract the Black version specification from pyproject.toml. The original regex pattern was overly permissive, allowing arbitrary strings after the "black" package name, including direct URL references to external repositories.

When a GitHub Action workflow processes a pull request with use_pyproject: true enabled, the action reads the Black version from the untrusted pyproject.toml file in the pull request. The insufficient validation allowed attackers to specify malicious package sources that would be installed and executed with the full permissions of the GitHub Action.

Root Cause

The root cause lies in the insufficient validation of the version specifier regex pattern in action/main.py. The original pattern ^black([^A-Z0-9._-]+.*)$ was too permissive, accepting any string following the package name rather than restricting input to valid PEP 440 version specifiers. This allowed direct URL references (e.g., black @ https://malicious.repo/package.tar.gz) to bypass validation and be installed during workflow execution.

Attack Vector

The attack vector is network-based, requiring an attacker with the ability to submit a pull request to a repository using the vulnerable Black GitHub Action. The exploitation path involves:

  1. Identifying a target repository using Black's GitHub Action with use_pyproject: true
  2. Creating a malicious fork and modifying pyproject.toml to include a direct URL package reference
  3. Submitting a pull request to trigger the GitHub Action workflow
  4. The malicious package executes arbitrary code with workflow permissions, enabling secret exfiltration or further compromise
python
# Security patch in action/main.py - Harden Black action version parsing (#5031)
 USE_PYPROJECT = os.getenv("INPUT_USE_PYPROJECT") == "true"
 OUTPUT_FILE = os.getenv("OUTPUT_FILE", default="")
 
-BLACK_VERSION_RE = re.compile(r"^black([^A-Z0-9._-]+.*)$", re.IGNORECASE)
+BLACK_VERSION_RE = re.compile(
+    r"^black((?:\s*(?:~=|==|!=|<=|>=|<|>|===)\s*[A-Za-z0-9*+._-]+)"
+    r"(?:\s*,\s*(?:~=|==|!=|<=|>=|<|>|===)\s*[A-Za-z0-9*+._-]+)*)\s*$",
+    re.IGNORECASE,
+)
 EXTRAS_RE = re.compile(r"\[.*\]")
 EXPORT_SUBST_FAIL_RE = re.compile(r"\$Format:.*\$")

Source: GitHub Commit Details

Detection Methods for CVE-2026-31900

Indicators of Compromise

  • Unexpected modifications to pyproject.toml files in pull requests, particularly in the Black version specification
  • GitHub Action logs showing installation of Black from non-PyPI sources or direct URL references
  • Unauthorized access to repository secrets or unexpected workflow behavior following pull request CI runs

Detection Strategies

  • Implement code review policies requiring approval for any changes to pyproject.toml or other dependency configuration files
  • Configure GitHub branch protection rules to require review from code owners for changes to CI/CD configuration files
  • Monitor GitHub Action audit logs for unusual package installation patterns or unexpected network requests during workflow execution

Monitoring Recommendations

  • Enable GitHub's security alerting for dependency-related changes in pull requests
  • Implement automated scanning for direct URL references in Python dependency specifications
  • Review GitHub Action workflow logs for installation commands containing URLs pointing to non-standard package repositories

How to Mitigate CVE-2026-31900

Immediate Actions Required

  • Upgrade Black to version 26.3.0 or later immediately across all repositories using the Black GitHub Action
  • Review recent pull requests for any suspicious modifications to pyproject.toml files
  • Audit GitHub Action workflow permissions and rotate any secrets that may have been exposed through CI/CD pipelines

Patch Information

The vulnerability has been fixed in Black version 26.3.0. The security patch hardens the version parsing regular expression to only accept valid PEP 440 version specifiers, rejecting direct URL references and other potentially malicious inputs. The fix is available in commit 0a2560b981364dde4c8cf8ce9d164c40669a8611. For detailed information, see the GitHub Security Advisory.

Workarounds

  • Disable the use_pyproject: true option in the Black GitHub Action and specify a fixed version directly in the workflow file
  • Configure GitHub Actions to run only after approval for external contributors, preventing automatic execution of workflows from untrusted pull requests
  • Implement workflow restrictions using GitHub's pull_request_target trigger cautiously with explicit checkout of trusted code only
bash
# Configuration example: Specify fixed Black version in GitHub Action workflow
# Instead of use_pyproject: true, pin the version directly
steps:
  - uses: psf/black@stable
    with:
      version: "26.3.0"
      # Avoid use_pyproject: true when accepting external pull requests

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

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechBlack

  • SeverityHIGH

  • CVSS Score8.7

  • EPSS Probability0.12%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:N/VC:H/VI:H/VA:H/SC:N/SI:N/SA:N/E:X/CR:X/IR:X/AR:X/MAV:X/MAC:X/MAT:X/MPR:X/MUI:X/MVC:X/MVI:X/MVA:X/MSC:X/MSI:X/MSA:X/S:X/AU:X/R:X/V:X/RE:X/U:X
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-20
  • Technical References
  • GitHub Commit Details

  • GitHub Security Advisory
  • Related CVEs
  • CVE-2026-32274: Black Python Formatter Path Traversal

  • CVE-2024-21503: Black Python Formatter ReDoS Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now 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