CVE-2021-37634
JSON

7.4high

LeafKit allows XSS with untrusted user input

Severity
7.4high CVSS:3.1 by GitHub_M
Exploit likelihood
0.71% (higher than 54% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M
Also known as
GHSA-rv3x-xq3r-8j9h

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.

Affected

Product or packageVersionsReported by
vapor leaf-kit< 1.3.0CVE List
github.com/vapor/leaf-kit (SwiftURL)before 1.3.0GitHub Advisory Database
vapor leafkitbefore 1.3.0NVD

All scores

GitHub_M7.4high CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N
GitHubmedium rating
NVD6.1medium CVSS:3.1CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
NVD4.3medium CVSS:2.0AV:N/AC:M/Au:N/C:N/I:P/A:N

Classification

What each source says

CVE List

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.

GitHub Advisory Database
Impact

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.

Patches

This has been patched in 1.3.0

Workarounds

Sanitise any untrusted input before passing it to Leaf and enable a CSP to block inline script and CSS data.

References

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

For more information

If you have any questions or comments about this advisory:

NVD (es)

Leafkit es un lenguaje de plantillas con una sintaxis inspirada en Swift. Las versiones anteriores a 1.3.0, son susceptibles de sufrir ataques de tipo Cross-site Scripting (XSS). Esto afecta a cualquiera que pase datos no saneados a las etiquetas variables de Leaf. Antes de esta corrección, Leaf no escapaba las cadenas pasadas a las etiquetas como variables. Si un atacante lograba encontrar una variable que se presentara con sus datos no saneados, podía inyectar scripts en una página de Leaf generada, que podía permitir ataques de tipo XSS si no se habilitaban otras mitigaciones como una Política de Seguridad de Contenidos. Esto ha sido parcheado en versión 1.3.0. Como solución, sanear cualquier entrada no confiable antes de pasarla a Leaf y habilitar una CSP para bloquear los datos de script y CSS en línea

References

Sources

SourceRecordLicence
CVE ListCVE-2021-37634 changed 2024-08-04CVE Terms of Use
GitHub Advisory DatabaseGHSA-rv3x-xq3r-8j9h changed 2026-07-08CC-BY-4.0
NVDCVE-2021-37634 changed 2026-06-17Public domain