CVE-2021-37634: Github.com/vapor/leaf kit Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-rv3x-xq3r-8j9h
CWE-80 CWE-79
Published
Advisory Summary

CVE-2021-37634 is a MODERATE cross-site scripting vulnerability (CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)) affecting Github.com/vapor/leaf kit libraries in the SwiftURL ecosystem. The issue involves leafkit allows xss with untrusted user input. Remediation is available by upgrading affected packages to version 1.3.0.

CVE-2021-37634 at a Glance

CVE Identifier CVE-2021-37634
GHSA Identifier GHSA-rv3x-xq3r-8j9h
Severity MODERATE
CVSS v3.1 Base Score N/A
CWE Classification CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS)
Affected Product Github.com/vapor/leaf kit
Package Ecosystem SwiftURL
Published Date
Last Updated

How to Fix CVE-2021-37634

To remediate this vulnerability, upgrade all affected Github.com/vapor/leaf kit dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/vapor/leaf-kit fixed: 1.3.0
Upgrade github.com/vapor/leaf-kit to 1.3.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/vapor/leaf-kit

How to Check if You Are Affected

To determine whether your application is affected by CVE-2021-37634, inspect your project dependencies for Github.com/vapor/leaf kit:

inspect dependencies for github.com/vapor/leaf-kit

Analyze the terminal output to locate any version of Github.com/vapor/leaf kit in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 1.3.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS), where the product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages. In Github.com/vapor/leaf kit, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### 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](https://github.com/vapor/leaf-kit) * Email us at [security@vapor.codes](mailto:security@vapor.codes)

CVE-2021-37634 Affected Github.com/vapor/leaf kit Versions

1 component(s)
Fixed Versions:
1.3.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/vapor/leaf-kit
SwiftURL
< 1.3.0
1.3.0

References

Frequently Asked Questions

What is CVE-2021-37634?
CVE-2021-37634 is a security vulnerability in Github.com/vapor/leaf kit involving LeafKit allows XSS with untrusted user input under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS).
Which Github.com/vapor/leaf kit versions are affected?
Affected versions include releases prior to 1.3.0 across affected packages: github.com/vapor/leaf-kit.
What version fixes CVE-2021-37634?
Upgrading to 1.3.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/vapor/leaf-kit affected?
Yes, github.com/vapor/leaf-kit is affected in releases prior to 1.3.0. Upgrade your dependency to 1.3.0 or later.
What CWE is associated with CVE-2021-37634?
CVE-2021-37634 is classified under CWE-80: Improper Neutralization of Script-Related HTML Tags in a Web Page (Basic XSS) (The product receives input from an upstream component, but it does not neutralize or incorrectly neutralizes special characters such as "<", ">", and "&" that could be interpreted as web-scripting elements when they are sent to a downstream component that processes web pages.).
How can I check SwiftURL dependencies for CVE-2021-37634?
Run the dependency tree command: 'inspect dependencies for github.com/vapor/leaf-kit'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-rv3x-xq3r-8j9h",
  "modified" : "2023-06-09T19:32:32Z",
  "published" : "2023-06-09T19:32:32Z",
  "aliases" : [ "CVE-2021-37634" ],
  "summary" : "LeafKit allows XSS with untrusted user input",
  "details" : "### Impact\nThis 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.\n\n### Patches\nThis has been patched in 1.3.0\n\n### Workarounds\nSanitise any untrusted input before passing it to Leaf and enable a CSP to block inline script and CSS data.\n\n### References\nhttps://github.com/vapor/leaf-kit-ghsa-rv3x-xq3r-8j9h/pull/1\n\n### For more information\nIf you have any questions or comments about this advisory:\n* Open an issue in [Leaf Kit](https://github.com/vapor/leaf-kit)\n* Email us at [security@vapor.codes](mailto:security@vapor.codes)",
  "severity" : [ ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "SwiftURL",
      "name" : "github.com/vapor/leaf-kit"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.3.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/vapor/leaf-kit/security/advisories/GHSA-rv3x-xq3r-8j9h"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2021-37634"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/vapor/leaf-kit"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/vapor/leaf-kit/releases/tag/1.3.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79", "CWE-80" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-06-09T19:32:32Z",
    "nvd_published_at" : "2021-08-09T20:15:00Z"
  }
}