naruto-lgtm opened a new pull request, #8578:
URL: https://github.com/apache/hadoop/pull/8578

   ### Description of PR
   
   `AbfsBlobClient` parses the XML bodies returned by the Blob endpoint with 
default JAXP factories: `parseBlockListResponse` builds a 
`DocumentBuilderFactory.newInstance()` for GetBlockList, and the shared 
`saxParserThreadLocal` (used by `parseListPathResults`) builds a 
`SAXParserFactory.newInstance()`. Both process DTDs and external entities by 
default, so a list/block response coming from a malicious or intercepted 
endpoint can declare an external entity and read local files off the client 
host (XXE).
   
   Route both through `XMLUtils.newSecureDocumentBuilderFactory()` / 
`newSecureSAXParserFactory()`, the secure factories already used elsewhere in 
hadoop (Configuration, HDFS ECPolicyLoader, YARN AllocationFileLoaderService, 
rumen, etc.). Legitimate ListBlob/GetBlockList responses never carry a DOCTYPE, 
so valid parsing is unchanged; only entity/DTD-bearing payloads are now 
rejected.
   
   ### How was this patch tested?
   
   Added `TestBlobListXmlParser#testExternalEntityRejected`, which feeds a 
blob-list body that declares an external-entity DOCTYPE through the same secure 
SAX parser the client now constructs and asserts the parse is rejected. The 
existing valid-response cases in that test (which have no DOCTYPE) are 
unaffected.
   
   ### For code changes:
   
   - [ ] Does the title or this PR starts with the corresponding JIRA issue id 
(e.g. 'HADOOP-17799. Your PR title ...')?
   - [ ] Object storage: have the integration tests been executed and the 
endpoint declared according to the connector-specific documentation?
   - [ ] If adding new dependencies to the code, are these dependencies 
licensed in a way that is compatible for inclusion under [ASF 
2.0](http://www.apache.org/legal/resolved.html#category-a)?
   - [ ] If applicable, have you updated the `LICENSE`, `LICENSE-binary`, 
`NOTICE-binary` files?
   
   ### AI Tooling
   
   If an AI tool was used:
   
   - [ ] The PR includes the phrase "Contains content generated by <tool>"
         where <tool> is the name of the AI tool used.
   - [ ] My use of AI contributions follows the ASF legal policy
         https://www.apache.org/legal/generative-tooling.html


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to