The vulnerability is a stored Cross-Site Scripting (XSS) issue in the Grav admin panel. An attacker can inject malicious scripts into page taxonomy fields (like tags or categories) or metadata. These scripts are saved to the page's frontmatter and are executed when the page is viewed or edited in the admin panel, as the injected values are rendered without proper HTML escaping.
The provided patch 99f653296504f1d6408510dd2f6f20a45a26f9b0 addresses this by fixing the rendering of these values on the client side.
The core of the fix is in themes/grav/app/forms/fields/selectize.js. The selectize component is used for taxonomy fields. Before the patch, the component was initialized without a secure renderer, meaning that any HTML in the taxonomy tags would be rendered as-is by the browser.
The patch introduces default render functions (SafeRender.option and SafeRender.item) that use an escape function to neutralize any HTML in the item's text or value. These safe renderers are now applied by default to all selectize fields within the SelectizeField constructor.
The vulnerable function is therefore the constructor of the SelectizeField class, which was responsible for the insecure initialization of the component. A runtime profile during exploitation would show this constructor being called to create the vulnerable dropdown field, which then renders the malicious script.
The patch also includes a change in themes/grav/templates/forms/fields/taxonomy/taxonomy.html.twig to escape the taxonomy field's label, providing another layer of protection. However, the primary vector for the described vulnerability (injecting malicious tags) is addressed by the selectize.js modification.