/

CVE-2026-35517

Severity:

HIGH RISK

(8.8)

Command Injection in Pi-hole FTL (FTLDNS)

CVE-2026-35517

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 remote code execution vulnerability in the dns.upstreams configuration parameter that backs the interactive API and web interface statistics.

An authenticated attacker who can modify upstream DNS settings can inject arbitrary dnsmasq configuration directives via newline characters, which can be abused to execute commands on the underlying system.

Affected context

The vulnerability exists in Pi-hole deployments using FTL (FTLDNS) versions 6.0 to before 6.6 where the upstream DNS servers (dns.upstreams) can be configured through the interactive API or linked administrative interfaces.

It manifests in environments where user-controlled configuration values are translated into dnsmasq configuration without robust sanitization of special characters such as newlines.

This typically affects Pi-hole instances exposed to authenticated users (local or remote) who have permission to manage DNS settings.

Exploit preconditions

  • Attack surface: Pi-hole FTL API / configuration interface that sets the dns.upstreams value.
  • Required access: Valid authenticated access with privileges to modify upstream DNS configuration (e.g., admin web access, API token).
  • Trigger point: Saving or updating the dns.upstreams parameter so that FTL generates or passes modified dnsmasq configuration and reloads/applies it.
  • Why exploitation is possible: The application fails to properly sanitize or constrain the dns.upstreams input, allowing newline characters and additional dnsmasq configuration directives to be injected. Those injected directives can be crafted to influence how commands or scripts are invoked, resulting in command execution on the host.

Why this happens

This issue stems from treating a partially trusted configuration parameter (dns.upstreams) as if it were safe to interpolate directly into dnsmasq configuration without strict validation or encoding.

By allowing newline characters and not enforcing a strict schema (e.g., only valid IP addresses or hostnames), the software effectively permits arbitrary configuration lines to be appended or inserted.

This maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, because user-controllable data affects command-related behavior, and secondarily to CWE-93: Improper Neutralization of CRLF Sequences, since line breaks are used to escape the intended configuration context.

Abstractly, the insecure pattern is: user-controlled text is concatenated into a configuration or command boundary without filtering metacharacters that alter structure and semantics.

Potential impact

  • Remote execution of arbitrary commands with the privileges of the Pi-hole FTL/dnsmasq process.
  • Complete compromise of the Pi-hole host system, including potential pivoting to adjacent services.
  • Manipulation of DNS behavior to redirect, block, or spoof traffic.
  • Installation of persistent malware or backdoors on the system.
  • Exfiltration or tampering with DNS logs and configuration data.

General mitigation guidance

Effective mitigation focuses on constraining and validating configuration inputs and reducing the impact of any misconfiguration:

  • Strict input validation and typing: Treat dns.upstreams as a structured value (e.g., an array of IP addresses/hostnames) and validate against a whitelist of allowed patterns, disallowing control characters, whitespace beyond separators, and any non-address tokens.
  • Context-aware encoding: When rendering user-supplied data into configuration files or command lines, ensure it is escaped or encoded so that metacharacters cannot break out of the intended field.
  • Configuration schema enforcement: Use a schema or typed configuration model that only allows well-formed upstream entries, rejecting values that do not conform.
  • Least-privilege execution: Run the DNS/FTL components with minimal privileges and limited filesystem/OS access to reduce the blast radius of any command execution.
  • Separation of concerns: Avoid direct, implicit translation of user-facing configuration into low-level dnsmasq directives; instead, map high-level options to a constrained set of generated directives.
  • Defense-in-depth controls: Restrict administrative access to the Pi-hole UI/API, use strong authentication, and limit network exposure of the management interfaces.

How teams detect issues like this

Detection can combine code-level analysis, configuration review, and runtime monitoring:

  • Static analysis: Scan for paths where user or API input is written into configuration files or used to influence command execution without robust validation or encoding. Patterns include concatenation of raw strings into dnsmasq config templates or shell command arguments.
  • Code review signals: Look for:
  • Configuration-building logic that interpolates user data directly into text templates.
  • Lack of validation on upstream DNS values (e.g., accepting arbitrary strings instead of validated IPs/hostnames).
  • Handling of newline or control characters in configuration-related fields.
  • Policy enforcement: Introduce coding standards requiring:
  • Structured parsing and validation for configuration parameters.
  • Prohibiting shell invocation or command construction using untrusted input even indirectly via configuration.
  • Runtime monitoring: Track abnormal command executions or dnsmasq invocations triggered after configuration changes, and inspect configuration files for unexpected extra directives.
  • Automated tooling: Integrate SAST/linters and infrastructure-as-code scanners into CI/CD pipelines to flag command-injection-prone patterns and unsafe configuration template handling.

Sources

SourceLink
github.comgithub.com/pi-hole/FTL/security/advisories/GHSA-23w8-7333-p9fj

Frequently asked

questions

Yes, if the Pi-hole management interface or API is exposed over the network and an attacker can authenticate, they may be able to exploit this remotely by modifying the dns.upstreams configuration.

The attacker generally needs authenticated access with permissions to configure upstream DNS servers, such as administrative access to the Pi-hole web UI or an associated API token.

Treat configuration values as strongly typed data, not free-form text. Enforce strict validation of upstream DNS entries (only valid IP addresses/hostnames), reject any inputs containing control characters like newlines, and generate dnsmasq configuration from a constrained set of templates that cannot be extended by user input.

Design configuration paths with clear trust boundaries, avoid passing user-controlled strings directly into configuration or command contexts, use schema-based validation, and adopt secure coding standards that mandate input sanitization, least-privilege execution, and automated security checks in the development pipeline.

Find out what's already
exploitable in your codebase.