CVE-2026-30830: Defuddle Cross-Site Scripting Vulnerability

LOW
Advisory Identifier: GHSA-5mq8-78gm-pjmq
CVSS 6.1
CWE-79
Published
Advisory Summary

CVE-2026-30830 is a LOW (CVSS 6.1) cross-site scripting vulnerability (CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')) affecting Defuddle libraries in the npm ecosystem. The issue involves defuddle vulnerable to xss via unescaped string interpolation in _findcontentbyschematext image tag. Remediation is available by upgrading affected packages to version 0.9.0.

CVE-2026-30830 at a Glance

CVE Identifier CVE-2026-30830
GHSA Identifier GHSA-5mq8-78gm-pjmq
Severity LOW
CVSS v3.1 Base Score 6.1
CWE Classification CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting')
Affected Product Defuddle
Package Ecosystem npm
Published Date
Last Updated

Security Impact

CVSS: 6.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N).

Attack Vector Network (AV:N)
Attack Complexity Low (AC:L)
Privileges Required None (PR:N)
User Interaction Required (UI:R)
Scope Changed (S:C)
Confidentiality Low (C:L)
Integrity Low (I:L)
Availability None (A:N)

How to Fix CVE-2026-30830

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

defuddle fixed: 0.9.0
npm install defuddle@0.9.0
Verify Direct and Transitive Dependencies

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

npm ls defuddle

How to Check if You Are Affected

To determine whether your Node.js application is affected by CVE-2026-30830, inspect your project dependencies using npm:

npm ls defuddle

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

Note: The npm ls defuddle command inspects dependencies declared in your package.json and lockfile; it does not perform automated runtime dynamic scanning.

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 Defuddle, 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 The `_findContentBySchemaText` method in `src/defuddle.ts` interpolates image `src` and `alt` attributes directly into an HTML string without escaping: ```typescript html += `<img src="${imageSrc}" alt="${imageAlt}">`; ``` An attacker can use a `"` in the `alt` attribute to break out of the attribute context and inject event handlers. This is a separate vulnerability from the sanitization bypass fixed in f154cb7 — the injection happens during string construction, not in the DOM, so `_stripUnsafeElements` cannot catch it. ### Details When `_findContentBySchemaText` finds a sibling image outside the matched content element, it reads the image's `src` and `alt` attributes via `getAttribute()` and interpolates them into a template literal. `getAttribute('alt')` returns the raw attribute value. If the alt contains `"`, it terminates the `alt` attribute in the interpolated HTML string, and subsequent content becomes new attributes (including event handlers). The recently added `_stripUnsafeElements()` (commit f154cb7) strips `on*` attributes from DOM elements, but the `alt` attribute's name is `alt` (not `on*`), so it is preserved with its full value. The `onload` handler is created by the string interpolation, not present in the original DOM. ### PoC Input HTML: ```html <!DOCTYPE html> <html> <head> <title>PoC</title> <script type="application/ld+json"> {"@type": "Article", "text": "Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count."} </script> </head> <body> <article><p>Short.</p></article> <div class="post-container"> <p>Extra text to inflate parent word count padding padding padding.</p> <div class="post-body"> Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count. </div> <img width="800" height="600" src="https://example.com/photo.jpg" alt='pwned" onload="alert(document.cookie)'> </div> </body> </html> ``` Output: ```html <img src="https://example.com/photo.jpg" alt="pwned" onload="alert(document.cookie)"> ``` The `onload` event handler is injected as a separate HTML attribute. ### Impact XSS in any application that renders defuddle's HTML output (browser extensions, web clippers, reader modes). The attack requires crafted HTML with schema.org structured data that triggers the `_findContentBySchemaText` fallback, combined with a sibling image whose `alt` attribute contains a quote character followed by an event handler. ### Suggested Fix Use DOM API instead of string interpolation: ```typescript if (imageSrc) { const img = this.doc.createElement('img'); img.setAttribute('src', imageSrc); img.setAttribute('alt', imageAlt); html += img.outerHTML; } ``` This ensures attribute values are properly escaped by the DOM serializer.

CVE-2026-30830 Affected Defuddle Versions

1 component(s)
Fixed Versions:
0.9.0
Product / Package Ecosystem Affected Versions Fixed Version
defuddle
npm
< 0.9.0
0.9.0

References

Frequently Asked Questions

What is CVE-2026-30830?
CVE-2026-30830 is a security vulnerability in Defuddle involving defuddle vulnerable to XSS via unescaped string interpolation in _findContentBySchemaText image tag under CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting').
Which Defuddle versions are affected?
Affected versions include releases prior to 0.9.0 across affected packages: defuddle.
What version fixes CVE-2026-30830?
Upgrading to 0.9.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is defuddle affected?
Yes, defuddle is affected in releases prior to 0.9.0. Upgrade your dependency to 0.9.0 or later.
What is the CVSS score of CVE-2026-30830?
CVE-2026-30830 has a CVSS v3.1 base score of 6.1 (LOW) with vector string CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N.
What CWE is associated with CVE-2026-30830?
CVE-2026-30830 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 npm dependencies for CVE-2026-30830?
Run the dependency tree command: 'npm ls defuddle'. 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-5mq8-78gm-pjmq",
  "modified" : "2026-07-20T21:30:35Z",
  "published" : "2026-03-06T18:39:35Z",
  "aliases" : [ "CVE-2026-30830" ],
  "summary" : "defuddle vulnerable to XSS via unescaped string interpolation in _findContentBySchemaText image tag",
  "details" : "### Summary\n\nThe `_findContentBySchemaText` method in `src/defuddle.ts` interpolates image `src` and `alt` attributes directly into an HTML string without escaping:\n\n```typescript\nhtml += `<img src=\"${imageSrc}\" alt=\"${imageAlt}\">`;\n```\n\nAn attacker can use a `\"` in the `alt` attribute to break out of the attribute context and inject event handlers. This is a separate vulnerability from the sanitization bypass fixed in f154cb7 — the injection happens during string construction, not in the DOM, so `_stripUnsafeElements` cannot catch it.\n\n### Details\n\nWhen `_findContentBySchemaText` finds a sibling image outside the matched content element, it reads the image's `src` and `alt` attributes via `getAttribute()` and interpolates them into a template literal. `getAttribute('alt')` returns the raw attribute value. If the alt contains `\"`, it terminates the `alt` attribute in the interpolated HTML string, and subsequent content becomes new attributes (including event handlers).\n\nThe recently added `_stripUnsafeElements()` (commit f154cb7) strips `on*` attributes from DOM elements, but the `alt` attribute's name is `alt` (not `on*`), so it is preserved with its full value. The `onload` handler is created by the string interpolation, not present in the original DOM.\n\n### PoC\n\nInput HTML:\n\n```html\n<!DOCTYPE html>\n<html>\n<head>\n<title>PoC</title>\n<script type=\"application/ld+json\">\n{\"@type\": \"Article\", \"text\": \"Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count.\"}\n</script>\n</head>\n<body>\n<article><p>Short.</p></article>\n<div class=\"post-container\">\n  <p>Extra text to inflate parent word count padding padding padding.</p>\n  <div class=\"post-body\">\n    Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count. Long article text repeated many times to exceed the extracted content word count.\n  </div>\n  <img width=\"800\" height=\"600\" src=\"https://example.com/photo.jpg\" alt='pwned\" onload=\"alert(document.cookie)'>\n</div>\n</body>\n</html>\n```\n\nOutput:\n\n```html\n<img src=\"https://example.com/photo.jpg\" alt=\"pwned\" onload=\"alert(document.cookie)\">\n```\n\nThe `onload` event handler is injected as a separate HTML attribute.\n\n### Impact\n\nXSS in any application that renders defuddle's HTML output (browser extensions, web clippers, reader modes). The attack requires crafted HTML with schema.org structured data that triggers the `_findContentBySchemaText` fallback, combined with a sibling image whose `alt` attribute contains a quote character followed by an event handler.\n\n### Suggested Fix\n\nUse DOM API instead of string interpolation:\n\n```typescript\nif (imageSrc) {\n    const img = this.doc.createElement('img');\n    img.setAttribute('src', imageSrc);\n    img.setAttribute('alt', imageAlt);\n    html += img.outerHTML;\n}\n```\n\nThis ensures attribute values are properly escaped by the DOM serializer.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N"
  }, {
    "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" : "npm",
      "name" : "defuddle"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "0.9.0"
      } ]
    } ],
    "database_specific" : {
      "last_known_affected_version_range" : "<= 0.7.0"
    }
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/kepano/defuddle/security/advisories/GHSA-5mq8-78gm-pjmq"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-30830"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/kepano/defuddle/commit/f154cb740ee603431b69638273af737a27156df9"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/kepano/defuddle"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-79" ],
    "severity" : "LOW",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-03-06T18:39:35Z",
    "nvd_published_at" : "2026-03-07T06:16:11Z"
  }
}