/

CVE-2026-35520

Severity:

HIGH RISK

(8.8)

Command Injection in Pi-hole FTL (FTLDNS)

CVE-2026-35520

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 (FTLDNS) from versions 6.0 to before 6.6 contains a command injection issue in the DHCP lease time configuration parameter (dhcp.leaseTime).

An authenticated attacker who can set this parameter may inject arbitrary dnsmasq configuration directives using newline characters, leading to remote code execution on the underlying system when the configuration is processed.

Affected context

This vulnerability affects Pi-hole deployments using the FTL (FTLDNS) engine with DHCP functionality configured and exposed through its interactive API or web interface.

In vulnerable versions, user-provided values for dhcp.leaseTime are written into configuration in a way that allows embedded newline characters to break out of the intended field and introduce additional dnsmasq directives.

Environments where administrative access to Pi-hole's web UI or API is more broadly granted, or where API tokens are weakly protected, are at higher risk.

Exploit preconditions

  • Attack surface: Pi-hole FTL API and/or Web interface handling DHCP configuration
  • Required access: Authenticated control over the dhcp.leaseTime parameter (e.g., admin-level or configuration-changing privileges)
  • Trigger point: Reloading or restarting dnsmasq/FTL after the malicious dhcp.leaseTime value is saved and written into active configuration
  • Why exploitation is possible: The application fails to correctly sanitize or constrain dhcp.leaseTime values, allowing newline characters to terminate the intended setting and inject arbitrary dnsmasq directives, some of which can be abused to execute system commands when interpreted by the underlying runtime or shell.

Why this happens

The root cause is improper neutralization of special characters in user-controlled configuration data, specifically newline and control characters within dhcp.leaseTime.

Instead of being treated as a single bounded value, the input is written verbatim into a configuration context where newlines have structural meaning.

This corresponds primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command ('OS Command Injection'), because attacker-controlled configuration ultimately influences command execution, and to CWE-93: Improper Neutralization of CRLF Sequences ('CRLF Injection'), because line breaks are abused to alter the structure of generated configuration.

The insecure pattern is trusting configuration parameters that are later used to construct or modify files or commands without strict validation and encoding, allowing attackers to escape their intended field and introduce new directives that change program behavior.

Potential impact

  • Remote execution of arbitrary commands with the privileges of the Pi-hole FTL/dnsmasq service
  • Complete compromise of the host device running Pi-hole (e.g., home router, server, or appliance)
  • Modification or poisoning of DNS responses for clients relying on the Pi-hole instance
  • Pivoting to other systems on the same network using the compromised host as a foothold
  • Installation of backdoors, malware, or persistence mechanisms on the Pi-hole host

General mitigation guidance

Effective mitigation centers on constraining and sanitizing configuration input and reducing the blast radius of any misconfigurations.

Recommended defensive patterns include:

  • Treat all configuration fields, even in authenticated admin interfaces, as untrusted input that must be strictly validated against expected formats (e.g., numeric ranges for time values).
  • Reject or escape newline, carriage return, and other control characters in configuration values that are written into files or used in command arguments.
  • Generate configuration files using structured templates and parameter binding APIs rather than string concatenation, ensuring each field occupies exactly one syntactic slot.
  • Enforce whitelists or strongly typed representations for sensitive parameters such as lease times, ports, and paths, rather than accepting arbitrary strings.
  • Run DNS and DHCP services with least privilege (e.g., non-root users, restricted capabilities, and confined via sandboxing or containers) so that even if command execution occurs, system-wide impact is reduced.
  • Limit access to administrative interfaces and API tokens, and segment management networks away from general user traffic.

How teams detect issues like this

Organizations can look for this and similar issues using a mix of code-level and operational monitoring techniques:

  • Static analysis: Create rules or patterns that flag direct insertion of user-controlled strings into configuration files, shell commands, or arguments without explicit validation and escaping. Specially watch for acceptance of newline characters and concatenation operations around config-writing code.
  • Code review: During manual review, scrutinize any feature that allows runtime configuration changes, especially where strings are serialized into configuration files or command-line flags. Ensure parameters like leaseTime are treated as numeric or constrained types.
  • Configuration policy checks: Implement automated tests or CI checks that attempt to inject newline characters or suspicious tokens in configuration-related inputs and verify they are rejected or safely encoded.
  • Runtime monitoring: Monitor logs for anomalous dnsmasq directives, unexpected restarts, or shell commands invoked by the Pi-hole process, which may indicate attempted or successful exploitation.

Sources

SourceLink
github.comgithub.com/pi-hole/FTL/security/advisories/GHSA-fqv2-qhfh-ghcj

Frequently asked

questions

It can be exploitable remotely if the Pi-hole admin interface or API is exposed beyond a trusted network and an attacker can authenticate or otherwise obtain configuration-changing privileges. In many home setups, access is limited to the local network, which still allows remote attack from any device on that network.

The attacker must be able to modify the dhcp.leaseTime parameter via the Pi-hole interface or API. This typically requires an authenticated admin session or equivalent API token, so compromise of admin credentials or tokens is a key prerequisite.

Treat configuration fields as strictly typed data and enforce rigid validation on input, especially for values written into configuration files consumed by other processes. Disallow control characters, avoid raw string concatenation when generating configurations, and ensure no user-controlled parameter can alter file structure or command syntax.

Adopt a defense-in-depth approach: apply strict input validation and encoding, use configuration templating instead of ad-hoc string building, run services with minimal privileges, and include security-focused code review and static analysis in the development pipeline to catch injection patterns early.

Find out what's already
exploitable in your codebase.