Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent XXE vulnerabilities #258

Merged
merged 7 commits into from
Jun 21, 2022

Conversation

clausnagel
Copy link
Member

@clausnagel clausnagel commented Jun 10, 2022

This PR adds necessary code to prevent XXE vulnerabilities when parsing XML files.

XML files are not just CityGML input files. But also the config file of the Importer/Exporter, XML query expressions, XSD schema files, and XSLT stylesheets are XML-based. So, various classes are affected by this PR.

  • Note 1: The ConfigUtil had to be moved from impexp-config to impexp-util to be able to use the new SecureXMLProcessors class.
  • Note 2: This PR uses the 2.12.1-SNAPSHOT version of citygml4j, which also contains XXE fixes (see here).

@clausnagel clausnagel requested a review from yaozhihang June 10, 2022 15:11
Copy link
Member

@yaozhihang yaozhihang left a comment

Choose a reason for hiding this comment

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

Thanks @clausnagel. Very important fix. I have only one remark from my review.

factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
Copy link
Member

Choose a reason for hiding this comment

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

Is the following code also needed? see here

factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure whether it's actually needed. I've found different examples on the web, and some even just use factory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);.

I am not against adding it. It's just that not all properties are supported by all XML implementations in every use case. So, could you please check that we do not get property-is-not-supported exceptions when adding it (e.g. when creating a validating or a non-validating reader)?

Copy link
Member

Choose a reason for hiding this comment

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

I haven't got exceptions after adding it.

Copy link
Member

Choose a reason for hiding this comment

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

Done with a82199a

@clausnagel clausnagel merged commit 2be6ff6 into release-5.2 Jun 21, 2022
@clausnagel clausnagel deleted the hotfix-prevent-xxe-vulnerabilities branch June 21, 2022 05:07
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