Skip to content

Update: XML External Entity (XXE) Prevention Cheat Sheet #488

@gilday

Description

@gilday

The JAXB > Java 8 and Up sub-section on the XXE Cheat Sheet can be misleading. The advice in this section succinctly states

Since JDK-8010393, which is in OpenJDK 8 beta 86, javax.xml.bind.Unmarshaller instances are safe by default. The other classes mentioned here are still unsafe by default in Java 8.

This statement is too broad. It does not account for all the nuances that can lead the javax.xml.bind.Unmarshaller to be vulnerable or used in a way that is vulnerable on OpenJDK 1.8 based runtimes. An application parsing untrusted XML on an OpenJDK 1.8 runtime may be vulnerable to XXE if

  • the JAXB runtime has been inadvertently replaced with a different JAXB runtime that is not safe-by-default (e.g. EclipseLink MOXy)
  • the secure SAX parser that the OpenJDK 1.8 Unmarshaller uses has been inadvertently replaced with a different implementation that is not safe-by-default (e.g. xercesImpl:2.8.0)
  • the application uses one of the unmarshal overloads that does not delegate XML parsing to the safe-by-default SAX parser

Elaborating on that last point, even if the Unmarshaller is considered safe by default, not all of its unmarshal methods use the safe by default XMLReader. Calling unmarshal with any of the following argument types still requires the user to explicitly configure the XML parsing to be safe

  • javax.xml.transform.stream.SAXSource
  • org.w3c.dom.Node
  • javax.xml.stream.XMLStreamReader
  • javax.xml.stream.XMLEventReader

The following is a detailed analysis that explains why users should not rely on the safe by default nature of the Unmarshaller in OpenJDK 1.8 https://www.contrastsecurity.com/security-influencers/xml-xxe-pitfalls-with-jaxb

Recommend removing this sub-section from the Cheat Sheet

Metadata

Metadata

Assignees

No one assigned

    Labels

    ACK_WAITINGIssue waiting acknowledgement from core team before to start the work to fix it.HELP_WANTEDIssue for which help is wanted to do the job.UPDATE_CSIssue about the update/refactoring of a existing cheat sheet.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions