# CVE-2026-42612: getgrav Grav stored XSS in detectXss function

Source: https://junglewise.ai/threats/cve-2026-42612-getgrav-grav-stored-xss-in-detectxss-function  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-05-11. Updated: 2026-05-13  
License: CC BY 4.0 with a link back

CVE-2026-42612 · Severity: high · CVSS 8.5 · Published 2026-05-11

Grav, a popular flat-file content management system, is vulnerable to a security flaw that allows users with publisher-level access to inject malicious scripts into website content. These scripts are executed in the browsers of other users, including administrators, when they view the affected pages. This could lead to unauthorized actions, theft of login sessions, or full compromise of administrative accounts.

Technologies: [Grav](https://junglewise.ai/threats/technologies/grav), [getgrav/grav (Packagist)](https://junglewise.ai/threats/technologies/getgrav-grav). Vendors: [Grav](https://junglewise.ai/threats/vendors/grav), [Packagist](https://junglewise.ai/threats/vendors/packagist).

## Quick answers

**Is CVE-2026-42612 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-42612 being exploited in the wild.

**How severe is CVE-2026-42612?** High severity, with a CVSS score of 8.5, published 11 May 2026.

**Which products and versions are affected?** Grav < 2.0.0-beta.2; getgrav/grav (Packagist) < 2.0.0-beta.2, ECOSYSTEM:introduced=0,fixed=2.0.0-beta.2.

**Is there a fix for CVE-2026-42612?** Yes. getgrav/grav (Packagist): upgrade to 2.0.0-beta.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-42612 attacked?** It is attacked over the network, in a web application.

**Am I affected by CVE-2026-42612?** Check whether you run Grav or getgrav/grav (Packagist) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- getgrav/grav (Packagist): upgrade to 2.0.0-beta.2 or later

  ```sh
  composer require getgrav/grav:^2.0.0-beta.2
  ```


## Technical details

A stored Cross-Site Scripting (XSS) vulnerability exists in Grav's `detectXss()` function within `system/src/Grav/Common/Security.php`. The root cause is a flawed regular expression used to identify `on*` event handlers; the pattern specifically expects whitespace or quotes around the equals sign (e.g., `onerror=`). By using unquoted attributes (e.g., `<img src=x onerror=alert(1)>`), an attacker with publisher-level privileges can bypass the filter. This allows for the execution of arbitrary JavaScript in the context of any user viewing the content. The vulnerability has been addressed in version 2.0.0-beta.2 by updating the regex to flag any `on*=` attribute regardless of surrounding characters.

## Affected products

- getgrav Grav < 2.0.0-beta.2

## Identifiers

- CVE-2026-42612
- GHSA-9695-8fr9-hw5q

## Timeline

- 2026-04-24: patched: Fix applied to Grav core 2.0 branch.
- 2026-04-27: disclosed: Advisory published by maintainer.
- 2026-05-05: advisory: GitHub Advisory published.
- 2026-05-11: other: NVD published.

## References

- [https://api.github.com/users/KC1zs4](https://api.github.com/users/KC1zs4)
- [https://github.com/KC1zs4](https://github.com/KC1zs4)
- [https://api.github.com/users/KC1zs4/gists%7B/gist_id%7D](https://api.github.com/users/KC1zs4/gists%7B/gist_id%7D)
- [https://api.github.com/users/KC1zs4/repos](https://api.github.com/users/KC1zs4/repos)
- [https://avatars.githubusercontent.com/u/143268500?v=4](https://avatars.githubusercontent.com/u/143268500?v=4)
- [https://api.github.com/users/KC1zs4/events%7B/privacy%7D](https://api.github.com/users/KC1zs4/events%7B/privacy%7D)

## Related threats

- [Grav allowlist bypass in Flex form processing](https://junglewise.ai/threats/cve-2026-116019-grav-2-0-15-before-2-2-13-contains-an-allowlist-bypass)
- [Grav improper access control in FlexDirectory::dynamicFlexField()](https://junglewise.ai/threats/cve-2026-114660-grav-from-2-0-0-before-2-2-5-contains-an-improper-access-control)
- [Grav information disclosure via Twig HTTP Basic credentials](https://junglewise.ai/threats/cve-2026-114657-grav-from-2-0-0-before-2-2-5-contains-an-information-disclosure)
- [Grav image pixel limit bypass allows resource exhaustion](https://junglewise.ai/threats/cve-2026-112782-grav-1-7-53-before-1-7-53-5-and-2-0-0-rc-8-before-2-2-2-contains)
- [Grav information disclosure via nested Git repositories](https://junglewise.ai/threats/cve-2026-109326-grav-before-2-1-7-contains-an-information-disclosure)
