Skip to content

Does xpath_variable escape strings (ie, sanitize for XPath injection)? #571

Answered by zeux
strazto asked this question in Q&A
Discussion options

You must be logged in to vote

XPath variables are not escaped, nor do they need to be. They work like variables in other programming languages - there is no textual substitution taking place, instead if the value of the variable is necessary during evaluation, it's looked up and used just as any other value extracted from an XML like an attribute value would. This is of course resistant to XPath injection.

I would hope all XPath implementations in existence that support XPath variables work like this, see https://www.w3.org/TR/1999/REC-xpath-19991116/#section-Basics. The link you noted uses dynamically generated query strings in its attack example, not XPath variables.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@strazto
Comment options

Answer selected by strazto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants