re-apply entity/DTD hardening after JDK deserialization of XmlFactory#878
Open
Sahana2524 wants to merge 1 commit into
Open
re-apply entity/DTD hardening after JDK deserialization of XmlFactory#878Sahana2524 wants to merge 1 commit into
Sahana2524 wants to merge 1 commit into
Conversation
Member
|
@Sahana2524 Thanks. We require a CLA as described in https://github.com/FasterXML/jackson/blob/main/CONTRIBUTING.md#paperwork - could you provide a CLA based on this? |
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.
Entity/DTD hardening dropped after JDK deserialization
XmlFactory.readResolve()rebuilds theXMLInputFactoryfrom only its stored class name, so the reconstructed factory comes back at plain Stax defaults with external-entity and DTD processing enabled again. A mapper that was safe by default silently regains the entity-expansion/XXE surface after a serialize then deserialize roundtrip. I moved the builder's hardening into a small shared helper and call it fromreadResolveso the two factory-building paths can't drift.Reproduces with a stock
new XmlMapper(): reading<!DOCTYPE foo [ <!ENTITY x "HELLO"> ]><foo>&x;</foo>throws before serialization, but after a JDK roundtrip&x;expands toHELLO. Added a regression test alongside the existing serialization/DTD tests.