CVE-2026-27120 Leaf-kit html escaping does not work on characters that are part of extended grapheme cluster

Medium 6.1 Published Updated

Attackers can bypass HTML escaping in Leaf-kit using extended grapheme clusters to inject scripts, leading to XSS in web applications using this library.

Exploited in the wild
Not known
Login needed
Not needed
Attackable
Over the internet
Victim action needed
A user has to click or open something
Fix
Available

What is CVE-2026-27120?

CVE-2026-27120 is a medium-severity cross-site scripting vulnerability in vapor leaf-kit, published on 20 Feb 2026. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

Official description

Leafkit is a templating language with Swift-inspired syntax. Prior to 1.4.1, htmlEscaped in leaf-kit will only escape html special characters if the extended grapheme clusters match, which allows bypassing escaping by using an extended grapheme cluster containing both the special html character and some additional characters. In the case of html attributes, this can lead to XSS if there is a leaf variable in the attribute that is user controlled. This vulnerability is fixed in 1.4.1.

Weakness: CWE-87, CWE-79, CWE-75

Which versions are affected by CVE-2026-27120?

2 open source packages ship an affected version, including github.com/vapor/leaf-kit. It affects 1 product.

PackageAffectedFixed in
github.com/vapor/leaf-kit SwiftURLAll versions1.4.1
github.com/vapor/leaf-kit SwiftURLAll versions1.4.1

Products include Vapor Leafkit.

How do I fix CVE-2026-27120?

Upgrade github.com/vapor/leaf-kit to 1.4.1 or later.

Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.

Is CVE-2026-27120 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2026-27120 exists.

Sources

Also known as GHSA-4hfh-fch3-5q7p.

Is CVE-2026-27120 in your software?

Upload an SBOM and sbomify checks it against every vulnerability here, every day.

Check your SBOMs for free