Join the Cyber Forum: Threat Intel on May 12, 2026 to learn how AI is reshaping threat defense.Join the Virtual Cyber Forum: Threat IntelRegister Now
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-27120

CVE-2026-27120: Leafkit Templating XSS Vulnerability

CVE-2026-27120 is an XSS flaw in Leafkit templating language that allows attackers to bypass HTML escaping using extended grapheme clusters. This post covers the technical details, affected versions, impact, and mitigation.

Published: February 27, 2026

CVE-2026-27120 Overview

CVE-2026-27120 is a Cross-Site Scripting (XSS) vulnerability in Leafkit, a templating language with Swift-inspired syntax used in the Vapor web framework ecosystem. Prior to version 1.4.1, the htmlEscaped() function in leaf-kit fails to properly escape HTML special characters when they appear within extended grapheme clusters. This flaw allows attackers to bypass HTML escaping by using specially crafted extended grapheme clusters containing both the special HTML character and additional characters, potentially leading to XSS attacks when user-controlled data is rendered in HTML attributes.

Critical Impact

Attackers can inject malicious scripts by exploiting the Unicode grapheme cluster handling flaw in Leafkit's HTML escaping mechanism, leading to Cross-Site Scripting attacks in applications using user-controlled Leaf template variables within HTML attributes.

Affected Products

  • Leafkit versions prior to 1.4.1
  • Vapor web applications using vulnerable leaf-kit templating
  • Swift server-side applications utilizing Leafkit for HTML rendering

Discovery Timeline

  • 2026-02-20 - CVE CVE-2026-27120 published to NVD
  • 2026-02-23 - Last updated in NVD database

Technical Details for CVE-2026-27120

Vulnerability Analysis

The vulnerability exists in the htmlEscaped() function within Sources/LeafKit/String+HTMLEscape.swift. The original implementation uses Swift's string replacement methods (replacing() or replacingOccurrences(of:with:)) which operate on extended grapheme clusters rather than individual Unicode scalars. In Swift, an extended grapheme cluster is a sequence of one or more Unicode scalars that produce a single human-readable character.

When an attacker crafts input containing HTML special characters (such as <, >, ", ', or &) combined with other Unicode scalars to form extended grapheme clusters, the string matching fails because the grapheme cluster as a whole does not match the single-character pattern. This allows the dangerous HTML characters to pass through unescaped, enabling injection of arbitrary HTML and JavaScript code.

The weakness falls under CWE-75 (Failure to Sanitize Special Elements into a Different Plane), as the escaping logic fails to account for Unicode composition mechanisms.

Root Cause

The root cause is the use of grapheme cluster-based string matching for HTML character escaping. Swift's String type treats strings as collections of extended grapheme clusters by default. When the replacing() or replacingOccurrences(of:with:) methods search for a single character like <, they look for an exact grapheme cluster match. If the < character is combined with other Unicode scalars (such as combining marks), it forms a different grapheme cluster that no longer matches the simple < pattern, causing the escape logic to skip it entirely.

Attack Vector

The attack vector is network-based and requires user interaction. An attacker can exploit this vulnerability by injecting specially crafted Unicode strings into user-controlled template variables that are rendered in HTML attribute contexts. When the Leafkit template engine processes the input and applies HTML escaping, the malicious characters survive due to the grapheme cluster bypass. The resulting HTML output contains unescaped special characters, enabling JavaScript execution in the victim's browser when they view the page.

For example, an attacker could submit input containing a quote character combined with a Unicode combining mark, which would bypass the escaping and break out of an HTML attribute to inject event handlers or script tags.

The security fix addresses this by operating on individual Unicode scalars rather than grapheme clusters:

text
-import Foundation
-
 extension String {
     /// Escapes HTML entities in a `String`.
     public func htmlEscaped() -> String {
-        if #available(macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0, *) {
-            self
-                .replacing("&", with: "&")
-                .replacing("\"", with: """)
-                .replacing("'", with: "'")
-                .replacing("<", with: "<")
-                .replacing(">", with: ">")
-        } else {
-            self
-                .replacingOccurrences(of: "&", with: "&")
-                .replacingOccurrences(of: "\"", with: """)
-                .replacingOccurrences(of: "'", with: "'")
-                .replacingOccurrences(of: "<", with: "<")
-                .replacingOccurrences(of: ">", with: ">")
+        self.unicodeScalars.reduce(into: "") { result, scalar in
+            switch scalar {
+            case "&": result += "&"
+            case "\"": result += """
+            case "'": result += "'"
+            case "<": result += "<"
+            case ">": result += ">"
+            default: result.unicodeScalars.append(scalar)
+            }
         }
     }

Source: GitHub Commit

Detection Methods for CVE-2026-27120

Indicators of Compromise

  • Unusual Unicode sequences in user input fields, particularly combining characters alongside HTML special characters
  • Web application logs showing input containing extended grapheme clusters with embedded <, >, ", ', or & characters
  • Client-side JavaScript errors or unexpected script execution reports from users

Detection Strategies

  • Implement Web Application Firewall (WAF) rules to detect and block input containing suspicious Unicode combining sequences adjacent to HTML special characters
  • Monitor application logs for requests containing non-ASCII characters in form fields that are rendered in HTML attribute contexts
  • Deploy Content Security Policy (CSP) headers to detect and report XSS attempts through policy violation reports

Monitoring Recommendations

  • Enable verbose logging for Leafkit template rendering to capture input values before and after HTML escaping
  • Set up alerts for CSP violation reports indicating inline script execution attempts
  • Monitor for anomalous patterns in user-submitted data containing Unicode combining marks or zero-width characters

How to Mitigate CVE-2026-27120

Immediate Actions Required

  • Upgrade Leafkit to version 1.4.1 or later immediately
  • Audit all Leaf templates to identify user-controlled variables rendered within HTML attributes
  • Implement Content Security Policy headers to mitigate potential XSS impact while patching
  • Consider additional server-side input validation for Unicode content

Patch Information

The vulnerability is fixed in Leafkit version 1.4.1. The fix modifies the htmlEscaped() function to iterate over individual Unicode scalars using self.unicodeScalars instead of operating on grapheme clusters. This ensures that HTML special characters are properly escaped regardless of whether they are combined with other Unicode scalars. The patch is available via the GitHub commit and through the official GitHub Security Advisory.

Workarounds

  • Implement additional input sanitization at the application layer before passing data to Leaf templates, stripping or rejecting Unicode combining characters
  • Avoid placing user-controlled variables directly in HTML attribute contexts; use safer contexts or additional encoding
  • Deploy strict Content Security Policy headers with script-src 'self' to prevent inline script execution from XSS payloads
bash
# Update Leafkit via Swift Package Manager
# In Package.swift, update the dependency:
.package(url: "https://github.com/vapor/leaf-kit.git", from: "1.4.1")

# Then run:
swift package update

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

  • Vulnerability Details
  • TypeXSS

  • Vendor/TechLeafkit

  • SeverityMEDIUM

  • CVSS Score6.1

  • EPSS Probability0.03%

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

  • GitHub Security Advisory GHSA-4hfh-fch3-5q7p
  • Latest CVEs
  • CVE-2025-49454: TinySalt Path Traversal Vulnerability

  • CVE-2025-48261: MultiVendorX Information Disclosure Flaw

  • CVE-2025-32119: CardGate WooCommerce SQL Injection Flaw

  • CVE-2025-26879: s2Member Plugin Reflected XSS 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