Grav CMS Vulnerability CVE-2026-86197 Could Allow Page Editors to Inject Malicious Scripts
A newly disclosed security vulnerability in the Grav CMS could allow users with page-editing privileges to inject malicious JavaScript into websites, potentially leading to attacks against administrators.
Tracked as CVE-2026-86197, the vulnerability is a cross-site scripting (XSS) flaw affecting Grav versions before 2.0.20. Security researchers have rated it Medium severity, with a CVSS 3.1 score of 5.4.
What is the problem?
The vulnerability is located in Grav’s Twig content sandbox. The sandbox is designed to restrict what Twig code contained within page content can do.
However, the affected versions allowed the addJs and addCss methods of Grav’s Assets component. A user who has permission to edit pages could abuse these methods to register an attacker-controlled JavaScript or stylesheet asset.
The resulting asset could then be inserted into the webpage’s HTML without appropriate escaping, creating an XSS condition.
Importantly, the attack does not require the user to have full Twig permissions. According to the security advisory, ordinary page-editing privileges can be sufficient.
Potential impact
An attacker able to exploit the vulnerability could inject JavaScript that executes in the browser of people viewing the affected page.
The vulnerability is particularly concerning for Grav installations where users with different levels of access can create or modify website content. A malicious page editor could potentially use the flaw as part of an attack against higher-privileged users, including administrators.
The issue is classified as CWE-79, covering improper neutralisation of input during web page generation, commonly known as cross-site scripting.
Grav 2.0.20 fixes the vulnerability
The Grav developers addressed the problem in Grav 2.0.20, released on August 21, 2026.
The update removes addJs and addCss from the default Twig sandbox allowlist and also adds escaping for asset URLs when HTML tags are generated. These changes prevent page content from directly registering scripts or stylesheets through the affected sandbox functionality and prevent malicious asset URLs from breaking out of HTML attributes.
The advisory states that all affected Grav 2.0 releases before 2.0.20 should be upgraded.
What should administrators do?
Administrators running Grav should check their installed version and upgrade to Grav 2.0.20 or later.
The vulnerability was publicly disclosed on August 21, although CVE-2026-86197 is now appearing in vulnerability databases dated September 5.
Administrators who cannot immediately upgrade can also tighten the Twig sandbox configuration to deny the addJs and addCss methods, although upgrading remains the recommended solution.
CVE-2026-86197 highlights the risks of giving content editors access to functionality that can influence how scripts and other resources are generated on a website. Grav administrators should ensure their installations are fully updated to reduce the risk of malicious content being used to target privileged users.

I am one of the editors here at www.systemtek.co.uk I am a UK based technology professional, with an interest in computer security and telecoms.
