Skip to content

Path traversal using file URI scheme without supplying hostname

High
dgtlmoon published GHSA-6jrf-rcjf-245r Nov 7, 2024

Package

pip changedetection.io (pip)

Affected versions

<= 0.47.05

Patched versions

0.47.06
docker dgtlmoon/changedetection.io (Docker)
<= 0.47.05
0.47.06
docker ghcr.io/dgtlmoon/changedetection.io (Docker)
<= 0.47.05
0.47.06

Description

Summary

The validation for the file URI scheme falls short, and results in an attacker being able to read any file on the system. This issue only affects instances with a webdriver enabled, and ALLOW_FILE_URI false or not defined.

Details

The check used for URL protocol, is_safe_url, allows file: as a URL scheme:

# Allowable protocols, protects against javascript: etc
# file:// is further checked by ALLOW_FILE_URI
SAFE_PROTOCOL_REGEX='^(http|https|ftp|file):'

It later checks if local files are permitted, but one of the preconditions for the check is that the URL starts with file://. The issue comes with the fact that the file URI scheme is not required to have double slashes.

A valid file URI must therefore begin with either file:/path (no hostname), file:///path (empty hostname), or file://hostname/path.
Wikipedia

if re.search(r'^file://', url, re.IGNORECASE):
if not strtobool(os.getenv('ALLOW_FILE_URI', 'false')):
raise Exception(
"file:// type access is denied for security reasons."
)

PoC

  1. Open up a changedetection.io instance with a webdriver configured
  2. Create a new watch: file:/etc/passwd or a similar path for your operating system. Enable webdriver mode
  3. Wait for it to be checked
  4. Open preview
  5. Notice contents of the file

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
Changed
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:C/C:H/I:N/A:N

CVE ID

CVE-2024-51998

Weaknesses

Credits