Skip to content

Commit aa010e4

Browse files
committed
python: update qhelp
1 parent 75a2f92 commit aa010e4

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

python/ql/src/Security/CWE-643/XpathInjection.qhelp

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,14 @@
22
<qhelp>
33
<overview>
44
<p>
5-
Using user-supplied information to construct an XPath query for XML data can
6-
result in an XPath injection flaw. By sending intentionally malformed information,
7-
an attacker can access data that he may not normally have access to.
8-
He/She may even be able to elevate his privileges on the web site if the XML data
9-
is being used for authentication (such as an XML based user file).
5+
If an XPath expression is built using string concatenation, and the components of the concatenation
6+
include user input, it makes it very easy for a user to create a malicious XPath expression.
107
</p>
118
</overview>
129
<recommendation>
1310
<p>
14-
XPath injection can be prevented using parameterized XPath interface or escaping the user input to make it safe to include in a dynamically constructed query.
15-
If you are using quotes to terminate untrusted input in a dynamically constructed XPath query, then you need to escape that quote in the untrusted input to ensure the untrusted data can’t try to break out of that quoted context.
16-
</p>
17-
<p>
18-
Another better mitigation option is to use a precompiled XPath query. Precompiled XPath queries are already preset before the program executes, rather than created on the fly after the user’s input has been added to the string. This is a better route because you don’t have to worry about missing a character that should have been escaped.
11+
If user input must be included in an XPath expression, either sanitize the data or use variable
12+
references to safely embed it without altering the structure of the expression.
1913
</p>
2014
</recommendation>
2115
<example>

0 commit comments

Comments
 (0)