CVE-2021-37634 LeafKit allows XSS with untrusted user input
Attackers can inject malicious scripts into web pages via unsanitized user input in LeafKit templates, potentially compromising user sessions.
- 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-2021-37634?
CVE-2021-37634 is a high-severity cross-site scripting vulnerability in vapor leaf-kit, published on 9 Aug 2021. 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. Versions prior to 1.3.0 are susceptible to Cross-site Scripting (XSS) attacks. This affects anyone passing unsanitised data to Leaf's variable tags. Before this fix, Leaf would not escape any strings passed to tags as variables. If an attacker managed to find a variable that was rendered with their unsanitised data, they could inject scripts into a generated Leaf page, which could enable XSS attacks if other mitigations such as a Content Security Policy were not enabled. This has been patched in 1.3.0. As a workaround sanitize any untrusted input before passing it to Leaf and enable a CSP to block inline script and CSS data.
Weakness: CWE-79
Which versions are affected by CVE-2021-37634?
2 open source packages ship an affected version, including github.com/vapor/leaf-kit. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
github.com/vapor/leaf-kit SwiftURL | All versions | 1.3.0 |
github.com/vapor/leaf-kit SwiftURL | All versions | 1.3.0 |
Products include Vapor Leafkit.
How do I fix CVE-2021-37634?
Upgrade github.com/vapor/leaf-kit to 1.3.0 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-2021-37634 being exploited?
There is no known exploitation of CVE-2021-37634 in the wild and no public exploit code.
Other vulnerabilities in vapor leaf-kit
Sources
Also known as GHSA-rv3x-xq3r-8j9h.