Skip to content

Conversation

@runeflobakk
Copy link
Member

@runeflobakk runeflobakk commented Oct 31, 2023

Ensuring JAXB marshalling (in particular Unmarshaller) uses a securely configured underlying XML parser, according to recommendations by OWASP.

In addition, more generic support for customizing the Marshaller and Unmarshaller, and setting schema used for validation is retrofitted into this facility. This is used by the BillionLaughsTest to inject the infamous Billion Laughs XXE attack header in order to test for the proper handling, i.e. not allowing a DOCTYPE header at all.

One additional unmarshal method is added: unmarshal(Node, Class). This allows for separating the XML-parsing to a general DOM-representation, and then afterwards unmarshal to a JAXB class from the already parsed DOM, instead of parsing the XML a second time.

Deprecates the constructor taking a set of schema resources.
Enables converting from already parsed DOM Document (e.g. from using
DocumentBuilder), which is applicable for ad-hoc access to the parsed
XML which is not captured into a JAXB type.
throw new IllegalArgumentException("No sources given for creating Schema. (schemaResourceNames was " + schemaResourceNames + ")");
}
try {
SAXParserFactory parserFactory = SAXParserFactory.newInstance();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hvorfor brukes ikke SaxParserProvider.createSecuredParserFactory(); her?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Den kan den nok! Dette ble nok tatt ut i en egen util før SaxParserProvider var tilgjengelig. Will fix!

Copy link
Contributor

@simenstoa simenstoa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏

Accepting an existing InputStream for consuming, should not assume that
the InputStream can be closed.
@runeflobakk runeflobakk force-pushed the disable-xml-entity-expansions branch from acd6be0 to a077a9b Compare November 2, 2023 17:38
@runeflobakk runeflobakk merged commit 0b146da into main Nov 2, 2023
@runeflobakk runeflobakk deleted the disable-xml-entity-expansions branch November 2, 2023 17:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants