v1.31.0
conocimientosecurity-auditattacks/

xxe-attacks.md

Referencia que security-audit carga bajo demanda desde su SKILL.md.

security-auditskill
attackscarpeta
2990 Btamaño
2026-09-21último cambio del pack

Skill: security-audit

Payloads XXE, prevencion en 5 parsers Java y C#.

Ver tambien: owasp/owasp-top10-2025.md (A05), reports/cwe-references.md (CWE-611)


Payloads de Ataque

<!-- Divulgacion de archivos -->
<?xml version="1.0"?>
<!DOCTYPE foo [
  <!ENTITY xxe SYSTEM "file:///etc/passwd">
]>
<foo>&xxe;</foo>

<!-- SSRF -->
<!ENTITY xxe SYSTEM "https://192.168.1.1/privado">

<!-- DoS (Billion Laughs) -->
<!ENTITY xxe SYSTEM "file:///dev/random">

Prevencion C# / .NET

// XmlReaderSettings seguro (.NET 10)
var settings = new XmlReaderSettings
{
    DtdProcessing = DtdProcessing.Prohibit,
    XmlResolver = null
};
using var reader = XmlReader.Create(stream, settings);

// XmlDocument seguro
var doc = new XmlDocument();
doc.XmlResolver = null;  // Deshabilitar resolucion de entidades externas
doc.Load(stream);

Prevencion Java (5 Parsers)

DocumentBuilderFactory

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
dbf.setFeature("http://xml.org/sax/features/external-general-entities", false);
dbf.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
dbf.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
dbf.setFeature("http://javax.xml.XMLConstants/feature/secure-processing", true);

TransformerFactory

TransformerFactory tf = TransformerFactory.newInstance();
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
tf.setAttribute(XMLConstants.ACCESS_EXTERNAL_STYLESHEET, "");

XMLInputFactory (StAX)

xmlInputFactory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
xmlInputFactory.setProperty(XMLConstants.ACCESS_EXTERNAL_DTD, "");
xmlInputFactory.setProperty("javax.xml.stream.isSupportingExternalEntities", false);

XMLReader (SAX)

XMLReader reader = XMLReaderFactory.createXMLReader();
reader.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
reader.setFeature("http://xml.org/sax/features/external-general-entities", false);
reader.setFeature("http://xml.org/sax/features/external-parameter-entities", false);

SAXParserFactory

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
spf.setFeature("http://xml.org/sax/features/external-general-entities", false);

APIs Java Vulnerables a Revisar

javax.xml.parsers.DocumentBuilder
javax.xml.parsers.DocumentBuildFactory
org.xml.sax.EntityResolver
org.dom4j.*
javax.xml.parsers.SAXParser
javax.xml.parsers.SAXParserFactory
TransformerFactory
SAXReader, SAXBuilder, SAXParserFactory
XMLReaderFactory, XMLInputFactory
SchemaFactory, DocumentBuilderFactoryImpl

Pattern 1.0.0

← Volver a la ficha de security-audit

Ovillo v1.31.0tag v1.31.0 (2026-10-06) · sin decisiones posteriores69 skills · 19 agents · 22 hooks · 3 reglas · 15 tools · 103 decisionesfuente: ovillo/.claude/skills/security-audit/attacks/xxe-attacks.mdCopyright 2026 Hugo Valer Rojas · Apache-2.0