Summary
changedetection.io allows users to define XPath-based content filters, but prior to version 0.54.4 these expressions were evaluated without restricting dangerous functions from the XPath 3.0/3.1 specification.
Because the unparsed-text() function can read arbitrary local files, an attacker who can control an include_filters XPath expression may be able to exfiltrate any file readable by the application process.
Affected context
This vulnerability occurs in deployments of changedetection.io where:
- Users are allowed to create or edit watches and define include_filters using XPath syntax.
- The backend uses the elementpath library to evaluate XPath 3.0/3.1 expressions against fetched web content.
- XPath expressions are passed to the library without restricting or filtering access to sensitive functions such as
unparsed-text().
In such contexts, any actor able to supply or modify an XPath expression may leverage the evaluation engine to read files from the local filesystem under the application's privileges.
Exploit preconditions
- Attack surface: Application web interface or API endpoints that accept XPath content filters (e.g., the
include_filtersfield on watches). - Required access: Ability to create or modify a watch with an XPath filter; this often corresponds to authenticated user access in typical deployments.
- Trigger point: The vulnerable code path is reached when changedetection.io evaluates the provided XPath expression against page content, causing built-in functions like
unparsed-text()to execute. - Why exploitation is possible: The application delegates expression evaluation directly to the XPath engine, which implements a powerful language including I/O-capable functions. Because expressions are not validated, constrained, or executed in a sandboxed profile, attackers can craft filters that call
unparsed-text()to read arbitrary files accessible to the application process.
Why this happens
The root cause is the direct evaluation of user-controlled XPath expressions using a full-featured query engine without restricting the available function set or capabilities.
This maps to CWE-94: Improper Control of Generation of Code ('Code Injection') and more specifically to expression injection: the user input is treated as executable query logic in a Turing-complete or I/O-capable language.
Instead of treating XPath as a declarative, constrained query, the application exposes the entire language surface, including unparsed-text(), which is designed to load external resources such as local files. When user input is interpreted as such an expression, the XPath engine effectively becomes a powerful gadget for arbitrary file access.
Potential impact
- Attackers may read arbitrary files that the changedetection.io process can access (e.g., configuration files, API keys, environment-specific secrets).
- Sensitive data such as access tokens, database connection strings, or authentication credentials could be exposed.
- Local application state, logs, or other operational data may be disclosed, aiding further attacks.
- Depending on deployment, attackers can potentially pivot using exposed secrets to compromise related services or infrastructure.
General mitigation guidance
Effective mitigation focuses on reducing expression power, minimizing trust in user-supplied queries, and limiting file-system exposure:
- Restrict XPath features: Prefer a limited evaluation mode that disables file I/O and other side-effectful functions. Where possible, configure the XPath engine to support only a safe subset of the language.
- Validate and sanitize expressions: Apply allow-list validation of XPath constructs, explicitly permitting only the minimal set of functions and operators required for filtering content (e.g., simple node selection and text extraction).
- Consider an alternative filter mechanism: Instead of evaluating arbitrary user-defined XPath, provide structured filter options (e.g., pre-defined selector types, CSS-style selectors, or compiled templates).
- Apply least privilege to the application process: Run changedetection.io under an account with minimal filesystem access; avoid co-locating secrets, private keys, or sensitive configuration in directories reachable by the application.
- Segregate sensitive configuration: Store secrets in dedicated, access-controlled mechanisms (e.g., environment variables via secret management systems) rather than local flat files in the application's working directory.
How teams detect issues like this
Organizations can use a combination of code-level and behavioral detection for similar issues:
- Static analysis and code review:
- Flag any use of expression evaluators (XPath, XQuery, template engines) where user input is passed directly to evaluation functions.
- Look for calls into XPath engines (such as elementpath) that accept raw user-provided strings, especially when configured with full language support.
- Review for absence of allow-list filters or sandbox configuration around expression evaluation.
- Policy and configuration checks:
- Establish coding guidelines that prohibit execution of unconstrained user-supplied expressions in query languages, template languages, or scripting engines.
- Use automated checks in CI to scan for known dangerous functions or configuration flags in XPath/XQuery usage.
- Runtime monitoring:
- Monitor application logs for suspicious or unexpected XPath expressions, including those invoking functions such as
unparsed-text(). - Instrument file access auditing on the host or container to detect unusual reads by the application process, especially targeting configuration or secret files.

