Skip to content

changedetection.io has an Arbitrary Local File Read via a crafted backup restore

High severity GitHub Reviewed Published Apr 27, 2026 in dgtlmoon/changedetection.io • Updated May 14, 2026

Package

pip changedetection.io (pip)

Affected versions

<= 0.54.10

Patched versions

0.55.1

Description

Details

The vulnerability is caused by trusting attacker-controlled snapshot paths restored from backup files.

The vulnerable flow starts in the backup restore logic. When a backup ZIP is restored, the application extracts the archive and copies each restored watch UUID directory directly into the live datastore using shutil.copytree(entry.path, dst_dir). This preserves attacker-controlled files inside the restored watch directory, including history.txt.

Relevant code:

After restore, the application parses history.txt in the watch history property. This is the core trust-boundary issue.

Relevant code:

The relevant logic is effectively:

if os.sep not in v and '/' not in v and '\\' not in v:
    v = os.path.join(self.data_dir, v)
else:
    snapshot_fname = os.path.basename(v)
    proposed_new_path = os.path.join(self.data_dir, snapshot_fname)
    if not os.path.exists(v) and os.path.exists(proposed_new_path):
        v = proposed_new_path

This has the following security consequence:

  • If the history.txt value is only a filename, it is resolved safely under self.data_dir.
  • If the value contains path separators, it is treated as a path reference rather than a watch-local snapshot name.
  • If that external path already exists, it is preserved unchanged.

As a result, a malicious restored history.txt entry such as:

1776969105,/etc/passwd

will be accepted if the referenced file exists and is readable by the application process.

The second vulnerable step is in get_history_snapshot(). Once the untrusted path has been accepted into the watch history, the application reads the resolved path directly without enforcing that it remains inside the watch directory.

Relevant code:

That function eventually performs direct file reads such as:

with open(filepath, 'r', encoding='utf-8', errors='ignore') as f:
    return f.read()

The third step is reachability. The trusted history entry is consumed by both the Preview UI and the watch history API.

Relevant code:

In the Preview flow, the application selects the latest history timestamp and calls:

content = watch.get_history_snapshot(timestamp=timestamp)

In the API flow, the application also calls:

content = watch.get_history_snapshot(timestamp=timestamp)

This creates the following end-to-end exploit chain:

  1. An attacker supplies a crafted backup ZIP.
  2. The restore process preserves attacker-controlled history.txt.
  3. The history.txt parser accepts an absolute or out-of-directory path if that path exists.
  4. Preview or the history API dereferences the stored path directly.
  5. The application returns the contents of the targeted local file.

The root cause is that imported history entries are treated as trusted filesystem paths instead of being restricted to safe basenames under watch.data_dir.

PoC

The following proof of concept demonstrates the end-to-end exploit chain. It assumes the attacker has gained access to the backup restore functionality to upload the crafted archive.

  1. Create a normal watch in the UI, for example:
https://example.com
  1. Trigger at least one successful check so the watch generates a valid history entry and can later be included in a backup.

image

  1. Go to the Backups section and create a backup archive.

image

  1. Extract the backup archive and identify the watch UUID directory that contains the target watch's watch.json. For example:
5db3d3d8-71e6-4db2-a81e-e1f0445c3e47
  1. Open that watch directory and edit history.txt.

  2. Replace the latest history entry with a path to an existing local file that is readable by the application process. For example:

1776969188,/etc/passwd

If the timestamp differs in the extracted backup, keep the original latest timestamp and only replace the filename/path portion.

Example:

1776969188,742215043ff9be7e635f05e680ff9b11.txt

becomes:

1776969188,/etc/passwd

image

  1. Repack the backup so that the UUID directories are located at the root of the ZIP archive.

Important:

  • Do not add an extra parent directory layer when repacking.
  • The archive root should contain directories such as:
<watch-uuid>/
<group-uuid>/
changedetection.json
url-list.txt

image

  1. In the UI, restore the modified backup and enable replacement of existing watches with the same UUID.

image

  1. After restore completes, open Preview for the restored watch.

  2. The application will read the attacker-controlled path from history.txt and display the contents of the referenced local file instead of the original watch snapshot.

Observed result:

  • The Preview page returns the content of the attacker-selected local file.

Expected result:

  • The application should reject absolute paths or out-of-directory paths restored from history.txt.
  • Snapshot history should be restricted to files within the watch's own data directory.

Optional API verification:

  • The same issue can also be confirmed through the watch history API by requesting the modified timestamp after restore.
  • The API returns the same file content because it also calls watch.get_history_snapshot(timestamp=timestamp) on the trusted history entry.

image

Impact

This is an arbitrary local file disclosure vulnerability reachable through malicious backup restore content.

Who is impacted:

  • Deployments where the application process has read access to sensitive local system files.
  • Docker or host-mounted environments where secrets, config files, or operational artifacts are explicitly readable by the service.

What can be exposed:

  • Arbitrary System Files: Core operating system files (e.g., /etc/passwd, /proc/self/environ), system-level configurations, and host metrics.
  • Application Data: Internal records and files residing under the /datastore directory.
  • Secrets & Artifacts: Application-local configuration files, API tokens, database credentials, and other sensitive artifacts accessible to the application process.

By accessing the backup restore functionality and importing a crafted archive, an attacker can exploit the application's fail-open path validation. The confidentiality impact is exceptionally high because, once the payload is ingested, the application can be manipulated to disclose arbitrary local system files and highly sensitive environment variables directly through standard UI or API responses.

Recommendation

The application should treat all paths restored from history.txt as untrusted input.

The root cause is in changedetectionio/model/Watch.py, where values containing path separators are currently accepted as filesystem paths and preserved if the referenced file already exists.

The fix should be:

  1. Never trust absolute or external paths from history.txt.
  2. Normalize every history entry to os.path.basename(v).
  3. Join the normalized filename to self.data_dir.
  4. Skip the entry if the resolved file does not exist inside the watch directory.

Suggested code change:

snapshot_fname = os.path.basename(v.strip())
resolved_path = os.path.join(self.data_dir, snapshot_fname)

if not os.path.exists(resolved_path):
    logger.warning(
        f"Skipping unsafe or missing history entry for {self.get('uuid')}: {v!r}"
    )
    continue

tmp_history[k] = resolved_path

This ensures restored history entries can only reference files inside the watch's own data directory and prevents arbitrary local file reads through Preview or the history API.

References

@dgtlmoon dgtlmoon published to dgtlmoon/changedetection.io Apr 27, 2026
Published to the GitHub Advisory Database May 5, 2026
Reviewed May 5, 2026
Published by the National Vulnerability Database May 12, 2026
Last updated May 14, 2026

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:N/A:N

EPSS score

Exploit Prediction Scoring System (EPSS)

This score estimates the probability of this vulnerability being exploited within the next 30 days. Data provided by FIRST.
(10th percentile)

Weaknesses

External Control of File Name or Path

The product allows user input to control or influence paths or file names that are used in filesystem operations. Learn more on MITRE.

CVE ID

CVE-2026-43891

GHSA ID

GHSA-8757-69j2-hx56

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.