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 b47b51a commit 06db9e0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
Expand Up @@ -602,6 +602,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
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 06db9e0

Please sign in to comment.