CVE-2024-41677: @builder.io/qwik Cross-Site Scripting Vulnerability

MODERATE
Advisory Identifier: GHSA-2rwj-7xq8-4gx4
CVSS 6.3
CWE-79
Published
Advisory Summary

CVE-2024-41677 is a MODERATE (CVSS 6.3) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting @builder.io/qwik libraries in the npm ecosystem. The issue involves qwik has a potential mxss vulnerability due to improper html escaping. Remediation is available by upgrading affected packages to version 1.7.3.

CVE-2024-41677 at a Glance

CVE Identifier CVE-2024-41677
GHSA Identifier GHSA-2rwj-7xq8-4gx4
Severity MODERATE
CVSS v3.1 Base Score 6.3
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product @builder.io/qwik
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.3

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

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

How to Fix CVE-2024-41677

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

@builder.io/qwik fixed: 1.7.3
npm install @builder.io/qwik@1.7.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 @builder.io/qwik

How to Check if You Are Affected

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

npm ls @builder.io/qwik

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

Note: The npm ls @builder.io/qwik 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 @builder.io/qwik, 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 A potential mXSS vulnerability exists in Qwik for versions up to 1.6.0. ### Details Qwik improperly escapes HTML on server-side rendering. It converts strings according to the following rules: https://github.com/QwikDev/qwik/blob/v1.5.5/packages/qwik/src/core/render/ssr/render-ssr.ts#L1182-L1208 - If the string is an attribute value: - `"` -> `&quot;` - `&` -> `&amp;` - Other characters -> No conversion - Otherwise: - `<` -> `&lt;` - `>` -> `&gt;` - `&` -> `&amp;` - Other characters -> No conversion It sometimes causes the situation that the final DOM tree rendered on browsers is different from what Qwik expects on server-side rendering. This may be leveraged to perform XSS attacks, and a type of the XSS is known as mXSS (mutation XSS). ## PoC A vulnerable component: ```javascript import { component$ } from "@builder.io/qwik"; import { useLocation } from "@builder.io/qwik-city"; export default component$(() => { // user input const { url } = useLocation(); const href = url.searchParams.get("href") ?? "https://example.com"; return ( <div> <noscript> <a href={href}>test</a> </noscript> </div> ); }); ``` If a user accesses the following URL, ``` http://localhost:4173/?href=</noscript><script>alert(123)</script> ``` then, `alert(123)` will be executed. ### Impact XSS

CVE-2024-41677 Affected @builder.io/qwik Versions

1 component(s)
Fixed Versions:
1.7.3
Product / Package Ecosystem Affected Versions Fixed Version
@builder.io/qwik
npm
< 1.7.3
1.7.3

References

Frequently Asked Questions

What is CVE-2024-41677?
CVE-2024-41677 is a security vulnerability in @builder.io/qwik involving Qwik has a potential mXSS vulnerability due to improper HTML escaping under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which @builder.io/qwik versions are affected?
Affected versions include releases prior to 1.7.3 across affected packages: @builder.io/qwik.
What version fixes CVE-2024-41677?
Upgrading to 1.7.3 (or the latest patched release for your respective branch) resolves the vulnerability.
Is @builder.io/qwik affected?
Yes, @builder.io/qwik is affected in releases prior to 1.7.3. Upgrade your dependency to 1.7.3 or later.
What is the CVSS score of CVE-2024-41677?
CVE-2024-41677 has a CVSS v3.1 base score of 6.3 (MODERATE) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L.
What CWE is associated with CVE-2024-41677?
CVE-2024-41677 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-2024-41677?
Run the dependency tree command: 'npm ls @builder.io/qwik'. 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-2rwj-7xq8-4gx4",
  "modified" : "2024-08-06T18:55:31Z",
  "published" : "2024-08-06T18:24:47Z",
  "aliases" : [ "CVE-2024-41677" ],
  "summary" : "Qwik has a potential mXSS vulnerability due to improper HTML escaping",
  "details" : "### Summary\n\nA potential mXSS vulnerability exists in Qwik for versions up to 1.6.0.\n\n### Details\n\nQwik improperly escapes HTML on server-side rendering. It converts strings according to the following rules:\n\nhttps://github.com/QwikDev/qwik/blob/v1.5.5/packages/qwik/src/core/render/ssr/render-ssr.ts#L1182-L1208\n\n- If the string is an attribute value:\n    - `\"` -> `&quot;`\n    - `&` -> `&amp;`\n    - Other characters -> No conversion\n- Otherwise:\n    - `<` -> `&lt;`\n    - `>` -> `&gt;`\n    - `&` -> `&amp;`\n    - Other characters -> No conversion\n\nIt sometimes causes the situation that the final DOM tree rendered on browsers is different from what Qwik expects on server-side rendering. This may be leveraged to perform XSS attacks, and a type of the XSS is known as mXSS (mutation XSS).\n\n## PoC\n\nA vulnerable component:\n```javascript\nimport { component$ } from \"@builder.io/qwik\";\nimport { useLocation } from \"@builder.io/qwik-city\";\n\nexport default component$(() => {\n  \n  // user input\n  const { url } = useLocation();\n  const href = url.searchParams.get(\"href\") ?? \"https://example.com\";\n\n  return (\n    <div>\n      <noscript>\n        <a href={href}>test</a>\n      </noscript>\n    </div>\n  );\n});\n```\n\nIf a user accesses the following URL,\n```\nhttp://localhost:4173/?href=</noscript><script>alert(123)</script>\n```\nthen, `alert(123)` will be executed.\n\n### Impact\n\nXSS",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:U/C:L/I:L/A:L"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:A/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@builder.io/qwik"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.7.3"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/QwikDev/qwik/security/advisories/GHSA-2rwj-7xq8-4gx4"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-41677"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/QwikDev/qwik/commit/7e742eb3a1001542d795776c0317d47df8b9d64e"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/QwikDev/qwik"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/QwikDev/qwik/blob/v1.5.5/packages/qwik/src/core/render/ssr/render-ssr.ts#L1182-L1208"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-08-06T18:24:47Z",
    "nvd_published_at" : "2024-08-06T18:15:56Z"
  }
}