Skip to main content

Boteraser | Website and Server Security Solutions

🛡️ CVE-2026-27120 — leafkit

🟡 CVSS 6.1 — Medium ✅ No Known Exploit CWE-75 NVD
6.1
CVSS Score
0 Low4 Medium7 High9 Critical10

Description

Leaf-kit html escaping does not work on characters that are part of extended grapheme cluster ### 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 ```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 ```
Hover to see message
``` 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.

How this vulnerability can be exploited

This issue can be reached over the network, attack complexity is low, an attacker needs no privileges on the target. A user must be tricked into taking some action. The scope is changed, meaning a successful attack can affect components beyond the vulnerable one. Rated impact: confidentiality low, integrity low, availability none.

CVSS metrics in full

The score comes from this vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N

  • Attack vector: Network — reachable from anywhere that can route to the service.
  • Attack complexity: Low — the attack works reliably, with no preparation.
  • Privileges required: None — an unauthenticated stranger can try it.
  • User interaction: Required — someone has to click, open or visit something.
  • Scope: Changed — a successful attack reaches components beyond the vulnerable one.
  • Confidentiality impact: Low — limited, and the attacker does not choose what is affected.
  • Integrity impact: Low — limited, and the attacker does not choose what is affected.
  • Availability impact: None.

Weakness class

CVE-2026-27120 is classified as CWE-75: Failure to Sanitize Special Elements into a Different Plane (Special Element Injection). The product does not adequately filter user-controlled input for special elements with control implications.

Affected software

CVE-2026-27120 is recorded against 2 packages.

  • github.com/vapor/leaf-kit
  • leafkit (fixed in 1.14.1)

Timeline and source

Published on 19 February 2026 and last revised on 22 April 2026. No public exploit is currently recorded for this entry. A vendor advisory or fix has been published. Record sourced from NVD.

References

github.com (Web)
nvd.nist.gov (Advisory)
github.com (Web)
github.com (Package)

Other advisories for this package

github.com/vapor/leaf-kit has other advisories on record. If you are patching this one, these are worth checking on the same host:

Same weakness in other software

These advisories are the same class of weakness (CWE-75: Failure to Sanitize Special Elements into a Different Plane (Special Element Injection)) in other software:

Details

Severity Medium
CVSS Score 6.1
CVSS Vector CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
CWE CWE-75
Public Exploit ✅ No
Source NVD
Published 2026-02-19
Updated 2026-08-20
Modified 2026-04-22

Affected Packages

Software From version Fixed in
github.com/vapor/leaf-kit — —
leafkit — 1.14.1

Similar Threats

Vulnerability Monitoring

Track new vulnerabilities in leafkit

CVE-2026-27120 is rated CVSS 6.1 Medium. BotEraser monitors your WordPress installation and notifies you when software you use appears in our vulnerability database.

Set Up Free Alerts →

No credit card required  ·  Results in minutes

ⓘ Data Notice: The information presented above has been compiled from publicly available internet sources. Boteraser aggregates this data solely for informational purposes and does not independently classify, evaluate, or endorse any findings about the vulnerabilities listed. The accuracy and completeness of this information is the sole responsibility of the original publishers. Boteraser and its operators accept no liability for any decisions made based on this data.

Browse related advisories

All advisoriesCVECVE 2026
✓