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.leaseTimeparameter (e.g., admin-level or configuration-changing privileges) - Trigger point: Reloading or restarting
dnsmasq/FTL after the maliciousdhcp.leaseTimevalue is saved and written into active configuration - Why exploitation is possible: The application fails to correctly sanitize or constrain
dhcp.leaseTimevalues, allowing newline characters to terminate the intended setting and inject arbitrarydnsmasqdirectives, 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
leaseTimeare 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
dnsmasqdirectives, unexpected restarts, or shell commands invoked by the Pi-hole process, which may indicate attempted or successful exploitation.

