Summary
HTML element id attribute values are embedded directly into XPath expressions using single-quote delimiters without escaping, enabling XPath injection from page content.
Location
- File:
src/parser/selector_generation.rs
- Line(s): 50
Severity
High
Details
parts.push(format!("{}[@id='{}']", tag, id.as_str()));
An HTML element with id="foo' or '1'='1" produces the XPath div[@id='foo' or '1'='1'], which is valid but semantically wrong and matches unintended nodes. Adversarial page content could cause incorrect element identification.
Suggested Fix
Escape single quotes in the ID value before embedding:
let escaped_id = id.as_str().replace('\'', "\\'");
parts.push(format!("{}[@id='{}']" , tag, escaped_id));
Automated finding by repo-monitor
Summary
HTML element
idattribute values are embedded directly into XPath expressions using single-quote delimiters without escaping, enabling XPath injection from page content.Location
src/parser/selector_generation.rsSeverity
High
Details
An HTML element with
id="foo' or '1'='1"produces the XPathdiv[@id='foo' or '1'='1'], which is valid but semantically wrong and matches unintended nodes. Adversarial page content could cause incorrect element identification.Suggested Fix
Escape single quotes in the ID value before embedding:
Automated finding by repo-monitor