Advisory

GHSA-3cgg-c5pp-57h6

Details, part 2 of 2. The advisory

Details

Reproduction script:

import { readFileSync } from 'fs';
import { odtToHtml } from 'odf-kit/odt/to-html';
import { odsToHtml } from 'odf-kit/ods/to-html';

const bytes = (p) => new Uint8Array(readFileSync(p));

console.log(odtToHtml(bytes('poc2.odt'), { fragment: true }));
console.log(odsToHtml(bytes('poc3.ods')));

This was found while auditing ODT import paths in a web application that uses odf-kit as its converter. That application happens to sanitize the output downstream, so minimal standalone reproductions were built against the published odf-kit 0.14.1 package directly in Node.

Impact

Any consumer that renders odtToHtml() or odsToHtml() output as HTML — which is both functions' documented purpose — gets XSS from a crafted .odt/.ods file they convert. Untrusted file → arbitrary tags and attributes → script execution in the host page with the page's origin. The fragment mode ({ fragment: true }) is equally affected. The header comment in the ODT renderer currently promises "the output is safe to embed in any context", so consumers may reasonably be relying on that today.

For what it's worth, the sibling paths were checked: the markdown direction does not reach this code, and escapeHtml is correctly applied everywhere else I looked in the ODT renderer. The ODS renderer initially appeared clean too, but the buildInlineStyle path above is the second instance of the same defect.

Suggested fix

Escape the assembled CSS string at every style="${...}" site, in both renderers:

html = `<span style="${escapeHtml(css)}">${html}</span>`

(or, stronger, validate/allowlist the parsed style values at parse time — they are all supposed to be color literals, lengths, or keywords, so a strict per-property format check would also work; escaping row.height in the ODS renderer at line 95 as well). The per-site escape is the minimal fix consistent with the rest of the ODT file.

Sources & licences