/

CVE-2026-41489

Severity:

HIGH RISK

(8.8)

Privilege Escalation via Insecure Configuration Handling

CVE-2026-41489

Deferred

Vulnerability type

Category:

Privilege Escalation via Insecure Configuration Handling

CWE:

CWE-15, CWE-269, CWE-732

Impact:

Local Privilege Escalation to Root

Severity:

HIGH RISK

(8.8)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Pi-hole's root-executed systemd hook scripts use a path read from configuration (files.pid) in privileged file operations without validation, allowing controlled deletion and recreation of arbitrary files outside certain protected directories.

An attacker who already has Pi-hole service privileges can point this path at sensitive locations (such as SSH authorized_keys) to gain full root access on the host.

Affected context

This vulnerability occurs in Pi-hole Core (6.0 to < 6.4.2) and FTL (6.0 to < 6.6.1) when deployed with the default systemd service configuration.

Two scripts, pihole-FTL-prestart.sh and pihole-FTL-poststop.sh, run as root and consume the files.pid path from Pi-hole's configuration.

When an attacker-controlled or attacker-modifiable configuration can influence this path, the scripts perform privileged file deletion and creation on arbitrary locations, outside systemd's ProtectSystem=full-restricted paths.

Exploit preconditions

  • Attack surface: Local, on a host running a vulnerable Pi-hole deployment.
  • Required access: Ability to authenticate as a user or service account with "pihole" privileges (or equivalent rights to modify Pi-hole configuration controlling files.pid).
  • Configuration control: Attacker can write an arbitrary filesystem path into the files.pid configuration value.
  • Trigger point: Starting, stopping, or restarting the pihole-FTL systemd service so that:
  • pihole-FTL-prestart.sh runs before service start, and/or
  • pihole-FTL-poststop.sh runs after service stop.
  • Why exploitation is possible: The scripts trust the configured path without validation, performing rm -f and file creation logic as root on whatever file the configuration points to, thereby crossing privilege boundaries.

Why this happens

The core issue is that privileged shell scripts executed by systemd as root implicitly trust a configuration-supplied file path and use it in dangerous file operations.

This behavior aligns with:

  • CWE-269: Improper Privilege Management – root-level scripts perform operations on attacker-controlled paths, allowing lower-privileged actors to escalate to root.
  • CWE-15: External Control of System or Configuration Setting – the files.pid setting, controlled by a less-privileged context, directly influences which file is deleted and recreated.
  • CWE-732: Incorrect Permission Assignment for Critical Resource – the recreated file is written with root's authority in a way that can grant unauthorized write/control to the attacker (for example, manipulating SSH authorized_keys).

In abstract terms, an untrusted configuration value is treated as a safe, absolute filesystem target for sensitive operations in a high-privilege context, without path validation, confinement, or policy checks.

Potential impact

  • Local privilege escalation from Pi-hole-level access to full root access on the host.
  • Overwriting or creating SSH authorized_keys files to obtain persistent root login.
  • Deletion and recreation of critical configuration files outside protected directories.
  • Potential denial of service by corrupting or removing key system or application files.
  • Broad system compromise if rewritten files control services, authentication, or security policies.

General mitigation guidance

Effective mitigation focuses on reducing trust in configuration-controlled paths and tightening privilege boundaries around root-executed scripts:

  • Constrain configurable paths: Restrict files.pid and similar settings to a fixed, root-owned directory (e.g., under /run, /var/run, or another dedicated runtime path), and reject absolute or parent-relative paths.
  • Validate and sanitize file paths: Introduce path canonicalization and checks to ensure the target remains within an allowed directory tree before performing any file operation.
  • Drop unnecessary privileges: Where possible, perform file handling as a less-privileged user and only escalate for narrow, controlled operations that cannot be avoided.
  • Harden script logic: Replace ad-hoc rm -f and install calls on user-controlled paths with safer patterns, such as temporary directories, fixed filenames, or explicit whitelisting.
  • Enforce ownership and permissions: Ensure configuration files that influence privileged behavior are writable only by trusted, root-level principals, and not by service or application users.
  • Leverage sandboxing: Use systemd hardening (e.g., stricter ProtectSystem, ReadOnlyPaths, InaccessiblePaths) and dedicated service users to restrict the blast radius of any path misuse.

How teams detect issues like this

Detection generally involves inspecting both configuration and the behavior of privileged scripts:

  • Static analysis and code review:
  • Look for shell scripts or service units executed as root that read paths from configuration or environment and pass them directly to commands like rm, install, cp, mv, or redirection operators (>/>>).
  • Flag any use of configuration-controlled variables in file operations without path validation or restriction to a known safe directory.
  • Configuration audits:
  • Periodically scan Pi-hole configuration (and similar components) for unexpected absolute paths or references to sensitive locations such as /root/.ssh/authorized_keys, /etc/, or other critical directories.
  • File integrity and monitoring:
  • Use file integrity monitoring tools to alert on changes to high-value targets (e.g., authorized_keys, system service files) correlated with service restarts.
  • Policy enforcement in CI/CD:
  • Introduce automated checks that block changes adding or modifying root-executed scripts which consume untrusted configuration values without validation or confinement.
  • Runtime logging and alerts:
  • Enable verbose logging for systemd services and consider rules that flag suspicious patterns like repeated deletion and recreation of sensitive files during service lifecycle events.

Sources

SourceLink
github.comgithub.com/pi-hole/pi-hole/security/advisories/GHSA-6w8x-p785-6pm4

Frequently asked

questions

Exploitation is local: the attacker must already have Pi-hole service-level access or equivalent ability to modify its configuration. However, on systems where Pi-hole is exposed to multiple users, this can be a reliable path to full root compromise.

The attacker needs sufficient privileges to alter Pi-hole configuration that controls the files.pid path and to trigger a restart/stop/start of the pihole-FTL service. This can often be done by any account that can run Pi-hole administrative commands or write to its configuration files.

The safest approach is to ensure that any configuration-derived file path used by root-level scripts is constrained to a fixed, trusted directory and validated before use. Additionally, configuration files that affect privileged behavior should be writable only by root, and script logic should avoid generic delete/recreate operations on configurable paths.

When designing service hooks or maintenance scripts, treat configuration values as untrusted input: validate them, confine them to expected directories, and avoid allowing low-privilege users to influence paths used in privileged file operations. Combine this with least-privilege execution, strong filesystem permissions, and automated reviews that flag pattern mismatches between privilege level and configuration control.

Find out what's already
exploitable in your codebase.