/

CVE-2026-35519

Severity:

HIGH RISK

(8.8)

Command Injection in Pi-hole FTL dns.hostRecord

CVE-2026-35519

Analyzed

Vulnerability type

Category:

Command Injection

CWE:

CWE-78, CWE-93

Impact:

Remote Code Execution on the Pi-hole host system

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) versions 6.0 to before 6.6 contain a command injection vulnerability in the DNS host record configuration parameter (dns.hostRecord).

An authenticated attacker who can submit specially crafted host record values can inject arbitrary dnsmasq configuration directives via newline characters, which can ultimately lead to command execution on the underlying system.

Affected context

This vulnerability affects Pi-hole deployments using the FTL engine (FTLDNS) where:

  • The dns.hostRecord parameter can be modified through the API or administrative interface
  • User-supplied values are written into dnsmasq configuration without robust sanitization or normalization
  • The FTL service controls or influences the dnsmasq process responsible for DNS resolution

It is most relevant in environments where administrative or API-level access is shared, delegated, or integrated with other systems that may be compromised.

Exploit preconditions

  • Attack surface: Pi-hole FTL configuration interface and interactive API that manage DNS host records.
  • Required access: Authenticated access with permission to create or modify dns.hostRecord entries (directly or via an integrated system using the API).
  • Trigger point: Applying or reloading Pi-hole / dnsmasq configuration after saving a malicious host record containing newline characters and extra directives.
  • Why exploitation is possible: Input for dns.hostRecord is treated as text to be embedded into configuration. Newline injection allows attackers to escape the expected field and append arbitrary dnsmasq configuration directives, some of which can be chained to execute system commands under the privileges of the Pi-hole/dnsmasq process.

Why this happens

The underlying issue is improper handling of user-controlled configuration text that is written into dnsmasq configuration files or equivalent runtime configuration structures.

Instead of being strictly validated and normalized to a single, well-formed host record line, the dns.hostRecord parameter accepts content containing newline characters and characters meaningful to the configuration parser. This enables an attacker to break out of the intended context and append additional directives.

This maps to:

  • CWE-78: Improper Neutralization of Special Elements used in an OS Command, because crafted configuration ultimately allows attacker-controlled strings to influence or trigger OS-level commands.
  • CWE-93: Improper Neutralization of CRLF Sequences, since the vulnerability hinges on newline (line-break) injection to introduce unintended configuration lines.

Conceptually, the bug arises from treating partially trusted administrative input as if it were inherently safe to embed verbatim into lower-level configuration, without enforcing strict structure or character constraints.

Potential impact

  • Remote code execution on the Pi-hole host in the context of the FTL/dnsmasq service account
  • Full compromise of the Pi-hole instance, including access to DNS configuration and logs
  • Use of the compromised Pi-hole host as a pivot point for lateral movement within the network
  • Manipulation of DNS responses to enable phishing, traffic redirection, or on-path attacks
  • Disruption of DNS service, causing denial of service for dependent clients

General mitigation guidance

Effective mitigation focuses on constraining how configuration text is constructed and interpreted, and on minimizing the privileges of the affected service:

  • Treat all configuration fields, including dns.hostRecord, as potentially unsafe and normalize them to a strict, minimal syntax (e.g., enforcing a single line, disallowing newlines and meta-characters).
  • Implement robust input validation and encoding on configuration values before writing them to dnsmasq configuration, rejecting or escaping control characters and delimiters.
  • Use structured configuration generation (e.g., templates with parameter substitution) instead of concatenating raw user input into configuration files.
  • Apply least-privilege principles so that the DNS/FTL service runs with minimal OS-level permissions, limiting damage if configuration abuse occurs.
  • Separate administrative and machine-to-machine API credentials, and restrict who or what can modify host records.
  • Consider introducing server-side schema checks or typed models for configuration entries, ensuring only well-formed host records are accepted.

How teams detect issues like this

Detection typically involves both code-level and operational monitoring techniques:

  • Static analysis and code review:
  • Flag any logic that writes user-controlled or API-controlled values directly into configuration files without strong validation.
  • Look for acceptance of newline characters, CRLF sequences, or unbounded strings in configuration-related fields.
  • Identify string concatenation patterns that build dnsmasq or similar config lines from untrusted input.
  • Configuration and runtime auditing:
  • Periodically scan generated dnsmasq configuration for unexpected directives or anomalous patterns not normally produced by the UI.
  • Monitor process execution paths for unusual child processes spawned by dnsmasq/FTL or unexpected shell invocations.
  • Policy enforcement:
  • Require security review for any feature that allows arbitrary text in configuration fields.
  • Integrate automated configuration linting checks into deployment pipelines to detect injected directives.

Sources

SourceLink
github.comgithub.com/pi-hole/FTL/security/advisories/GHSA-wxhv-w77q-6qwp

Frequently asked

questions

It can be, but only if the Pi-hole admin or API interface is exposed and reachable by an attacker who can authenticate or abuse exposed credentials. In many home deployments Pi-hole is restricted to local networks, but in corporate or misconfigured environments it may be reachable from broader networks.

The attacker needs authenticated access with the ability to modify dns.hostRecord entries, either via the web interface or through the FTL API. Exploitation is not possible through ordinary unauthenticated DNS queries alone.

The safest pattern is to strictly sanitize and normalize configuration fields so they cannot contain newline characters or other control sequences, and to generate configuration using structured, parameterized templates rather than embedding raw user input. Any value that becomes part of a lower-level configuration file should be validated against a tight whitelist of allowed characters and formats.

Design configuration-handling code under the assumption that all externally supplied values are untrusted, including admin-input fields. Use strong input validation, reject or encode control characters, avoid passing user-controlled strings into shell or configuration contexts without strict transformation, and incorporate secure coding reviews and automated checks focusing on configuration generation and command invocation paths.

Find out what's already
exploitable in your codebase.