Skip to content

Commit

Permalink
External Formats XML: Prevent XXE vulnerability in XMLReader (finos#3188
Browse files Browse the repository at this point in the history
)

* External Formats XML: Prevent XXE vulnerability in XMLReader

* Fix
  • Loading branch information
aziemchawdhary-gs authored Oct 21, 2024
1 parent b169f66 commit 2c326f2
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class XmlReader
private static final int EVENT_BUFFER_SIZE = 4096;
private static final int DEFAULT_CAPTURE_CAPACITY = 4096;

private static final XMLInputFactory XML_INPUT_FACTORY = XMLInputFactory.newFactory();
private static final XMLInputFactory XML_INPUT_FACTORY = createInputFactory();
private static final XMLOutputFactory XML_OUTPUT_FACTORY = XMLOutputFactory.newFactory();

private final XMLEventReader reader;
Expand All @@ -57,6 +57,14 @@ public class XmlReader
private EventBuffer eventBuffer;
private ReadState currentState;

private static XMLInputFactory createInputFactory()
{
XMLInputFactory factory = XMLInputFactory.newFactory();
factory.setProperty(XMLInputFactory.SUPPORT_DTD, false);
return factory;
}


private XmlReader(XMLEventReader reader, Function<XMLStreamException, ? extends RuntimeException> exceptionHandler)
{
this(reader, exceptionHandler, DEFAULT_CAPTURE_CAPACITY);
Expand Down

0 comments on commit 2c326f2

Please sign in to comment.