CVE-2024-45389
Medium · 5.4CVSS
5.4
EPSS
0.4%
Published
Sep 3, 2024
CISA due date
—
Cloudanix analysis
A search feature on websites could be tricked into loading code from the wrong place if someone is already able to add certain types of content to the page, giving them more control than they should have.
- Exploitation
- Requires User Interaction
- Attacker needs
- User Interaction
- Complexity
- Moderate
- Impact
- Privilege Gain
- Component
- Library
- Class
- XSS
- Remediation
- Upgrade
- Effort
- Low
- Patch risk
- Low
What it actually does
The vulnerability allows an attacker with partial HTML injection capability to manipulate document.currentScript.src lookup, causing Pagefind to resolve and load its JavaScript and WebAssembly dependencies from an attacker-controlled external domain instead of the intended location.
Why it matters to the business
Organizations hosting sites that use Pagefind face increased risk of client-side code execution attacks if an attacker can already inject limited HTML, potentially leading to unauthorized access to user data or site functionality on production websites.
How an attack unfolds
An attacker who can inject benign HTML elements such as img tags with a name attribute on a live site uses this to clobber the script source resolution performed by Pagefind. This causes the library to fetch its dynamic files from a malicious domain, escalating the attacker's privileges to full script execution without directly adding a script tag.
How to fix it
Upgrade Pagefind to version 1.1.1 or later (commit 70012fba86ca51bf1f476c3c64d840a81c60e9cb) to enforce loading only from a valid script element. For Debian packages, update webkit2gtk to version 2.22.0-2 or newer on affected releases.
How to confirm the fix worked
Verify the deployed Pagefind version is 1.1.1 or higher and inspect the initialization code to confirm it validates the script element before resolving the source URL. Test by attempting HTML clobbering on a staging site and confirming dependencies load only from the expected origin.
Typical attack path
- Identify a page using Pagefind on a target site
- Inject HTML elements with name attributes that interfere with document.currentScript.src resolution
- Trigger Pagefind initialization
- Force loading of Pagefind dependencies from attacker-controlled domain
- Execute arbitrary JavaScript in the victim's browser context
How to detect it
Examine web server and application logs for unexpected external domains in script requests during Pagefind initialization. Review page source and rendered HTML for suspicious img or other elements with name attributes near search script includes. No known in-the-wild exploitation has been reported.
What your security team should do
- Prioritize upgrade of all Pagefind instances to 1.1.1 or later within standard change windows
- Review sites for any HTML injection vectors that could enable this escalation
- Monitor for unusual external script loads originating from Pagefind initialization
- Apply the fix even on low-EPSS vulnerabilities when the library processes untrusted page content
The record
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 packages
| Ecosystem | Package | Introduced | Fixed |
|---|---|---|---|
| crates.io | pagefind | 0 | 1.1.1 |
| npm | @pagefind/default-ui | 0 | 1.1.1 |
| npm | @pagefind/modular-ui | 0 | 1.1.1 |
| npm | pagefind | 0 | 1.1.1 |
| npm | vite | 0 | 3.2.11 |
| npm | vite | 4.0.0 | 4.5.4 |
| npm | vite | 5.0.0 | 5.1.8 |
| npm | vite | 5.0.0 | 5.2.14 |
| npm | vite | 5.2.0 | 5.2.14 |
| npm | vite | 5.3.0 | 5.3.6 |
| npm | vite | 5.4.0 | 5.4.6 |
| npm | webpack | 5.0.0-alpha.0 | 5.94.0 |
| Debian:11 | node-webpack | 0 | No fix |
| Debian:12 | node-webpack | 0 | No fix |
| Debian:13 | node-webpack | 0 | 5.94.0+dfsg1+~cs11.18.26-2 |
| Debian:14 | node-webpack | 0 | 5.94.0+dfsg1+~cs11.18.26-2 |
Related vulnerabilities
- CVE-2024-45812 Vite a frontend build tooling framework for javascript. Same vulnerability
- CVE-2026-53571 Vite is a frontend tooling framework for JavaScript. Also affects vite
- CVE-2026-53632 launch-editor allows users to open files with line numbers in editor from Node.js. Also affects vite
- GHSA-v6wh-96g9-6wx3 launch-editor: NTLMv2 hash disclosure via UNC path handling on Windows Also affects vite
- GHSA-fx2h-pf6j-xcff vite: `server.fs.deny` bypass on Windows alternate paths Also affects vite
- GHSA-c27g-q93r-2cwf launch-editor vulnerable to command injection via the crafted request on Windows Also affects vite
- CVE-2024-52011 launch-editor allows users to open files with line numbers in editor from Node.js. Also affects vite
- CVE-2026-39363 Vite is a frontend tooling framework for JavaScript. Also affects vite