container: pf Rule Injection via Domain Name Argument in `container system dns create --localhost` Command
Date: 2026-05
Affected: swift/github.com/apple/container
Attack vector: other
Category: vulnerability-disclosure
Severity: Low
CWE: CWE-20

#### Product Name: container Github Link: https://github.com/apple/container Version: <= 0.12.2 #### Summary The `container system dns create --localhost` command accepts a `domainName` argument and passes it unsanitized into the pf anchor file (`/etc/pf.anchors/com.apple.container`) as a comment in a rule line. A domain name containing a newline character breaks out of the comment context and injects an arbitrary pf rule into the anchor file. When `pfctl -f` subsequently loads the configuration, the attacker-controlled rule is loaded into the macOS kernel packet filter. A `isValidDomainName()` function exists in `Parser.swift:892` but is **never called** from `DNSCreate`. **The core harm caused by this vulnerability is the bypassing of sudo privileges. An administrator may have only granted a user or an automation tool such as CI/CD the ability to execute `container system dns create` with root privileges, expecting that the user or automation tool could only add redirects from other IPs to localhost in the firewall rules file via `--localhost`. However, an attacker can exploit this vulnerability to write arbitrary rules into the firewall rules file: the target address is no longer restricted to localhost, and the rules are no longer limited to redirects.** #### Impact **What a legitimate invocation can write** `--localhost` is an optional parameter. Its presence or absence determines whether any pf rule is written at all: - **Without `--localhost`**: only a res


Mitigations:

Architectural layers (MAESTRO):