11 vulnerabilities classified as CWE-643 (XPath表达式中数据转义处理不恰当(XPath注入)). AI Chinese analysis included.
CWE-643 represents a critical input validation weakness where applications fail to sanitize external data before embedding it into XPath queries. This vulnerability typically arises when user-supplied strings are directly concatenated into dynamic XPath expressions without proper escaping or parameterization. Attackers exploit this flaw by injecting malicious XPath syntax, effectively altering the query’s logical structure to bypass authentication mechanisms or extract sensitive data from XML databases. To mitigate this risk, developers must strictly avoid dynamic query construction using unsanitized input. Instead, they should employ parameterized queries or prepared statements that treat user input as data rather than executable code. Additionally, implementing robust input validation and using whitelisting techniques ensures that only expected characters are processed, thereby neutralizing potential injection vectors and preserving the integrity of the underlying XML data retrieval process.
<users> <user> <login>john</login> <password>abracadabra</password> <home_dir>/home/john</home_dir> </user> <user> <login>cbc</login> <password>1mgr8</password> <home_dir>/home/cbc</home_dir> </user> </users>XPath xpath = XPathFactory.newInstance().newXPath(); XPathExpression xlogin = xpath.compile("//users/user[login/text()='" + login.getUserName() + "' and password/text() = '" + login.getPassword() + "']/home_dir/text()"); Document d = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File("db.xml")); String homedir = xlogin.evaluate(d);Vulnerabilities classified as CWE-643 (XPath表达式中数据转义处理不恰当(XPath注入)) represent 11 CVEs. The CWE taxonomy describes the weakness; review individual CVEs for product-specific impact.