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
    • 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-2024-6923

CVE-2024-6923: CPython Email Header Injection Flaw

CVE-2024-6923 is an email header injection vulnerability in CPython's email module that allows attackers to inject malicious headers during serialization. This article covers the technical details, affected versions, and mitigation.

Published: January 28, 2026

CVE-2024-6923 Overview

CVE-2024-6923 is a header injection vulnerability affecting CPython's email module. The vulnerability exists because the email module fails to properly quote newlines when serializing email headers. This improper handling allows attackers to inject arbitrary headers when an email message is serialized, potentially enabling email spoofing, phishing attacks, or bypassing email security controls.

Critical Impact

Attackers can inject malicious headers into emails by exploiting improper newline handling in CPython's email serialization, enabling email spoofing and potential security bypass scenarios.

Affected Products

  • CPython (multiple versions including 3.10.x, 3.12.x, and 3.13.x branches)
  • Applications using Python's email module for message serialization
  • Systems running vulnerable CPython versions with email handling functionality

Discovery Timeline

  • August 1, 2024 - CVE-2024-6923 published to NVD
  • November 3, 2025 - Last updated in NVD database

Technical Details for CVE-2024-6923

Vulnerability Analysis

This vulnerability is classified as CWE-94 (Improper Control of Generation of Code / Code Injection). The core issue stems from insufficient input validation in CPython's email module when processing header values during message serialization. When an email message is serialized for transmission, the module fails to properly escape or quote newline characters (\n or \r\n) present in header values.

Email protocols (RFC 5322) use newlines as header delimiters. By injecting newline characters followed by malicious header content, an attacker can insert arbitrary headers into the serialized email output. This could allow manipulation of routing headers, content-type headers, or other critical email metadata.

Root Cause

The root cause lies in the email generator's failure to validate and sanitize header content before outputting serialized messages. The original implementation did not enforce proper encoding of special characters, particularly newline sequences, that have semantic meaning in the email protocol. Headers containing embedded newlines would be written directly to the output without transformation, allowing the injected content to be interpreted as separate headers by receiving mail systems.

Attack Vector

The attack can be executed over the network when an application accepts user-controlled input for email header fields (such as subject lines, sender names, or custom headers) and uses Python's email module to construct and serialize the message. An attacker provides input containing embedded newline characters followed by malicious header content. When the email is serialized, the injected content becomes part of the actual email headers.

The security patch introduces a verify_generated_headers policy attribute that validates headers during generation:

text
   .. attribute:: verify_generated_headers

      If ``True`` (the default), the generator will raise
      :exc:`~email.errors.HeaderWriteError` instead of writing a header
      that is improperly folded or delimited, such that it would
      be parsed as multiple headers or joined with adjacent data.
      Such headers can be generated by custom header classes or bugs
      in the ``email`` module.

      As it's a security feature, this defaults to ``True`` even in the
      :class:`~email.policy.Compat32` policy.
      For backwards compatible, but unsafe, behavior, it must be set to
      ``False`` explicitly.

Source: CPython GitHub Commit

Detection Methods for CVE-2024-6923

Indicators of Compromise

  • Unexpected or malformed email headers in outgoing mail logs
  • Email messages containing multiple instances of headers that should appear only once
  • User-supplied input appearing verbatim in email header fields with newline sequences
  • Reports of email spoofing originating from your mail systems

Detection Strategies

  • Review application code for usage of Python's email module with user-controlled header inputs
  • Implement logging to detect newline characters (\n, \r\n, \r) in header field inputs before email serialization
  • Monitor mail server logs for emails with anomalous header structures
  • Conduct code audits to identify all entry points where user input reaches email header construction

Monitoring Recommendations

  • Enable verbose logging on mail transfer agents to capture full header details of outgoing messages
  • Implement input validation alerts that trigger when special characters are detected in email header fields
  • Monitor for HeaderWriteError exceptions in application logs after patching, which may indicate attempted exploitation
  • Establish baseline metrics for normal email header patterns to detect anomalies

How to Mitigate CVE-2024-6923

Immediate Actions Required

  • Update CPython to a patched version (3.10.15+, 3.12.5+, or 3.13+) immediately
  • Review all application code that uses Python's email module for header construction with user input
  • Implement server-side input validation to strip or reject newline characters in header values
  • Enable the verify_generated_headers policy option (enabled by default in patched versions) to detect malformed headers

Patch Information

The Python development team has released security patches across multiple CPython branches. The fix introduces a new HeaderWriteError exception and the verify_generated_headers policy attribute that validates headers during email generation. When enabled (the default), the generator raises an exception instead of writing improperly delimited headers. Patches are available via the following resources:

  • Python Security Announcement
  • GitHub Issue #121650
  • GitHub Pull Request #122233
  • Debian LTS Advisory
  • NetApp Security Advisory

Workarounds

  • Implement strict input validation on all user-supplied data destined for email headers, rejecting inputs containing \r or \n characters
  • Use a sanitization layer that strips or encodes newline sequences before passing values to the email module
  • If patching is not immediately possible, explicitly set verify_generated_headers=True in email policy configurations
  • Consider using alternative email libraries with built-in header sanitization if CPython cannot be updated
bash
# Verify Python version includes the security fix
python3 --version
# Should be 3.10.15+, 3.12.5+, or 3.13+

# Check for HeaderWriteError availability (indicates patched version)
python3 -c "from email.errors import HeaderWriteError; print('Patched')"

# Update Python using system package manager (Debian/Ubuntu example)
sudo apt update && sudo apt upgrade python3

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

  • Vulnerability Details
  • TypeOther

  • Vendor/TechPython

  • SeverityMEDIUM

  • CVSS Score5.5

  • EPSS Probability0.20%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:U/C:L/I:L/A:L
  • Impact Assessment
  • ConfidentialityLow
  • IntegrityLow
  • AvailabilityLow
  • CWE References
  • CWE-94
  • Technical References
  • GitHub Commit Update

  • GitHub Commit Update

  • GitHub Commit Update

  • GitHub Commit Update

  • GitHub Commit Update

  • GitHub Commit Update

  • GitHub Commit Update

  • GitHub Issue #121650

  • GitHub Pull Request #122233

  • Python Security Announcement

  • Openwall OSS Security Thread

  • Openwall OSS Security Thread

  • Debian LTS Announcement

  • Debian LTS Announcement

  • NetApp Security Advisory
  • Related CVEs
  • CVE-2025-13462: Python tarfile Module Parsing Vulnerability

  • CVE-2021-23336: Python Web Cache Poisoning Vulnerability

  • CVE-2020-26116: Python HTTP Client CRLF Injection Flaw

  • CVE-2020-15523: Python DLL Hijacking Vulnerability
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