GHSA-3h6j-9x8m-rg3g: J0k3r/graby Cross-Site Scripting Vulnerability

LOW
CWE-79
Published
Advisory Summary

GHSA-3h6j-9x8m-rg3g is a LOW cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting J0k3r/graby libraries in the Packagist ecosystem. The issue involves graby has stored xss via iframe srcdoc attribute in htmlawed sanitization config. Remediation is available by upgrading affected packages to version 2.5.1.

GHSA-3h6j-9x8m-rg3g at a Glance

CVE Identifier N/A
GHSA Identifier GHSA-3h6j-9x8m-rg3g
Severity LOW
CVSS v3.1 Base Score N/A
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product J0k3r/graby
Package Ecosystem Packagist
Published Date
Last Updated

How to Fix GHSA-3h6j-9x8m-rg3g

To remediate this vulnerability, upgrade all affected J0k3r/graby dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

j0k3r/graby fixed: 2.5.1
Upgrade j0k3r/graby to 2.5.1
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for j0k3r/graby

How to Check if You Are Affected

To determine whether your application is affected by GHSA-3h6j-9x8m-rg3g, inspect your project dependencies for J0k3r/graby:

inspect dependencies for j0k3r/graby

Analyze the terminal output to locate any version of J0k3r/graby in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 2.5.1), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), where the product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users. In J0k3r/graby, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

## 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.

GHSA-3h6j-9x8m-rg3g Affected J0k3r/graby Versions

1 component(s)
Fixed Versions:
2.5.1
Product / Package Ecosystem Affected Versions Fixed Version
j0k3r/graby
Packagist
< 2.5.1
2.5.1

References

Frequently Asked Questions

What is GHSA-3h6j-9x8m-rg3g?
GHSA-3h6j-9x8m-rg3g is a security vulnerability in J0k3r/graby involving Graby has stored XSS via iframe srcdoc Attribute in htmLawed Sanitization Config under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which J0k3r/graby versions are affected?
Affected versions include releases prior to 2.5.1 across affected packages: j0k3r/graby.
What version fixes GHSA-3h6j-9x8m-rg3g?
Upgrading to 2.5.1 (or the latest patched release for your respective branch) resolves the vulnerability.
Is j0k3r/graby affected?
Yes, j0k3r/graby is affected in releases prior to 2.5.1. Upgrade your dependency to 2.5.1 or later.
What CWE is associated with GHSA-3h6j-9x8m-rg3g?
GHSA-3h6j-9x8m-rg3g is classified under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') (The product does not neutralize or incorrectly neutralizes user-controllable input before it is placed in output that is used as a web page that is served to other users.).
How can I check Packagist dependencies for GHSA-3h6j-9x8m-rg3g?
Run the dependency tree command: 'inspect dependencies for j0k3r/graby'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-3h6j-9x8m-rg3g",
  "modified" : "2026-03-31T23:12:36Z",
  "published" : "2026-03-31T23:12:36Z",
  "aliases" : [ ],
  "summary" : "Graby has stored XSS via iframe srcdoc Attribute in htmLawed Sanitization Config",
  "details" : "## Summary\n\nGraby'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.\n\n## Root Cause\n\n**`src/Graby.php` lines 1038-1048:**\n```php\nhtmLawed($html, [\n    'safe' => 1,                    // removes <iframe>\n    'elements' => '*+iframe-meta',  // re-adds <iframe>, overrides safe=1\n    'deny_attribute' => 'style',    // srcdoc is NOT denied\n]);\n```\n\nThe `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.\n\n## Proof of Concept\n\nInput to `cleanupXss()`:\n```html\n<iframe srcdoc=\"&lt;script&gt;alert(document.domain)&lt;/script&gt;\"></iframe>\n```\n\nOutput (unchanged — htmLawed passes it through):\n```html\n<iframe srcdoc=\"&lt;script&gt;alert(document.domain)&lt;/script&gt;\"></iframe>\n```\n\nWhen 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.**\n\nValidated on Wallabag (which uses Graby) via Docker: entry created via API with iframe-only content body triggers Readability failure → falls through to `cleanupXss()` path.\n\n## Impact\n\n- Stored XSS in any application rendering Graby-sanitized content via `|raw`\n- In Wallabag: affects both authenticated views and public share pages (unauthenticated)\n- No CSP headers in default Wallabag config — no secondary mitigation\n\n## Suggested Fix\n\nEither remove `+iframe` from the elements config to keep iframes blocked:\n```php\n'elements' => '*-iframe-meta',\n```\n\nOr explicitly deny the `srcdoc` attribute:\n```php\n'deny_attribute' => 'style srcdoc',\n```\n\n## Credit\n\nDiscovered by @tikket1, 2026-03-25. Redirected from wallabag/wallabag advisory by @j0k3r.",
  "severity" : [ {
    "type" : "CVSS_V4",
    "score" : "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"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Packagist",
      "name" : "j0k3r/graby"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "2.5.1"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 2.5.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/j0k3r/graby/security/advisories/GHSA-3h6j-9x8m-rg3g"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/j0k3r/graby/commit/0295d828822f7a59c5751a8199973a4f965a99b0"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/j0k3r/graby"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/j0k3r/graby/releases/tag/2.5.1"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-31T23:12:36Z",
    "nvd_published_at" : null
  }
}