/

CVE-2026-35521

Severity:

HIGH RISK

(8.8)

Command Injection in Pi-hole FTL DHCP Hosts Parameter

CVE-2026-35521

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-78, CWE-93

Impact:

Remote Code Execution

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 FTL engine versions 6.0 to before 6.6 contain a command injection vulnerability in the dhcp.hosts configuration parameter exposed via the interactive API.

An authenticated attacker who can control this parameter can inject arbitrary dnsmasq configuration directives using newline characters, which can be leveraged to execute operating system commands on the underlying host.

Affected context

The vulnerability occurs in Pi-hole deployments using the FTL engine where the interactive API is exposed and the DHCP hosts configuration (dhcp.hosts) can be modified by authenticated users or services.

It is relevant in environments where:

  • Pi-hole FTL versions 6.0 to before 6.6 are in use
  • The FTL API or management interface is available over the network
  • DHCP host entries are dynamically managed through the API or integrated automation

The flaw is tied to how user-supplied values are translated into dnsmasq configuration without robust validation or sanitization of control characters and directive boundaries.

Exploit preconditions

  • Attack surface: Pi-hole FTL interactive API / management interface that exposes the dhcp.hosts configuration parameter.
  • Required access: Authenticated access with permission to configure or update DHCP hosts; often panel/API credentials, API tokens, or access to a trusted integration.
  • Trigger point: Submission or update of dhcp.hosts values containing newline characters and crafted payloads that are written into the generated dnsmasq configuration and subsequently loaded or reloaded by the service.
  • Why exploitation is possible: The FTL engine treats the dhcp.hosts parameter as opaque text and embeds it directly into dnsmasq configuration files or equivalent input, without stripping newline characters or enforcing a strict schema. This enables injection of additional dnsmasq directives, some of which can be abused to reach OS command execution in the runtime environment.

Why this happens

The underlying issue is a combination of improper input validation and command injection through configuration channels, primarily aligning with CWE-78: Improper Neutralization of Special Elements used in an OS Command and CWE-93: Improper Neutralization of CRLF Sequences in HTTP Headers-like newline handling patterns.

Instead of treating dhcp.hosts inputs as structured data with a strict format, the FTL engine accepts arbitrary strings that may include newline characters. These newline sequences prematurely terminate the intended configuration line and start new dnsmasq configuration directives. Because dnsmasq can be configured in ways that ultimately influence command execution or system behavior, this uncontrolled directive injection escalates into remote code execution. The bug class is thus the failure to sanitize metacharacters and separators (such as \n) before passing user-controlled data into a configuration context that ultimately drives system-level commands.

Potential impact

  • Execution of arbitrary OS commands under the privileges of the Pi-hole / FTL process
  • Full compromise of the Pi-hole host, including reading or modifying local files accessible to the service account
  • Alteration or poisoning of DNS/DHCP behavior, enabling network-wide traffic redirection or denial-of-service
  • Use of the compromised Pi-hole instance as a pivot point to move laterally within the network
  • Persistent backdoor installation or deployment of additional malware on the host system

General mitigation guidance

Robust mitigation focuses on sanitizing configuration inputs and constraining how user data reaches lower-level services:

  • Strict input validation and encoding: Treat dhcp.hosts and similar parameters as structured data with a well-defined grammar. Reject or escape newline characters, carriage returns, and other control characters that can break out of the intended configuration line.
  • Configuration templating with strong typing: Generate dnsmasq configuration from typed data structures rather than raw string concatenation. Use templates or libraries that handle escaping and avoid direct injection of user-controlled segments.
  • Whitelist-based schema enforcement: Limit DHCP host configuration fields to safe character sets (e.g., alphanumerics, hyphens, and dots) and apply length checks and pattern constraints before persisting values.
  • Privilege minimization: Run Pi-hole / FTL and dnsmasq with the least privileges necessary, and restrict file system and OS capabilities so that even if configuration is abused, the impact is reduced.
  • Separation of control and data channels: Avoid configuration designs where a user-controlled field can directly influence control directives; separate user data from administrative directives wherever possible.

How teams detect issues like this

Detection can be approached at both code and operational levels:

  • Static analysis and code review:
  • Flag any paths where user-controlled configuration fields are concatenated into dnsmasq or other service configuration files without explicit sanitization.
  • Look for acceptance of raw newline characters (\n, \r\n) in API parameters that are later written to configuration files.
  • Review configuration rendering logic for absence of schema validation, escaping, or character whitelisting.
  • Configuration and runtime monitoring:
  • Monitor generated dnsmasq configuration files for unexpected or non-standard directives, especially those including shell commands or external program hooks.
  • Alert on suspicious changes to configuration files outside expected workflows (e.g., unusual directives inserted shortly after API calls).
  • Policy and CI/CD checks:
  • Introduce security-focused unit tests or integration tests that attempt to inject newline characters and control sequences into configuration-related parameters and verify they are rejected or safely encoded.
  • Use automated security scanners or SAST tools configured with rules for newline/CRLF injection and configuration injection patterns.

Sources

SourceLink
github.comgithub.com/pi-hole/FTL/security/advisories/GHSA-vfmq-jrx3-wv3c

Frequently asked

questions

Yes, in typical deployments it is remotely exploitable, but it requires authenticated access to the Pi-hole FTL API or management interface that controls the dhcp.hosts configuration. An external attacker would need valid credentials, an exposed management endpoint, or control of an integration that is allowed to push DHCP host entries.

The attacker must be able to authenticate as a user or service account with permissions to modify the DHCP hosts configuration parameter. This could be an administrative web interface user, an API token holder, or an automated system with configuration rights.

The core fix pattern is to enforce strict validation and encoding for any user-supplied configuration values before writing them into dnsmasq or other downstream configuration files. This includes rejecting newline/control characters, applying character whitelists, and generating configurations from structured, typed data instead of raw string concatenation.

Treat all configuration input as untrusted, even when it comes from authenticated users. Define clear schemas for configuration fields, validate against those schemas, and rely on parameterized or templated configuration generation. Combine this with regular security-focused code reviews, static analysis rules targeting configuration injection and command injection, and principle-of-least-privilege deployment practices.

Find out what's already
exploitable in your codebase.