Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
{
"schema_version": "1.4.0",
"id": "GHSA-5mq8-78gm-pjmq",
"modified": "2026-07-20T21:30:35Z",
"modified": "2026-07-20T21:30:36Z",
"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"
"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"
}
],
"affected": [
Expand All @@ -36,10 +32,7 @@
}
]
}
],
"database_specific": {
"last_known_affected_version_range": "<= 0.7.0"
}
]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a hand edit. The file is generated from the advisory, and last_known_affected_version_range only appears when the range and the patched version disagree. I changed the range to < 0.9.0, which is the same as "fixed": "0.9.0", so there is nothing left for that field to hold. See the explanation from GitHub in #470 (comment)

}
],
"references": [
Expand All @@ -64,7 +57,7 @@
"cwe_ids": [
"CWE-79"
],
"severity": "LOW",
"severity": "MODERATE",
"github_reviewed": true,
"github_reviewed_at": "2026-03-06T18:39:35Z",
"nvd_published_at": "2026-03-07T06:16:11Z"
Expand Down
Loading