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-32274

CVE-2026-32274: Black Python Formatter Path Traversal

CVE-2026-32274 is a path traversal vulnerability in Black Python code formatter that allows attackers to write cache files to arbitrary locations. This post covers the technical details, affected versions, and mitigation.

Published: March 13, 2026

CVE-2026-32274 Overview

CVE-2026-32274 is a path traversal vulnerability in Black, the popular uncompromising Python code formatter. Prior to version 26.3.1, Black improperly handled the --python-cell-magics option when computing cache file names. The value of this argument was placed directly into the filename without sanitization, enabling an attacker who controls this argument to write cache files to arbitrary file system locations.

Critical Impact

Attackers who can control the --python-cell-magics argument value can write cache files to arbitrary locations on the file system, potentially leading to arbitrary file write conditions that could compromise system integrity.

Affected Products

  • Black Python Formatter versions prior to 26.3.1
  • Python projects using Black with IPython/Jupyter notebook integration
  • CI/CD pipelines and development environments utilizing Black's caching mechanism

Discovery Timeline

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

Technical Details for CVE-2026-32274

Vulnerability Analysis

This vulnerability is classified as CWE-22 (Path Traversal), affecting how Black constructs cache file names from user-supplied configuration options. The --python-cell-magics option, designed to specify additional cell magic syntax for IPython/Jupyter notebooks, was concatenated directly into cache file paths without proper sanitization.

The flaw exists in the cache key computation logic within src/black/mode.py. When Black processes formatting options to generate a unique cache filename, it incorporates the python_cell_magics values directly into the path construction. An attacker could supply path traversal sequences (such as ../) within the magic cell names to escape the intended cache directory.

Root Cause

The root cause is insufficient input validation when constructing cache file paths. The features_and_magics string, which includes unsanitized user-controlled data from --python-cell-magics, was conditionally hashed only if it exceeded a certain length threshold. This conditional approach allowed shorter, malicious inputs containing path traversal characters to pass through unhashed and be used directly in file path construction.

Attack Vector

The vulnerability is exploitable over the network in scenarios where Black is invoked with attacker-controlled arguments, such as in shared CI/CD environments, code formatting services, or when processing untrusted configuration files. An attacker would craft a malicious --python-cell-magics value containing directory traversal sequences to write files outside the intended cache directory.

The attack requires no authentication and can be executed with low complexity. While the vulnerability does not directly expose confidential data, it allows high-impact integrity violations through arbitrary file writes.

python
# Security patch in src/black/mode.py
# Before: Conditional hashing allowed malicious input to bypass sanitization
             + "@"
             + ",".join(sorted(self.python_cell_magics))
         )
-        if len(features_and_magics) > _MAX_CACHE_KEY_PART_LENGTH:
-            features_and_magics = sha256(features_and_magics.encode()).hexdigest()[
-                :_MAX_CACHE_KEY_PART_LENGTH
-            ]
+        features_and_magics = sha256(features_and_magics.encode()).hexdigest()[
+            :_MAX_CACHE_KEY_PART_LENGTH
+        ]
         parts = [
             version_str,
             str(self.line_length),

Source: GitHub Commit Changes

Detection Methods for CVE-2026-32274

Indicators of Compromise

  • Unexpected files appearing outside Black's designated cache directories
  • Cache files with unusual naming patterns containing path traversal sequences (../)
  • Black process activity with suspicious --python-cell-magics arguments containing special characters
  • Anomalous file write operations in sensitive system directories originating from Black processes

Detection Strategies

  • Monitor command-line arguments passed to Black for path traversal patterns in --python-cell-magics values
  • Implement file integrity monitoring on critical system directories to detect unexpected writes
  • Audit CI/CD pipeline configurations for untrusted input being passed to Black formatting commands
  • Review pyproject.toml and other Black configuration files for suspicious python_cell_magics entries

Monitoring Recommendations

  • Enable logging for Black execution in automated environments to capture full command-line arguments
  • Set up alerts for file creation events outside designated cache directories associated with Python processes
  • Monitor for unusual patterns in Black's cache directory indicating potential exploitation attempts
  • Implement SentinelOne's behavioral AI detection to identify anomalous file system activity from development tools

How to Mitigate CVE-2026-32274

Immediate Actions Required

  • Upgrade Black to version 26.3.1 or later immediately across all development environments
  • Audit existing configurations and CI/CD pipelines for potentially malicious --python-cell-magics values
  • Review file system integrity in environments where Black has been executed with untrusted input
  • Implement input validation on any systems that pass user-controlled values to Black arguments

Patch Information

The vulnerability has been fixed in Black version 26.3.1. The patch modifies the cache key computation to always hash the features_and_magics string, regardless of length, ensuring that path traversal sequences cannot be injected into file paths. The fix was implemented in commit 4937fe6cf241139ddbfc16b0bdbb5b422798909d.

For detailed patch information, refer to:

  • GitHub Security Advisory GHSA-3936
  • GitHub Release Tag 26.3.1
  • GitHub Pull Request Discussion

Workarounds

  • Avoid passing untrusted or user-controlled input to the --python-cell-magics argument
  • Run Black in isolated environments with restricted file system permissions
  • Implement allowlisting for python_cell_magics values in automated pipelines
  • Use container isolation or sandboxing when executing Black on untrusted code
bash
# Configuration example - Upgrade Black to patched version
pip install --upgrade black>=26.3.1

# Verify installed version
black --version

# For pipenv environments
pipenv install black>=26.3.1

# For poetry environments  
poetry add black@^26.3.1

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

  • Vulnerability Details
  • TypePath Traversal

  • Vendor/TechBlack

  • SeverityHIGH

  • CVSS Score8.7

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:H/VA:N/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
  • AvailabilityNone
  • CWE References
  • CWE-22
  • Technical References
  • GitHub Commit Changes

  • GitHub Pull Request Discussion

  • GitHub Release Tag 26.3.1

  • GitHub Security Advisory GHSA-3936
  • Related CVEs
  • CVE-2026-31900: Black Python Formatter RCE Vulnerability

  • 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