ABFS: disable external entity resolution when parsing Blob endpoint XML#8609
Open
nishat-06 wants to merge 1 commit into
Open
ABFS: disable external entity resolution when parsing Blob endpoint XML#8609nishat-06 wants to merge 1 commit into
nishat-06 wants to merge 1 commit into
Conversation
…ponses Signed-off-by: nishat-06 <nishat@bugqore.com>
|
🎊 +1 overall
This message was automatically generated. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description of PR
Blob endpoint XML responses are parsed with external entities enabled
parseBlockListResponsecreates itsDocumentBuilderFactoryvianewInstance(), and thesaxParserThreadLocalbehindparseListPathResultsandparseListContainersResponsedoes the same withSAXParserFactory. Neither disables DOCTYPE or external entity resolution, so XML coming back from the Blob endpoint on GetBlockList, ListBlobs and ListContainers is parsed with entity resolution on, and a response carrying<!ENTITY xxe SYSTEM "file:///...">has the entity resolved client side, with the contents landing in block ids and listing entries. Both now use the secure factories hadoop-common already exposes inXMLUtilsfor exactly this.I do not have a JIRA id for this yet, so the title does not carry one. Happy to file one and rename if you would like it tracked that way.
How was this patch tested?
New unit test
TestAbfsBlobClientXmlParsingunder hadoop-azure. It feedsparseBlockListResponsea block list response whose block name is an external entity pointing at a temp file: before the change the parse succeeds and hands back the file contents as a block id, after it the parse raisesIOException. A second case parses a well formed block list and checks the ids still come through, so valid responses are unaffected.Ran locally on JDK 11:
mvn test -pl hadoop-tools/hadoop-azure -Dtest='TestAbfsBlobClientXmlParsing,TestBlobListXmlParser,TestListActionTaker,TestAbfsClient,TestAbfsHttpOperation'— 11 tests, all passmvn install -DskipTestsfrom the root — BUILD SUCCESSmvn checkstyle:check -pl hadoop-tools/hadoop-azure— nothing new on the two touched filesThe ABFS ITest suites need a live storage account, which I do not have, so they have not been run. That is the one gap I would ask a reviewer with an endpoint to cover.
For code changes:
LICENSE,LICENSE-binary,NOTICE-binaryfiles?No new dependencies;
XMLUtilsis already reachable from hadoop-azure through the hadoop-common provided dependency.AI Tooling
If an AI tool was used:
where is the name of the AI tool used.
https://www.apache.org/legal/generative-tooling.html
Contains content generated by Claude Code.