Skip to content

Commit

Permalink
XML External Entity (XXE) injection in XmlConverter. Thanks to Stepha…
Browse files Browse the repository at this point in the history
…n Siano for the patch.
  • Loading branch information
davsclaus committed Mar 2, 2015
1 parent 1df5596 commit 7d19340
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -596,6 +596,12 @@ public SAXSource toSAXSourceFromStream(StreamSource source, Exchange exchange) t
} catch (Exception e) {
LOG.warn("SAXParser doesn't support the feature {} with value {}, due to {}.", new Object[]{javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, "true", e});
}
try {
sfactory.setFeature("http://xml.org/sax/features/external-general-entities", false);
} catch (SAXException e) {
LOG.warn("SAXParser doesn't support the feature {} with value {}, due to {}."
, new Object[]{"http://xml.org/sax/features/external-general-entities", false, e});
}
}
sfactory.setNamespaceAware(true);
SAXParser parser = sfactory.newSAXParser();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,19 +57,25 @@ private void sendEntityMessage(Object message) throws Exception {
Exchange exchange = list.get(0);
String xml = exchange.getIn().getBody(String.class);
assertTrue("Get a wrong transformed message", xml.indexOf("<transformed subject=\"\">") > 0);




try {
endpoint.reset();
endpoint.expectedMessageCount(1);

template.sendBody("direct:start2", message);
fail("Expect an exception here");

assertMockEndpointsSatisfied();

list = endpoint.getReceivedExchanges();
exchange = list.get(0);
xml = exchange.getIn().getBody(String.class);
assertTrue("Get a wrong transformed message", xml.indexOf("<transformed subject=\"\">") > 0);
} catch (Exception ex) {
// expect an exception here
assertTrue("Get a wrong exception", ex instanceof CamelExecutionException);
// the file could not be found
assertTrue("Get a wrong exception cause", ex.getCause() instanceof TransformerException);
}

}


Expand Down

0 comments on commit 7d19340

Please # to comment.