# Grav stored XSS bypass via invalid UTF-8 byte in detectXss()

Source: https://junglewise.ai/threats/grav-stored-xss-bypass-via-invalid-utf-8-byte-in-detectxss-91166cf8  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-08-18. Updated: 2026-09-25  
License: CC BY 4.0 with a link back

Severity: medium · CVSS 5.4 · Published 2026-08-18

Grav is an open-source flat-file CMS used to build and manage websites. A vulnerability in its XSS detection function allows an authenticated page editor to bypass the security checks by inserting a single invalid UTF-8 byte into page content, enabling them to inject malicious JavaScript that executes when site visitors view the affected page.

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

## Quick answers

**Is This vulnerability exploited in the wild?** No. Junglewise Threat Intelligence has no report of This vulnerability being exploited in the wild.

**How severe is This vulnerability?** Medium severity, with a CVSS score of 5.4, published 18 August 2026.

**Which products and versions are affected?** getgrav/grav (Packagist) < 2.0.14.

**Is there a fix for This vulnerability?** A patch was published on 2026-08-03: Patch available in version 2.0.14 Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is This vulnerability attacked?** It is attacked over the network, in a web application.

**Am I affected?** Check whether you run 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.

## Technical details

The vulnerability exists in Security::detectXss() in system/src/Grav/Common/Security.php. All XSS detection regex patterns use the PCRE /u (UTF-8) modifier; when preg_match() encounters even one invalid UTF-8 byte sequence in the input, it returns false for the entire call instead of attempting to match the pattern. Since detectXss() only checks truthiness of the return value, a single malformed UTF-8 byte silently causes all six XSS checks to fail. An authenticated attacker with page-edit permissions (without security.xss_whitelist privilege) can inject an invalid UTF-8 byte anywhere in the page content alongside malicious JavaScript, bypassing both the save-time Validation::checkSafety() gate and the render-time detectXssInEditorContent() backstop. The browser normalizes the invalid byte to U+FFFD and executes the stored XSS payload normally. A patch is available in version 2.0.14.

## Affected products

- Getgrav Grav < 2.0.14

## Timeline

- 2026-08-03: disclosed
- 2026-08-18: advisory
- 2026-08-03: patched: Patch available in version 2.0.14

## References

- [https://github.com/getgrav/grav/security/advisories/GHSA-q2j8-x8hf-63ch](https://github.com/getgrav/grav/security/advisories/GHSA-q2j8-x8hf-63ch)

## Related threats

- [Grav cross-site scripting in Twig sandbox asset methods](https://junglewise.ai/threats/cve-2026-86197-grav-cross-site-scripting-in-twig-sandbox-asset-methods)
- [Grav Twig sandbox config exfiltration via offsetGet and dump filters](https://junglewise.ai/threats/cve-2026-61842-grav-twig-sandbox-config-exfiltration-via-offsetget-and-dump)
- [Grav ZipArchiver decompression bomb via missing extraction limits](https://junglewise.ai/threats/cve-2026-61690-grav-ziparchiver-decompression-bomb-via-missing-extraction-limits)
- [Grav incomplete Twig sandbox denylist information disclosure](https://junglewise.ai/threats/grav-incomplete-twig-sandbox-denylist-information-disclosure-e903bd3b)
- [Grav UserInterface offsetGet/offsetExists Twig sandbox bypass](https://junglewise.ai/threats/grav-userinterface-offsetget-offsetexists-twig-sandbox-bypass-f709468e)
