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

CVE-2026-6019: Python http.cookies XSS Vulnerability

CVE-2026-6019 is a cross-site scripting flaw in Python's http.cookies.Morsel.js_output() that fails to neutralize script tags, allowing HTML injection. This article covers the technical details, affected versions, and mitigation.

Published: April 23, 2026

CVE-2026-6019 Overview

A script injection vulnerability exists in Python's http.cookies.Morsel.js_output() method. The function generates an inline <script> snippet for setting cookies via JavaScript but only escapes double quotes (") for JavaScript string context. It fails to neutralize the HTML parser-sensitive sequence </script> inside the generated script element, potentially allowing attackers to inject malicious HTML/JavaScript content through crafted cookie values.

Critical Impact

Attackers who can control cookie values may be able to break out of the JavaScript context and inject arbitrary HTML or script content, leading to potential Cross-Site Scripting (XSS) attacks.

Affected Products

  • Python CPython - http.cookies module

Discovery Timeline

  • 2026-04-22 - CVE CVE-2026-6019 published to NVD
  • 2026-04-22 - Last updated in NVD database

Technical Details for CVE-2026-6019

Vulnerability Analysis

The vulnerability stems from insufficient output encoding in the js_output() method of the http.cookies.Morsel class. When generating JavaScript code to set cookies, the method creates an inline <script> element containing a document.cookie assignment. While the implementation escapes double quotes to prevent JavaScript string escaping, it does not account for HTML parser behavior.

Specifically, if a cookie value contains the sequence </script>, the HTML parser will interpret this as the end of the script element, regardless of whether it appears within a JavaScript string. This allows an attacker who can control cookie values to prematurely close the script tag and inject arbitrary HTML content, including malicious scripts.

This vulnerability falls under CWE-150 (Improper Neutralization of Escape, Meta, or Control Sequences), as the function fails to properly handle sequences that have special meaning in the HTML parsing context.

Root Cause

The root cause is the dual-context nature of inline scripts in HTML. The js_output() method only considered JavaScript string escaping (escaping double quotes) but failed to account for the HTML parsing layer that processes the script element first. The HTML parser looks for </script> to close the script element before JavaScript parsing occurs, creating an injection vector.

Attack Vector

An attacker can exploit this vulnerability by crafting a cookie value containing </script> followed by malicious HTML or JavaScript. When the js_output() method renders this value into an HTML page, the HTML parser will:

  1. Encounter the </script> sequence within the cookie value
  2. Interpret it as closing the legitimate script element
  3. Parse the subsequent attacker-controlled content as HTML/JavaScript

This is a network-accessible vulnerability requiring high privileges to exploit, as the attacker must be able to influence cookie values that are subsequently rendered using js_output().

The following patch shows how Python addressed this vulnerability by base64-encoding cookie values:

python
         return '<%s: %s>' % (self.__class__.__name__, self.OutputString())
 
     def js_output(self, attrs=None):
+        import base64
         # Print javascript
         output_string = self.OutputString(attrs)
         if _has_control_character(output_string):
             raise CookieError("Control characters are not allowed in cookies")
+        # Base64-encode value to avoid template
+        # injection in cookie values.
+        output_encoded = base64.b64encode(output_string.encode('utf-8')).decode("ascii")
         return """
         <script type="text/javascript">
         <!-- begin hiding
-        document.cookie = \"%s\";
+        document.cookie = atob(\"%s\");
         // end hiding -->
         </script>
-        """ % (output_string.replace('"', r'\"'))
+        """ % (output_encoded,)
 
     def OutputString(self, attrs=None):
         # Build up our result

Source: GitHub Commit Changes

Detection Methods for CVE-2026-6019

Indicators of Compromise

  • Unusual cookie values containing HTML-like sequences such as </script>, <script>, or other HTML tags
  • Web application logs showing cookie values with embedded HTML/JavaScript content
  • Client-side monitoring detecting unexpected script injections or DOM modifications

Detection Strategies

  • Implement input validation to detect and reject cookie values containing </script> or similar HTML-sensitive sequences
  • Use Content Security Policy (CSP) headers to detect and prevent execution of injected scripts
  • Deploy web application firewalls (WAF) with rules to identify script injection attempts in cookie parameters

Monitoring Recommendations

  • Monitor application logs for anomalous cookie values, particularly those containing angle brackets or script-related strings
  • Enable CSP violation reporting to detect attempted script injections
  • Review code for usage of http.cookies.Morsel.js_output() method and assess exposure

How to Mitigate CVE-2026-6019

Immediate Actions Required

  • Update Python to the latest patched version that includes the base64-encoding fix for js_output()
  • Audit application code for usage of http.cookies.BaseCookie.js_output() or http.cookies.Morsel.js_output()
  • Implement Content Security Policy headers to mitigate potential XSS impact
  • Validate and sanitize any user-controlled data that may influence cookie values

Patch Information

The Python development team has released a security patch that modifies the js_output() method to base64-encode cookie values before embedding them in JavaScript. The fix uses base64.b64encode() on the server side and atob() on the client side to decode the value, completely eliminating the possibility of HTML injection through cookie values.

For more details, see the GitHub Pull Request Review and Python Security Mailing Archive.

Workarounds

  • Avoid using js_output() method entirely; instead, set cookies via HTTP headers using Set-Cookie
  • If js_output() must be used, manually base64-encode cookie values before passing them to the method
  • Implement server-side validation to reject cookie values containing potentially dangerous sequences like </script>
bash
# Check Python version and update to patched release
python --version
# Update Python using your package manager
# For pip-based environments, ensure you're using a patched Python interpreter

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

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechN/A

  • SeverityLOW

  • CVSS Score2.1

  • EPSS Probability0.04%

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

  • GitHub Issue Discussion

  • GitHub Pull Request Review

  • Python Security Mailing Archive
  • Latest CVEs
  • CVE-2026-8468: Elixir Plug Library DoS Vulnerability

  • CVE-2026-8295: simdjson Information Disclosure Vulnerability

  • CVE-2025-68421: Comarch ERP Optima Auth Bypass Vulnerability

  • CVE-2025-68420: Comarch ERP Optima Privilege Escalation
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