Code RoomXML parser enables external entities
HardPrep Room Coding #2184

XML parser enables external entities

Code reviewML systemsSecuritySenior–Staff~20 min

Review this Java endpoint that parses an uploaded XML document.

What a strong answer looks like

Separate real bugs from style. Rank issues by severity, point at the root cause rather than the symptom, and suggest a concrete fix, specific and kind.

0:00 of about 20 min
Mark a line and say what kind of problem it is.0 findings
1public Document parseUpload(InputStream xml) throws Exception {
2 DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
3 DocumentBuilder builder = dbf.newDocumentBuilder();
4 Document doc = builder.parse(xml);
5 doc.getDocumentElement().normalize();
6 return doc;
7}
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.