/

CVE-2026-33765

Severity:

CRITICAL RISK

(9.8)

OS Command Injection in Pi-hole Admin Interface

CVE-2026-33765

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78

Impact:

Remote Code Execution with Elevated Privileges

Severity:

CRITICAL RISK

(9.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 Admin Interface versions prior to 6.0 contain an OS command injection flaw in savesettings.php, where user-supplied input from the webtheme POST parameter is concatenated into a shell command executed via PHP's exec().

Because this command is run with sudo privileges and the input is not sanitized or validated, an attacker who can reach the admin interface can inject arbitrary system commands that execute with elevated (likely root) privileges.

Affected context

The vulnerability occurs in the Pi-hole Admin Interface, specifically within the savesettings.php handler that processes configuration changes, including the selected web theme.

It affects deployments running versions prior to 6.0 where:

  • The web admin interface is accessible over the network (LAN or WAN)
  • The savesettings.php endpoint is reachable and processes the $_POST['webtheme'] parameter
  • The backend invokes shell commands using exec() with sudo permissions

Risk increases significantly when the admin interface is exposed beyond a tightly controlled internal network or when multiple users can access the panel.

Exploit preconditions

  • Attack surface: HTTP(S) interface of the Pi-hole Admin UI, specifically requests that trigger savesettings.php.
  • Required access: Ability to send POST requests to the admin interface. In many deployments this may require authentication, but misconfigurations could expose it more broadly.
  • Trigger point: Submitting a request where $_POST['webtheme'] contains injected shell metacharacters or command fragments.
  • Why exploitation is possible: The value of $_POST['webtheme'] is directly concatenated into a shell command that is executed using PHP's exec() with sudo, without sanitization, validation, escaping, or use of safer command invocation APIs. This aligns with CWE-78: improper neutralization of special elements used in an OS command.

Why this happens

The core issue is the direct interpolation of untrusted HTTP POST data into a shell command line.

In savesettings.php, the webtheme parameter is assumed to be a benign value and is appended to a command string that is passed to exec(), which delegates execution to the operating system shell.

Without strict validation or escaping, shell metacharacters (such as separators, redirection operators, or subshell constructs) can alter the intended command and introduce additional, attacker-controlled commands.

Conceptually, this reflects the CWE-78 pattern: application logic builds OS commands by string concatenation rather than using parameterized or non-shell execution APIs, and it incorrectly treats user input as data-only, when the shell treats it as both data and executable syntax.

Potential impact

  • Remote execution of arbitrary commands on the Pi-hole host.
  • Execution of injected commands with elevated (likely root) privileges due to sudo usage.
  • Installation of malware, backdoors, or persistent agents on the underlying system.
  • Modification or exfiltration of configuration files, logs, or other sensitive data.
  • Lateral movement within the local network by using the compromised Pi-hole host as a pivot.
  • Disruption of DNS and ad-blocking services, causing denial of service or traffic manipulation.

General mitigation guidance

Effective mitigation focuses on eliminating shell command construction from untrusted data and reducing the privilege and exposure of management interfaces.

Recommended defensive patterns include:

  • Avoid constructing shell commands via string concatenation; instead, use language-native APIs or libraries that do not invoke a shell, or use parameterized command-execution functions that treat arguments as opaque data.
  • Apply strict allow-list validation to user-supplied parameters like webtheme, accepting only known-good identifiers and rejecting all other input.
  • If shell commands must be used, employ robust escaping and argument separation, and avoid passing user input through a shell interpreter wherever possible.
  • Run web application components with the least privileges required, avoiding sudo or root execution for routine configuration updates.
  • Restrict network access to the admin interface (e.g., limit to trusted management networks or VPN) and apply strong authentication controls to reduce who can reach the vulnerable functionality.

How teams detect issues like this

Detection can target both code-level patterns and runtime behavior:

  • Static analysis rules for PHP that flag usage of exec(), system(), passthru(), shell_exec(), or backticks with interpolated variables or direct use of $_POST, $_GET, $_REQUEST, or other superglobals.
  • Code review checklists that specifically require justification and scrutiny for any shell command construction, focusing on where user input is involved and whether allow-list validation is enforced.
  • Security linters or SAST tools configured to identify OS command injection sinks and flows from HTTP request parameters to command execution.
  • Runtime monitoring or intrusion detection that looks for unusual process executions originating from the web server user, especially commands commonly used in post-exploitation (e.g., downloaders, archive tools, reverse shells).
  • Logging and alerting around changes to Pi-hole configuration and unusual admin interface activity patterns, such as unexpected theme changes or bursts of POST requests to savesettings.php.

Sources

SourceLink
github.comgithub.com/pi-hole/web/security/advisories/GHSA-828h-5x96-rqx7

Frequently asked

questions

Yes. If an attacker can reach the Pi-hole Admin Interface and send crafted POST requests to the affected endpoint, they can exploit the vulnerability remotely, subject to any authentication or network access controls in place.

In many typical deployments, changing settings via savesettings.php is tied to the authenticated admin session, so valid credentials or session hijacking may be required.

However, if the admin interface is exposed without proper authentication or is misconfigured, an unauthenticated attacker could potentially exploit the flaw.

The safest pattern is to remove direct shell invocation from HTTP request paths: use high-level APIs rather than shell commands, strictly allow-list acceptable parameter values (such as known theme names), and never concatenate raw user input into command strings.

Establish secure coding guidelines that forbid constructing shell commands from untrusted input, enforce code reviews and automated checks for command-execution functions, apply least-privilege to application processes, and keep admin interfaces tightly restricted to trusted users and networks.

Find out what's already
exploitable in your codebase.