CVE-2026-27120 is a medium-severity (CVSS 6.1) CWE-75 vulnerability in github.com/vapor/leaf-kit. A fix is available for github.com/vapor/leaf-kit — see the affected versions and patch details below.
Leaf-kit html escaping does not work on characters that are part of extended grapheme cluster
Exploitation Status
Proof-of-concept exploit code exists
- CISA’s SSVC triage found public proof-of-concept exploit code for this CVE, though no confirmed active exploitation.
Exploitation and automatability from CISA’s SSVC triage for CVE-2026-27120.
EPSS Exploitation Probability
EPSS (Exploit Prediction Scoring System) is a daily probability model maintained by FIRST.org. It estimates the likelihood a CVE will be exploited in production environments within the next 30 days, derived from real-world threat intelligence signals.
How urgent is this, really
CVE-2026-27120 plotted by exploitation likelihood (EPSS) against impact (CVSS). The shaded corner — EPSS 50%+ and CVSS 7.0+ — is where this CVE doesn't sit, though severity or exploitability alone can still warrant action.
Where this sits among everything scored
Of 378,567 CVEs with a current EPSS score, this one falls in the < 10% band (highlighted). Real counts from FIRST.org, not a sample — log-scaled since the landscape is heavily right-skewed.
Real-World Exposure
github.com/vapor/leaf-kitReal-time download stats are indexed for npm and PyPI packages. This vulnerability affects SwiftURL packages — download data is not available via public APIs for these ecosystems.
Description
Summary
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.
Details
Relevant code: https://github.com/vapor/leaf-kit/blob/main/Sources/LeafKit/String%2BHTMLEscape.swift#L14
Strings in Swift are based on extended grapheme clusters. HTML on the other hand is based on unicode characters.
For example if you have the sequence "́ (U+0022 Quotation mark followed by U+0301 Combining Acute Accent). To HTML this is just a quote mark followed by some other random character. To swift this is one extended grapheme cluster that does not equal a quotation mark by itself which is a different extended grapheme cluster.
Thus "\"́".replacingOccurrences(of: "\"", with: """) does not replace the quote mark. This allows you to break out of html attributes.
I believe replacingOccurences takes an optional third parameter that allows you to specify options to make it work on UTF-8 characters instead of grapheme clusters, which would be a good fix for this issue.
I see depending on version, leafkit might use replacing instead of replacingOccurences. I don't know swift that well and couldn't find docs on what replacing does, so I don't know if both versions of the function are affected. The version of swift i was testing on I believe was using replacingOccurences
It seems like replacingOccurences will skip past prefix characters of extended grapheme clusters, which is what would be needed in order to meaningfully bypass esaping of <. Thus i think this is mostly limited to attributes and not general text.
PoC
An example vapor application that is vulnerable might look like
routes.swift
import Vapor
struct Hello: Content {
var msg: String?
}
func routes(_ app: Application) throws {
app.post { req throws in
let Hello = try req.content.decode(Hello.self)
return req.view.render("hello", [
"msg": Hello.msg ?? "Hello World!"
])
}
}
With a hello.leaf that looks like
<div title="#(msg)">Hover to see message</div>
And then you POST something like msg=%22%cc%81=1%20autofocus%20tabindex=0%20onfocus=alert(1)%20
Impact
If a website uses leaf to escape an attribute value based on user input, the attacker may be able to insert a malicious attribute. If a site is not using a secure CSP policy, then this can be used to execute malicious javascript (XSS). Impact is context dependent if a site is using a secure CSP policy.
Affected Packages
| Ecosystem | Package | Vulnerable range | Fix |
|---|---|---|---|
| 📦SwiftURL | github.com/vapor/leaf-kit | all versions | 1.4.1 |
Detection & mitigation playbook
Open-source dependencyDetect
Scan your dependency tree (package-lock.json, pnpm-lock.yaml, requirements.txt, go.sum, etc.) for github.com/vapor/leaf-kit, including transitive dependencies — a direct dependency you never call can still pull in a vulnerable version.
Fix
Update github.com/vapor/leaf-kit to 1.4.1 or later, then make sure no transitive (indirect) dependency still pins the vulnerable range — O3 confirms CVE-2026-27120 is resolved across your whole dependency graph.
Workarounds
If you can't upgrade right away: gate or disable the affected feature, validate untrusted input at the boundary, and avoid passing attacker-controlled data into the vulnerable path. O3's runtime protection blocks exploitation in production as an interim safeguard until the upgrade lands.
How O3 protects you
O3 Security's impact-aware SCA analyses which vulnerable code paths your application actually calls, so a match like CVE-2026-27120 can be triaged on real exposure rather than presence alone.
Tailored to CVE-2026-27120. Runtime protection reduces exposure until a permanent patch is applied and verified — it complements patching, it doesn't replace it.
Frequently Asked Questions
Is CVE-2026-27120 in your dependencies?
O3 Security finds CVE-2026-27120 across SwiftURL dependencies, including transitive ones, and its impact-aware SCA ranks findings by whether your code actually calls the vulnerable path.