CVE-2024-45389 Pagefind DOM clobbering could escalate to Cross-site Scripting (XSS)
Attacker with HTML injection capability can escalate to XSS by clobbering script source resolution in Pagefind static search library.
- Exploited in the wild
- Not known
- Login needed
- Any signed-in user
- Attackable
- Over the internet
- Victim action needed
- Not needed
- Fix
- Available
What is CVE-2024-45389?
CVE-2024-45389 is a medium-severity cross-site scripting vulnerability in CloudCannon pagefind, published on 3 Sep 2024. Any signed-in user can exploit it over the network, with no action from the victim.
Official 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.
Weakness: CWE-79
Which versions are affected by CVE-2024-45389?
8 open source packages ship an affected version, including pagefind, @pagefind/default-ui and @pagefind/modular-ui. It affects 1 product.
| Package | Affected | Fixed in |
|---|---|---|
pagefind crates.io | All versions | 1.1.1 |
pagefind crates.io | All versions | 1.1.1 |
pagefind npm | All versions | 1.1.1 |
pagefind npm | All versions | 1.1.1 |
@pagefind/default-ui npm | All versions | 1.1.1 |
@pagefind/default-ui npm | All versions | 1.1.1 |
2 more packages
@pagefind/modular-ui npm | All versions | 1.1.1 |
@pagefind/modular-ui npm | All versions | 1.1.1 |
Products include Pagefind Pagefind.
How do I fix CVE-2024-45389?
Upgrade pagefind to 1.1.1 or later.
Escape output for the context it lands in and set a strict Content Security Policy. Upgrading the affected component is the real fix. More about Cross-site scripting.
Is CVE-2024-45389 being exploited?
It is not confirmed as exploited in the wild, but public exploit code for CVE-2024-45389 exists.
Sources
Also known as GHSA-gprj-6m2f-j9hx.