Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion server/bootstrap/src/org/labkey/bootstrap/ModuleArchive.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,12 @@ private String nameFromModuleXML(InputStream is) throws IOException

try
{
SAXParser parser = SAXParserFactory.newDefaultInstance().newSAXParser();
SAXParserFactory factory = SAXParserFactory.newDefaultInstance();
factory.setFeature(javax.xml.XMLConstants.FEATURE_SECURE_PROCESSING, true);
factory.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

According to this blog post I found from 2012 these settings seem to be mutually exclusive. My understanding is that you need to either disable doctype declaration (what this line does) or disable external entities (what the following two lines do). I'm not sure it's problematic to do both though, so maybe we should keep it.

https://blog.compass-security.com/2012/08/secure-xml-parser-configuration/

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, should be safe to do both, just in case.

factory.setFeature("http://xml.org/sax/features/external-general-entities", false);
factory.setFeature("http://xml.org/sax/features/external-parameter-entities", false);
SAXParser parser = factory.newSAXParser();
parser.parse(is, new DefaultHandler()
{
final ArrayList<String> elementStack = new ArrayList<>();
Expand Down