/

CVE-2026-35518

Severity:

HIGH RISK

(8.8)

Command Injection in Pi-hole FTL Engine

CVE-2026-35518

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 vulnerability in the dns.cnameRecords configuration parameter.

An authenticated attacker who can write crafted CNAME configuration data can inject arbitrary dnsmasq directives via newline characters and ultimately execute commands on the underlying system.

Affected context

This vulnerability occurs in Pi-hole deployments using FTLDNS (pihole-FTL) versions 6.0 through 6.5.x, where dns.cnameRecords is configurable via the interactive API or related management interfaces.

It becomes risky when attacker-controlled or weakly validated configuration values are written into dnsmasq configuration contexts, and those values are later interpreted as part of the DNS server configuration.

The issue is most relevant in environments where multiple users or automated systems can interact with Pi-hole's API or where configuration updates are exposed beyond a single trusted administrator.

Exploit preconditions

  • Attack surface: Pi-hole FTL interactive API or any interface that updates dns.cnameRecords.
  • Required access: Authenticated access to modify Pi-hole DNS configuration, including CNAME records or equivalent configuration structures.
  • Trigger point: Processing and persistence of dns.cnameRecords such that newline characters and attacker-supplied content are injected into dnsmasq configuration; subsequent reload or use of this configuration by the FTL engine.
  • Why exploitation is possible: User-controlled configuration data is concatenated into dnsmasq configuration without proper sanitization or normalization, allowing newline characters to break out of the intended parameter and inject arbitrary configuration directives that can be leveraged to reach OS command execution.

Why this happens

The core issue is improper handling of special characters and control sequences when mapping user-provided configuration values into dnsmasq configuration files or in-memory directives.

Instead of strictly validating or sanitizing dns.cnameRecords content, the implementation allows newline characters to be embedded, which breaks the configuration structure and enables injection of additional dnsmasq options.

This behavior maps to CWE-78 (OS Command Injection) because the injected configuration ultimately influences how commands or system-level actions are invoked, and to CWE-93 (Improper Neutralization of CRLF Sequences) due to the failure to neutralize newline (CR/LF) characters in a context where line-based configuration is parsed as executable directives.

Conceptually, it is an injection bug where untrusted input crosses a trust boundary into a configuration channel that controls downstream command execution.

Potential impact

  • Remote execution of arbitrary commands with the privileges of the Pi-hole FTL/dnsmasq process.
  • Complete compromise of the host running Pi-hole if the service has high or privileged access.
  • Modification or redirection of DNS responses to facilitate phishing, malware distribution, or traffic interception.
  • Establishment of persistence mechanisms or lateral movement within the local network environment.
  • Disruption of DNS service, leading to denial-of-service for dependent clients.

General mitigation guidance

Effective mitigation centers on hardening how configuration data is accepted, stored, and rendered into dnsmasq or other system-level components.

Recommended patterns include:

  • Strict input validation: Treat CNAME configuration as data only; enforce tight character whitelists (e.g., domain-name character sets), length limits, and structural validation before accepting or persisting values.
  • Normalization and encoding: Strip or reject control characters such as \n, \r, and other delimiters in any user-supplied input that will be mapped into line-based configuration; normalize data before concatenation.
  • Context-aware construction: Build configuration using structured APIs or templates that separate data from control, rather than string concatenation; avoid directly embedding raw user input into configuration files.
  • Least privilege execution: Run Pi-hole and associated DNS components with the minimum required OS privileges and restricted filesystem and network permissions to limit the blast radius of any compromise.
  • Configuration access controls: Restrict who and what can modify dns-related configuration via the API or UI, ensuring strong authentication, authorization, and logging for administrative actions.
  • Defense in depth: Combine network segmentation, OS-level sandboxing (e.g., chroot, containers, namespaces), and application-level rate limiting to reduce the overall exploitation surface.

How teams detect issues like this

To identify and monitor for this vulnerability class, organizations can adopt a combination of code-level and operational detection techniques:

  • Static analysis patterns:
  • Flag concatenation of user-controllable strings into configuration lines destined for dnsmasq or other interpreters.
  • Detect lack of sanitization or filtering for newline (\n, \r\n) and other control characters in API handlers dealing with DNS record parameters.
  • Highlight any code paths where configuration strings are written directly to configuration files without encoding or structural validation.
  • Code review signals:
  • Presence of APIs that allow arbitrary CNAME or DNS record values without clear validation logic.
  • Configuration-writing functions that accept raw input and construct line-based config using string interpolation or direct writes.
  • Missing or minimal boundary checks around domain-related fields, especially when those are used outside of pure DNS response generation.
  • Runtime and log-based detection:
  • Monitor dnsmasq or Pi-hole logs for unusual or malformed configuration entries or errors after configuration changes.
  • Alert on unexpected commands, processes, or child processes spawned by the DNS service account.
  • Implement audit logging and anomaly detection around administrative API calls modifying DNS configuration.

Automated security scanning tools, including SAST and policy-as-code engines, can help enforce these patterns across codebases and configuration repositories.

Sources

SourceLink
github.comgithub.com/pi-hole/FTL/security/advisories/GHSA-28g5-gg88-wh5m

Frequently asked

questions

It can be remotely exploitable if the Pi-hole API or management interface is exposed beyond the local network and an attacker can obtain valid credentials. In typical home or internal deployments where the admin interface is not internet-facing, exploitation is usually limited to the local network or systems with API reach.

The attacker must have authenticated access capable of modifying DNS configuration, specifically dns.cnameRecords or equivalent parameters. This could be through valid Pi-hole admin credentials, compromised API tokens, or another vector that grants configuration write privileges.

The safest pattern is to treat all configuration parameters as untrusted input, apply strict domain-specific validation, and ensure that any data written into configuration files is sanitized of control characters and delimiters. Configuration lines should be built using structured, context-aware APIs or templates that prevent mixing control syntax with raw user data.

Future development should incorporate secure coding guidelines for injection prevention: define clear trust boundaries, validate and normalize all user-controlled inputs, prevent CR/LF and other control characters in configuration contexts, and subject changes touching configuration and command execution paths to focused security review and automated static analysis checks.

Find out what's already
exploitable in your codebase.