XML standard allows the use of entities, declared in the DOCTYPE of the document, which can be internal or external.
When parsing the XML file, the content of the external entities is retrieved from an external storage such as the file system or network, which may lead, if no restrictions are put in place, to arbitrary file disclosures or server-side request forgery (SSRF) vulnerabilities.
It’s recommended to limit resolution of external entities by using one of these solutions:
libxmljs module:
const libxmljs = require("libxmljs");
var fs = require('fs');
var xml = fs.readFileSync('xxe.xml', 'utf8');
var xmlDoc = libxmljs.parseXmlString(xml, { noblanks: true, noent: true, nocdata: true }); // Noncompliant: noent set to true
libxmljs module:
const libxmljs = require("libxmljs");
var fs = require('fs');
var xml = fs.readFileSync('xxe.xml', 'utf8');
var xmlDoc = libxmljs.parseXmlString(xml); // Compliant: noent set to false by default