# GHSA-3h6j-9x8m-rg3g: Graby has stored XSS via iframe srcdoc Attribute in htmLawed Sanitization Config

- Severity: Low (CVSS:4.0, scored by GitHub) `CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:P/VC:N/VI:N/VA:N/SC:L/SI:L/SA:N/E:P`
- Known to be exploited: not in CISA's catalogue, which lists only what CISA has confirmed
- Published: 2026-03-31T23:12:36.000Z
- Modified: 2026-03-31T23:32:26.906Z
- Weaknesses: CWE-79

## Description

## Summary

Graby's `cleanupXss()` function configures htmLawed with conflicting settings: `safe=1` (which removes `<iframe>`) combined with `'elements' => '*+iframe-meta'` (which re-enables `<iframe>`). htmLawed does not sanitize the `srcdoc` attribute, allowing injection of arbitrary JavaScript that executes when the content is rendered via `|raw` in templates.

## Root Cause

**`src/Graby.php` lines 1038-1048:**
```php
htmLawed($html, [
    'safe' => 1,                    // removes <iframe>
    'elements' => '*+iframe-meta',  // re-adds <iframe>, overrides safe=1
    'deny_attribute' => 'style',    // srcdoc is NOT denied
]);
```

The `safe=1` and `+iframe` combination is a conflict: `safe` mode is designed to strip dangerous elements, but the elements override re-enables `<iframe>` without also blocking the dangerous `srcdoc` attribute.

## Proof of Concept

Input to `cleanupXss()`:
```html
<iframe srcdoc="&lt;script&gt;alert(document.domain)&lt;/script&gt;"></iframe>
```

Output (unchanged — htmLawed passes it through):
```html
<iframe srcdoc="&lt;script&gt;alert(document.domain)&lt;/script&gt;"></iframe>
```

When rendered via `{{ content|raw }}` in a template, `srcdoc` executes in an `about:srcdoc` frame with the same origin as the page. **Confirmed via Puppeteer/Chromium headless: `alert(document.domain)` fires.**

Validated on Wallabag (which uses Graby) via Docker: entry created via API with iframe-only content body triggers Readability failure → falls through to `cleanupXss()` path.

## Impact

- Stored XSS in any application rendering Graby-sanitized content via `|raw`
- In Wallabag: affects both authenticated views and public share pages (unauthenticated)
- No CSP headers in default Wallabag config — no secondary mitigation

## Suggested Fix

Either remove `+iframe` from the elements config to keep iframes blocked:
```php
'elements' => '*-iframe-meta',
```

Or explicitly deny the `srcdoc` attribute:
```php
'deny_attribute' => 'style srcdoc',
```

## Credit

Discovered by @tikket1, 2026-03-25. Redirected from wallabag/wallabag advisory by @j0k3r.

(As written by GitHub Advisory Database.)

## Affected

- j0k3r/graby (Packagist): before 2.5.1

## References

- <https://github.com/j0k3r/graby/security/advisories/GHSA-3h6j-9x8m-rg3g> (web)
- <https://github.com/j0k3r/graby/commit/0295d828822f7a59c5751a8199973a4f965a99b0> (web)
- <https://github.com/j0k3r/graby> (package)
- <https://github.com/j0k3r/graby/releases/tag/2.5.1> (web)

## Sources

- GitHub Advisory Database: [GHSA-3h6j-9x8m-rg3g](https://github.com/advisories/GHSA-3h6j-9x8m-rg3g), CC-BY-4.0, modified 2026-03-31

---

Page: https://cve.day/GHSA-3h6j-9x8m-rg3g · Whole record: https://cve.day/GHSA-3h6j-9x8m-rg3g.json · Rebuilt by cve.day 2026-11-25T22:56:30.903Z
