Vulnerabilities in pkg:npm/pagefind

PACKAGE
Advisory Identifier: GHSA-gprj-6m2f-j9hx
Advisory Summary

CVE-2024-45389 is a MODERATE (CVSS 6.4) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Pagefind libraries in the npm ecosystem. The issue involves dom clobbering could escalate to cross-site scripting (xss). Remediation is available by upgrading affected packages to version 1.1.1.

1 Known Advisory Record(s)
Package Vulnerability Intelligence

pkg:npm/pagefind

1 Known Advisory Record(s)

Vulnerability advisories affecting package pkg:npm/pagefind. Select an advisory below to view technical details or fixes.

Advisory ID CVE / NVD Severity Summary
GHSA-gprj-6m2f-j9hx CVE-2024-45389 MODERATE DOM clobbering could escalate to Cross-site Scripting (XSS)

CVE-2024-45389 at a Glance

CVE Identifier CVE-2024-45389
GHSA Identifier GHSA-gprj-6m2f-j9hx
Severity MODERATE
CVSS v3.1 Base Score 6.4
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Pagefind
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.4

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

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

How to Fix CVE-2024-45389

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

pagefind fixed: 1.1.1
npm install pagefind@1.1.1
@pagefind/default-ui fixed: 1.1.1
npm install @pagefind/default-ui@1.1.1
@pagefind/modular-ui fixed: 1.1.1
npm install @pagefind/modular-ui@1.1.1
pagefind fixed: 1.1.1
Upgrade pagefind to 1.1.1
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 pagefind

How to Check if You Are Affected

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

npm ls pagefind

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

Note: The npm ls pagefind 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 Pagefind, 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

Pagefind initializes its dynamic JavaScript and WebAssembly files relative to the location of the first script you load. This information is gathered by looking up the value of `document.currentScript.src`. It is possible to "clobber" this lookup with otherwise benign HTML on the page, for example: ```html <img name="currentScript" src="blob:https://xxx.xxx.xxx/ui.js"></img> ``` This will cause `document.currentScript.src` to resolve as an external domain, which will then be used by Pagefind to load dependencies. This exploit would only work in the case that an attacker could inject HTML to your live, hosted, website. In these cases, this would act as a way to escalate the privilege available to an attacker. This assumes they have the ability to add some elements to the page (for example, `img` tags with a `name` attribute), but not others, as adding a `script` to the page would itself be the XSS vector. Pagefind has tightened this resolution by ensuring the source is loaded from a valid script element. There are no reports of this being exploited in the wild via Pagefind. ### Original Report If an attacker can inject benign html, such as: `<img name="currentScript" src="blob:https://xxx.xxx.xxx/ui.js"></img>` they can clobber `document.currentScript.src` leading to XSS in your library. Here is the same attack on webpack that was accepted: https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986

CVE-2024-45389 Affected Pagefind Versions

4 component(s)
Fixed Versions:
1.1.1
Product / Package Ecosystem Affected Versions Fixed Version
pagefind
npm
< 1.1.1
1.1.1
@pagefind/default-ui
npm
< 1.1.1
1.1.1
@pagefind/modular-ui
npm
< 1.1.1
1.1.1
pagefind
crates.io
< 1.1.1
1.1.1

References

Frequently Asked Questions

What is CVE-2024-45389?
CVE-2024-45389 is a security vulnerability in Pagefind involving DOM clobbering could escalate to Cross-site Scripting (XSS) under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Pagefind versions are affected?
Affected versions include releases prior to 1.1.1 across affected packages: pagefind, @pagefind/default-ui, @pagefind/modular-ui.
What version fixes CVE-2024-45389?
Upgrading to 1.1.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is pagefind affected?
Yes, pagefind is affected in releases prior to 1.1.1. Upgrade your dependency to 1.1.1 or later.
Is @pagefind/default-ui affected?
Yes, @pagefind/default-ui is affected in releases prior to 1.1.1. Upgrade your dependency to 1.1.1 or later.
What is the CVSS score of CVE-2024-45389?
CVE-2024-45389 has a CVSS v3.1 base score of 6.4 (MODERATE) with vector string CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H.
What CWE is associated with CVE-2024-45389?
CVE-2024-45389 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-45389?
Run the dependency tree command: 'npm ls pagefind'. 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-gprj-6m2f-j9hx",
  "modified" : "2024-09-12T21:38:09Z",
  "published" : "2024-09-03T19:33:36Z",
  "aliases" : [ "CVE-2024-45389" ],
  "summary" : "DOM clobbering could escalate to Cross-site Scripting (XSS)",
  "details" : "Pagefind initializes its dynamic JavaScript and WebAssembly files relative to the location of the first script you load. This information is gathered by looking up the value of `document.currentScript.src`.\n\nIt is possible to \"clobber\" this lookup with otherwise benign HTML on the page, for example:\n```html\n<img name=\"currentScript\" src=\"blob:https://xxx.xxx.xxx/ui.js\"></img>\n```\n\nThis will cause `document.currentScript.src` to resolve as an external domain, which will then be used by Pagefind to load dependencies.\n\nThis exploit would only work in the case that an attacker could inject HTML to your live, hosted, website. In these cases, this would act as a way to escalate the privilege available to an attacker. This assumes they have the ability to add some elements to the page (for example, `img` tags with a `name` attribute), but not others, as adding a `script` to the page would itself be the XSS vector.\n\nPagefind has tightened this resolution by ensuring the source is loaded from a valid script element. There are no reports of this being exploited in the wild via Pagefind.\n\n### Original Report\n\nIf an attacker can inject benign html, such as:\n`<img name=\"currentScript\" src=\"blob:https://xxx.xxx.xxx/ui.js\"></img>`\n\nthey can clobber `document.currentScript.src` leading to XSS in your library.\n\nHere is the same attack on webpack that was accepted: https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H"
  }, {
    "type" : "CVSS_V4",
    "score" : "CVSS:4.0/AV:N/AC:L/AT:P/PR:L/UI:N/VC:L/VI:L/VA:H/SC:N/SI:N/SA:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "npm",
      "name" : "pagefind"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pagefind/default-ui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "npm",
      "name" : "@pagefind/modular-ui"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "crates.io",
      "name" : "pagefind"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "1.1.1"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/CloudCannon/pagefind/security/advisories/GHSA-gprj-6m2f-j9hx"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/webpack/webpack/security/advisories/GHSA-4vvj-4cpr-p986"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2024-45389"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/CloudCannon/pagefind/commit/14ec96864eabaf1d7d809d5da0186a8856261eeb"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/CloudCannon/pagefind"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "MODERATE",
    "github_reviewed" : true,
    "github_reviewed_at" : "2024-09-03T19:33:36Z",
    "nvd_published_at" : "2024-09-03T20:15:08Z"
  }
}