# GHSA-RHPM-4QPJ-GPX6: j0k3r/graby cross-site scripting (XSS)

- Database: GitHub
- Severity: CVSS 6.5 (Medium)
- Published: 2026-07-07
- Modified: 2026-07-07

## Affected versions

- j0k3r/graby (Packagist): fixed in 2.5.2

## Description

### Summary

`Graby::cleanupXss()` (`src/Graby.php:1038-1048`) configures htmLawed with `'deny_attribute' => 'style srcdoc'` (space-separated).

htmLawed's config parser splits `deny_attribute` on commas only, after first stripping all whitespace. So this value collapses into the single, non-matching token `'stylesrcdoc'`.

Neither `style` nor `srcdoc` is ever added to htmLawed's deny-list. Both attributes survive `safe` mode completely unfiltered.

### Details

htmLawed's config-normalization step (`htmLawed.php`, around lines 91-103):

```php
$x = !empty($C['deny_attribute']) ? strtolower(preg_replace('"\s+-"', '/', trim($C['deny_attribute']))) : '';
$x = str_replace(array(' ', "\t", "\r", "\n"), '', $x);
$x = array_flip(
  (isset($x[0]) && $x[0] == '*')
   ? preg_replace('`^[^*]`', '-'. '\\0', explode('/', ...))
   : array_filter(explode(',', $x . (!empty($C['safe']) ? ',on*' : ''))));
$C['deny_attribute'] = $x;
```

For the input `'style srcdoc'`, the whitespace-strip produces `'stylesrcdoc'`, then `explode(',', 'stylesrcdoc,on*')` yields `['stylesrcdoc', 'on*']`.

The deny-set therefore contains the keys `stylesrcdoc` and `on*`, never the individual names `style` or `srcdoc` that the later per-attribute check (`isset($eleSpec['deny'][$attr])`, around line 1142-1145) tests against.

Confirmed with the exact pinned config (fossar/htmlawed 1.3.3), both attributes pass through unchanged:

```
in : <div style="position:fixed;inset:0;z-index:2147483647;background:#fff">x</div>
out: <div style="position:fixed;inset:0;z-index:2147483647;background:#fff">x</div>

in : <iframe srcdoc="&lt;script&gt;alert(document.domain)&lt;/script&gt;"></iframe>
out: <iframe srcdoc="&lt;script&gt;alert(document.domain)&lt;/script&gt;"></iframe>
```

A single-token value works correctly, which confirms the comma requirement is the whole issue: with `deny_attribute => 'style'`, the same `<div style="...">x</div>` comes out as `<div>x</div>`, attribute removed.

That single-token `'style'` is exactly what graby 2.5.0 shipped, so `style` was correctly denied there. GHSA-3h6j-9x8m-rg3g's fix in 2.5.1 changed the value to `'style srcdoc'` to additionally deny srcdoc, but the space breaks parsing, so the 2.5.1 change does two things at once. srcdoc is still not denied: the intended fix is a no-op, and the advisory's own entity-encoded proof-of-concept still fires byte-for-byte on the "patched" 2.5.1. And `style` is no longer denied either: a regression from what 2.5.0 did correctly. Both survive on 2.5.1, which is graby's current latest release.

(An entity-encoded `srcdoc` is the standards-conformant way to author one: the browser decodes the entities when parsing the attribute, so the DOM `srcdoc` property holds literal, executable markup.)

### Proof of concept

Save an article whose content contains either payload. Both survive `cleanupXss()`, and the consuming app renders the result. Wallabag renders `entry.content` with `{{ ...|raw }}` at the unauthenticated `GET /share/{uid}`, so the following happens on page load with no login.

Full-viewport overlay via `style`:

```
<div style="position:fixed;inset:0;z-index:2147483647;background:#fff">...</div>
```

When the page renders, this element covers the entire viewport (bounding box measured at a 1280x800 viewport is `{x:0, y:0, w:1280, h:800}`), so it can overlay a spoofed login or session-expired prompt on top of the real page.

Auto-firing script via entity-encoded `srcdoc`:

```
<iframe srcdoc="&lt;script&gt;alert(document.domain)&lt;/script&gt;"></iframe>
```

The browser decodes the entities when parsing the attribute, so the iframe document contains a live `<script>` and executes it the instant the page loads, with no interaction.

The sanitizer is otherwise active: an `<img src=x onerror=...>` is stripped in the same configuration. Changing the config value to the comma-separated form (the fix below) then strips `style` and `srcdoc` as well.

### Impact

Any wallabag user who saves a URL they do not control (the app's purpose) can end up with a stored entry that carries either consequence.

(A) An unfiltered `style` attribute enables a full-viewport `position:fixed` overlay that can spoof a login prompt or redress the page for phishing and clickjacking, on both the authenticated reading view and the unauthenticated `GET /share/{uid}` page.

(B) An `<iframe srcdoc>` with an entity-encoded script payload auto-executes arbitrary JavaScript in the wallabag origin the instant the page loads, with no click.

Any Graby consumer that renders `cleanupHtml()` output without additional sanitization is affected the same way. Wallabag, confirmed here, has no CSP or other secondary mitigation by default.

### Suggested fix

```php
'deny_attribute' => 'style,srcdoc',
```

Comma, not space. This closes both `style` and `srcdoc` while leaving ordinary content, the deliberately re-allowed `<iframe src="...">` embed, and the `<img onerror>` positive control unaffected.

A regression test asserting htmLawed actually denies every intended token in this string (not just the first, or a concatenated blob) would prevent this class of bug from recurring.

## References

- https://github.com/j0k3r/graby/security/advisories/GHSA-rhpm-4qpj-gpx6

Page: https://cve.now/GHSA-RHPM-4QPJ-GPX6

Wrong or missing data? Send feedback: POST https://cve.now/api/v1/feedback (see https://cve.now/agents#feedback).
