Unsanitized User Input in XPath
Overview
Description
Remediation Guidelines
public class Cls extends HttpServlet { public void handleRequest(HttpServletRequest request, HttpServletResponse response) { String userID = request.getParameter("userID"); String sanitizedUserID = sanitize(userID); // Ensure sanitization javax.xml.xpath.XPathFactory xpf = javax.xml.xpath.XPathFactory.newInstance(); javax.xml.xpath.XPath xp = xpf.newXPath(); String expression = "/Users/User[@userID='" + sanitizedUserID + "']"; String result = xp.evaluate(expression, xmlDocument); } }
References
Configuration
PreviousUnsanitized user input in XML External EntityNextUsage of bad hex conversion on digest array
Last updated