CVE-2023-38687: Svelecte Svelecte Item Names Vulnerable To Vulnerability

MODERATE
Advisory Identifier: GHSA-7h45-grc5-89wq
CVSS 5.4
CWE-79
Published
Advisory Summary

CVE-2023-38687 is a MODERATE (CVSS 5.4) svelecte item names vulnerable to vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Svelecte libraries in the npm ecosystem. The issue involves svelecte item names vulnerable to execution of arbitrary javascript. Remediation is available by upgrading affected packages to version 3.16.3.

CVE-2023-38687 at a Glance

CVE Identifier CVE-2023-38687
GHSA Identifier GHSA-7h45-grc5-89wq
Severity MODERATE
CVSS v3.1 Base Score 5.4
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Svelecte
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 5.4

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2023-38687

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

svelecte fixed: 3.16.3
npm install svelecte@3.16.3
Verify Direct and Transitive Dependencies

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

npm ls svelecte

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2023-38687, inspect your project dependencies using npm:

npm ls svelecte

Analyze the terminal output to locate any version of Svelecte in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.16.3), your application is affected.

Note: The npm ls svelecte command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In Svelecte, 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

### Summary Svelecte item names are rendered as raw HTML with no escaping. This allows the injection of arbitrary HTML into the Svelecte dropdown. This can be exploited to execute arbitrary JavaScript whenever a Svelecte dropdown is opened. ### Details Item names given to Svelecte appear to be directly rendered as HTML by the default item renderer. This means that any HTML tags in the name are rendered as HTML elements not as text. Note that the custom item renderer shown in https://mskocik.github.io/svelecte/#item-rendering is also vulnerable to the same exploit. To prevent this all special HTML characters in item names should be escaped (for example using `document.createTextNode()`). ### PoC ```svelte <script> import Svelecte from 'svelecte'; const list = [ { id: 1, name: `Item 1` }, { id: 2, name: `Item 2<img style="display:none;" src=1 onerror="alert('JavaScript executed!');"/>` }, { id: 3, name: 'Item 3'} ]; </script> <Svelecte options={list}></Svelecte> ``` This code snippet demonstrates how the vulnerability can be used to execute arbitrary JavaScript without the user's knowledge when the Svelecte dropdown is opened (note that visually item 2 appears identical to other items). In this case the script is hardcoded, but in practice the real danger is that some applications may use Svelecte with items that are created by users or come from low-trust sources where someone else could add a malicious script to the item name. ### Impact Any site that uses Svelecte with dynamically created items either from an external source or from user-created content could be vulnerable to an XSS attack (execution of untrusted JavaScript), clickjacking or any other attack that can be performed with arbitrary HTML injection. The actual impact of this vulnerability for a specific application depends on how trustworthy the sources that provide Svelecte items are and the steps that the application has taken to mitigate XSS attacks. XSS attacks using this vulnerability are mostly mitigated by a Content Security Policy that blocks inline JavaScript.

CVE-2023-38687 Affected Svelecte Versions

1 component(s)
Fixed Versions:
3.16.3
Product / Package Ecosystem Affected Versions Fixed Version
svelecte
npm
< 3.16.3
3.16.3

References

Frequently Asked Questions

What is CVE-2023-38687?
CVE-2023-38687 is a security vulnerability in Svelecte involving Svelecte item names vulnerable to execution of arbitrary JavaScript under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Svelecte versions are affected?
Affected versions include releases prior to 3.16.3 across affected packages: svelecte.
What version fixes CVE-2023-38687?
Upgrading to 3.16.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is svelecte affected?
Yes, svelecte is affected in releases prior to 3.16.3. Upgrade your dependency to 3.16.3 or later.
What is the CVSS score of CVE-2023-38687?
CVE-2023-38687 has a CVSS v3.1 base score of 5.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2023-38687?
CVE-2023-38687 is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check npm dependencies for CVE-2023-38687?
Run the dependency tree command: 'npm ls svelecte'. 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-7h45-grc5-89wq",
  "modified" : "2023-08-14T21:14:08Z",
  "published" : "2023-08-14T21:14:08Z",
  "aliases" : [ "CVE-2023-38687" ],
  "summary" : "Svelecte item names vulnerable to execution of arbitrary JavaScript",
  "details" : "### Summary\n\nSvelecte item names are rendered as raw HTML with no escaping. This allows the injection of arbitrary HTML into the Svelecte dropdown. This can be exploited to execute arbitrary JavaScript whenever a Svelecte dropdown is opened.\n\n### Details\n\nItem names given to Svelecte appear to be directly rendered as HTML by the default item renderer. This means that any HTML tags in the name are rendered as HTML elements not as text.\n\nNote that the custom item renderer shown in https://mskocik.github.io/svelecte/#item-rendering is also vulnerable to the same exploit.\n\nTo prevent this all special HTML characters in item names should be escaped (for example using `document.createTextNode()`).\n\n### PoC\n```svelte\n<script>\n    import Svelecte from 'svelecte';\n    \n    const list = [\n        { id: 1, name: `Item 1` },\n        { id: 2, name: `Item 2<img style=\"display:none;\" src=1 onerror=\"alert('JavaScript executed!');\"/>` },\n        { id: 3, name: 'Item 3'}\n    ];\n</script>\n    \n<Svelecte options={list}></Svelecte>\n```\n\nThis code snippet demonstrates how the vulnerability can be used to execute arbitrary JavaScript without the user's knowledge when the Svelecte dropdown is opened (note that visually item 2 appears identical to other items).\nIn this case the script is hardcoded, but in practice the real danger is that some applications may use Svelecte with items that are created by users or come from low-trust sources where someone else could add a malicious script to the item name.\n\n### Impact\n\nAny site that uses Svelecte with dynamically created items either from an external source or from user-created content could be vulnerable to an XSS attack (execution of untrusted JavaScript), clickjacking or any other attack that can be performed with arbitrary HTML injection.\nThe actual impact of this vulnerability for a specific application depends on how trustworthy the sources that provide Svelecte items are and the steps that the application has taken to mitigate XSS attacks. XSS attacks using this vulnerability are mostly mitigated by a Content Security Policy that blocks inline JavaScript.\n",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "svelecte"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.16.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/mskocik/svelecte/security/advisories/GHSA-7h45-grc5-89wq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2023-38687"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/mskocik/svelecte"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2023-08-14T21:14:08Z",
    "nvd_published_at" : "2023-08-14T21:15:12Z"
  }
}