An XML parser is configured to expand external entities

tx0/ts:xml-external-entitiesrecommendedwarningsecurity, cwe-611

What it finds

An XML parser that expands external entities lets a document pull in local files, such as /etc/passwd, or make the server fetch URLs on its behalf.

Reported are calls of parseXml, parseXmlString and parseXmlAsync, as libxmljs offers them, with the option noent: true, which turns entity expansion on.

From the rule's source, xml_external_entities.rs.

Example from the rule's tests
import libxmljs from "libxmljs";export function parse(xml: string) {  const a = libxmljs.parseXmlString(xml, { noent: true });tx0 reports: expands external entities  const b = libxmljs.parseXmlString(xml, { noent: false });  return [a, b];}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/ts:xml-external-entities" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/ts:xml-external-entities] reason="..."

tx0 explain tx0/ts:xml-external-entities shows the same in the terminal. Found a false positive? Report it.