Core: XmlPullParser processes external DTD entities (XXE) — disable FEATURE_PROCESS_DOCDECL in Xml#createParser()
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 84/100
Direzione di ricerca
Inizia da Xml#createParser() nel modulo google-http-client-xml e verifica come viene configurato il nuovo XmlPullParser. Esegui o aggiungi il test di regressione denominato testCreateParser_disablesDocDecl, usando l’esempio di entità DTD dell’issue. Il lavoro è completato quando le dichiarazioni del documento sono disabilitate o rifiutate in modo sicuro e il test di regressione conferma che l’entità non viene risolta.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Environment details
- Core (XML) — Xml#createParser() in google-http-client-xml
- OS type and version: Any (JVM-level issue, not OS-specific)
- Java version: Any (Java 8+)
- google-http-client-xml version: 2.1.1 and earlier
Problem Statement
Xml#createParser() returns a raw XmlPullParser without disabling
XmlPullParser.FEATURE_PROCESS_DOCDECL. If an attacker can influence the XML content
parsed by the library (e.g. via a malicious server response or injected content), they can
embed a <!DOCTYPE> declaration with external entity references (),
causing the parser to resolve arbitrary external entities.
This is a classic XML External Entity (XXE) vulnerability.
Steps to reproduce
- Call Xml.createParser() and feed it XML containing an inline DTD with entity
declarations ( ]>). - Parse the document with Xml.parseElement(...).
- Observe that the entity &xxe; is resolved and its value appears in the parsed output
instead of being rejected or left unexpanded.
Code example
XmlPullParser parser = Xml.createParser();
String xmlWithDtd = "\n"
+ "\n"
+ "]>\n"
+ "&xxe;";
parser.setInput(new StringReader(xmlWithDtd));
SimpleTypeString result = new SimpleTypeString();
Xml.parseElement(parser, result, new XmlNamespaceDictionary().set("", ""), null);
// result.value == "injected" <-- DTD entity resolved, XXE confirmed
Security Impact
- Allows entity injection / content spoofing from malicious XML input.
- In environments parsing untrusted XML (e.g. API responses from attacker-controlled
servers), this could lead to information disclosure or server-side request forgery (SSRF)
if external URI entities are supported by the underlying parser implementation.
Proposed Fix
Set FEATURE_PROCESS_DOCDECL to false immediately after creating the parser, with a
graceful fallback for parsers that do not support the feature flag:
public static XmlPullParser createParser() throws XmlPullParserException {
XmlPullParser parser = getParserFactory().newPullParser();
try {
parser.setFeature(XmlPullParser.FEATURE_PROCESS_DOCDECL, false);
} catch (XmlPullParserException e) {
// Ignore if the feature is not supported by this parser implementation
}
return parser;
}
A regression test (testCreateParser_disablesDocDecl) is included in the accompanying PR
verifying that DTD entity content is not resolved (or that the parser throws, which is also
an acceptable safe outcome).
- Lingua principale
- Java
- Stelle
- 1.4k
- Fork
- 473
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di googleapis/google-http-java-client
-
GenericData.containsKey() returns true for unset (null) declared fields, violating Map contract Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
googleapis/google-http-java-client#2187 · 1 commento ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Core: LowLevelHttpResponse not disconnected when HttpResponse construction throws RuntimeException Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
type: cleanup
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
priority: p2 type: cleanup
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
Tutte le issue di googleapis/google-http-java-client
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
infinispan/infinispan#18150 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
-
untriaged
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
opensearch-project/k-NN#3597 ·
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100