CVE-2021-37634: LeafKit allows XSS with untrusted user input

Published Aug 9, 2021
·
Updated

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.

Affected Software

1 affected component
Vapor Leafkit<1.3.0

Remediation

Recommended actions to resolve this vulnerability, in priority order.

  1. Upgrade

    Upgrade Leaf (LeafKit) to a version that resolves this vulnerability.

    Fixed in 1.3.0
  2. Configuration

    Enable a Content Security Policy (CSP) configured to block inline script and inline CSS data to mitigate injected XSS payloads.

    Content Security Policy (CSP) CSP to block inline script and CSS data = Enable CSP that blocks inline script and inline CSS (and CSS data if using `data:`)
  3. Configuration

    Sanitize any untrusted input prior to rendering it in Leaf tags/variable tags, since Leaf previously did not escape strings passed to tags as variables (versions prior to 1.3.0 were susceptible to XSS).

    Leaf (LeafKit) templates Untrusted input sanitization before variable tags = Sanitize any untrusted input before passing it to Leaf variable tags

Event History

Aug 9, 2021
CVE Published
via MITRE·07:45 PM
Data Sourced
via MITRE·07:45 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·08:15 PM
DescriptionSeverityWeaknessAffected Software

Frequently Asked Questions

1

What is CVE-2021-37634?

CVE-2021-37634 is a vulnerability in Leafkit, a templating language with Swift-inspired syntax, that allows for Cross-site Scripting (XSS) attacks.

2

What is the severity of CVE-2021-37634?

The severity of CVE-2021-37634 is high, with a CVSS score of 6.1.

3

How does CVE-2021-37634 affect Leafkit?

CVE-2021-37634 affects Leafkit versions prior to 1.3.0, allowing for XSS attacks when unsanitized data is passed to Leaf's variable tags.

4

How can I fix CVE-2021-37634 in Leafkit?

To fix CVE-2021-37634 in Leafkit, you should upgrade to version 1.3.0 or higher.

5

What is the Common Weakness Enumeration (CWE) ID for CVE-2021-37634?

The CWE ID for CVE-2021-37634 is CWE-79.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203