Skip to content

disable external entity resolution in log4j 1.x XmlConfiguration - #4198

Open
jmestwa-coder wants to merge 1 commit into
apache:2.xfrom
jmestwa-coder:log4j1-xml-xxe
Open

disable external entity resolution in log4j 1.x XmlConfiguration#4198
jmestwa-coder wants to merge 1 commit into
apache:2.xfrom
jmestwa-coder:log4j1-xml-xxe

Conversation

@jmestwa-coder

Copy link
Copy Markdown

The Log4j 1.x XmlConfiguration reader resolves external XML entities.

  • the DocumentBuilderFactory is built with setValidating(true) and no entity restrictions
  • Log4jEntityResolver only handles log4j.dtd and returns null otherwise, so the parser falls back to fetching external entities
  • a legacy log4j.xml with a SYSTEM entity can read local files or reach network URLs
  • mirrors the disableDtdProcessing hardening already in log4j-core's XmlConfiguration

Test loads a config with an external entity and asserts it is not resolved.

Checklist

  • Base your changes on 2.x branch
  • ./mvnw verify succeeds
  • Non-trivial changes contain an entry file in the src/changelog/.2.x.x directory
  • Tests are provided

@ramanathan1504

Copy link
Copy Markdown
Contributor

@jmestwa-coder Thanks for the PR! I appreciate your patience. I'll try to get it closed ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

2 participants