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 package | Versions | Reported by |
|---|---|---|
| vapor leaf-kit | < 1.3.0 | CVE List |
| github.com/vapor/leaf-kit (SwiftURL) | before 1.3.0 | GitHub Advisory Database |
| vapor leafkit | before 1.3.0 | NVD |
All scores
| GitHub_M | 7.4high CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:H/I:N/A:N |
| GitHub | medium rating | |
| NVD | 6.1medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N |
| NVD | 4.3medium CVSS:2.0 | AV: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:
- Open an issue in Leaf Kit
- Email us at security@vapor.codes
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
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2021-37634 changed 2024-08-04 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-rv3x-xq3r-8j9h changed 2026-07-08 | CC-BY-4.0 |
| NVD | CVE-2021-37634 changed 2026-06-17 | Public domain |