Aller au contenu

XPath injection (ARCH6108)

Ce contenu n’est pas encore disponible dans votre langue.

Key ruby.security.xpath-injection · Severity error · Category security · CWE CWE-643

Concatenating untrusted input into an XPath expression lets attackers alter the query to disclose unauthorized data or bypass authentication.

def find(user)
doc.xpath("//user[name='#{user}']")
end
def find(user)
doc.xpath("//user[name=$name]", nil, name: user)
end

Do not embed input in XPath; use variable binding (xpath parameters).