Skip to content

container: pf Rule Injection via Domain Name Argument in `container system dns create --localhost` Command

Low severity GitHub Reviewed Published Apr 30, 2026 in apple/container • Updated May 7, 2026

Package

swift github.com/apple/container (Swift)

Affected versions

<= 0.12.2

Patched versions

0.12.3

Description

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 resolver config file is written; no pf rule is produced.
  • With --localhost <IP>: exactly one rule is written to the pf anchor file:
rdr inet from any to <IP> -> 127.0.0.1 # <domain>

The redirect destination is hard-coded to 127.0.0.1. The rule type is always rdr inet. There is no legitimate way to produce a rule that redirects traffic to any IP other than 127.0.0.1, nor to produce pass, block, or nat rules, through normal command usage.

What injection additionally enables

The injection lives in the domain name argument. --localhost must be supplied to trigger the createRedirectRule() code path — without it, no pf rule is written at all and the domain name never reaches the pf anchor file. However, the value passed to --localhost is unconstrained (only IP format is validated), so any valid IP suffices to open the injection path.

sudo container system dns create --localhost 127.0.0.1 \
  $'foo.local\nrdr inet from any to 1.2.3.4 -> 5.6.7.8'

The --localhost value becomes the from IP in the legitimate rule. The injected content after the newline is an entirely independent pf directive with fully attacker-controlled from and to values.

The capability gap between normal use and injection is therefore:

Normal use (no --localhost) Normal use (with --localhost) Injection (with --localhost, domain contains \n)
Writes pf rule No Yes Yes
from IP User-specified Arbitrary
to IP Hard-coded 127.0.0.1 Arbitrary
Rule type rdr inet only Any (pass, block, nat, …)

The single capability that injection uniquely adds is: writing a pf rule with an arbitrary to IP — redirecting traffic to any external host rather than being confined to 127.0.0.1.

Primary scenario: sudo delegation bypass

The most direct attack path requires only that an administrator grants a restricted user sudo access to this specific command:

# /etc/sudoers
user ALL=(root) NOPASSWD: /usr/bin/container system dns create *

The administrator's intent is to allow user to manage DNS domains for container networking. Under normal usage this is bounded: even with --localhost, the command can only produce rdr ... -> 127.0.0.1 rules. Without --localhost, it produces no pf rules at all.

With the injection, the user provides any valid IP to --localhost to open the pf write path, then embeds the actual malicious rule in the domain name:

sudo container system dns create --localhost 127.0.0.1 \
  $'evil.local\nrdr inet proto tcp from any to 10.0.0.1 -> 203.0.113.1 port 4444'

This is a classic sudo delegation bypass: the administrator delegated a scoped capability; the injection expands it to writing arbitrary kernel firewall rules.

Additional scenarios:

  • An automated script or CI/CD pipeline that runs sudo container system dns create $DOMAIN_FROM_ENV where the environment variable originates from a container label, image metadata, or external API response — any newline in the upstream value triggers injection without any user action
  • A developer following documentation or a README that includes a crafted domain name example (social engineering)

Consequences of successful injection:

  • pf redirect rules with arbitrary from and to IPs — enabling redirection of any host-level traffic to an attacker-controlled external address (not achievable through normal command use)
  • Additional rule types (pass, block, nat) with arbitrary port and protocol filters loaded into the kernel
  • Legitimate traffic selectively blocked (denial of service against specific endpoints)
  • Injected rules persist across DNS domain deletions — the removeRedirectRule() cleanup path cannot match and remove standalone injected lines

Credit

This vulnerability was independently discovered and reported by multiple sources:

  • XlabAI Team of Tencent Xuanwu Lab
  • Atuin Automated Vulnerability Discovery Engine
  • Mohamed Abdelaal (@0xmrma)

References

@madrob madrob published to apple/container Apr 30, 2026
Published to the GitHub Advisory Database May 7, 2026
Reviewed May 7, 2026
Last updated May 7, 2026

Severity

Low

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v4 base metrics

Exploitability Metrics
Attack Vector Local
Attack Complexity Low
Attack Requirements None
Privileges Required Low
User interaction None
Vulnerable System Impact Metrics
Confidentiality Low
Integrity Low
Availability Low
Subsequent System Impact Metrics
Confidentiality None
Integrity None
Availability None

CVSS v4 base metrics

Exploitability Metrics
Attack Vector: This metric reflects the context by which vulnerability exploitation is possible. This metric value (and consequently the resulting severity) will be larger the more remote (logically, and physically) an attacker can be in order to exploit the vulnerable system. The assumption is that the number of potential attackers for a vulnerability that could be exploited from across a network is larger than the number of potential attackers that could exploit a vulnerability requiring physical access to a device, and therefore warrants a greater severity.
Attack Complexity: This metric captures measurable actions that must be taken by the attacker to actively evade or circumvent existing built-in security-enhancing conditions in order to obtain a working exploit. These are conditions whose primary purpose is to increase security and/or increase exploit engineering complexity. A vulnerability exploitable without a target-specific variable has a lower complexity than a vulnerability that would require non-trivial customization. This metric is meant to capture security mechanisms utilized by the vulnerable system.
Attack Requirements: This metric captures the prerequisite deployment and execution conditions or variables of the vulnerable system that enable the attack. These differ from security-enhancing techniques/technologies (ref Attack Complexity) as the primary purpose of these conditions is not to explicitly mitigate attacks, but rather, emerge naturally as a consequence of the deployment and execution of the vulnerable system.
Privileges Required: This metric describes the level of privileges an attacker must possess prior to successfully exploiting the vulnerability. The method by which the attacker obtains privileged credentials prior to the attack (e.g., free trial accounts), is outside the scope of this metric. Generally, self-service provisioned accounts do not constitute a privilege requirement if the attacker can grant themselves privileges as part of the attack.
User interaction: This metric captures the requirement for a human user, other than the attacker, to participate in the successful compromise of the vulnerable system. This metric determines whether the vulnerability can be exploited solely at the will of the attacker, or whether a separate user (or user-initiated process) must participate in some manner.
Vulnerable System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the VULNERABLE SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the VULNERABLE SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the VULNERABLE SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
Subsequent System Impact Metrics
Confidentiality: This metric measures the impact to the confidentiality of the information managed by the SUBSEQUENT SYSTEM due to a successfully exploited vulnerability. Confidentiality refers to limiting information access and disclosure to only authorized users, as well as preventing access by, or disclosure to, unauthorized ones.
Integrity: This metric measures the impact to integrity of a successfully exploited vulnerability. Integrity refers to the trustworthiness and veracity of information. Integrity of the SUBSEQUENT SYSTEM is impacted when an attacker makes unauthorized modification of system data. Integrity is also impacted when a system user can repudiate critical actions taken in the context of the system (e.g. due to insufficient logging).
Availability: This metric measures the impact to the availability of the SUBSEQUENT SYSTEM resulting from a successfully exploited vulnerability. While the Confidentiality and Integrity impact metrics apply to the loss of confidentiality or integrity of data (e.g., information, files) used by the system, this metric refers to the loss of availability of the impacted system itself, such as a networked service (e.g., web, database, email). Since availability refers to the accessibility of information resources, attacks that consume network bandwidth, processor cycles, or disk space all impact the availability of a system.
CVSS:4.0/AV:L/AC:L/AT:N/PR:L/UI:N/VC:L/VI:L/VA:L/SC:N/SI:N/SA:N/E:P

EPSS score

Weaknesses

Improper Input Validation

The product receives input or data, but it does not validate or incorrectly validates that the input has the properties that are required to process the data safely and correctly. Learn more on MITRE.

CVE ID

No known CVE

GHSA ID

GHSA-39g5-644c-qwcg

Source code

Credits

Loading Checking history
See something to contribute? Suggest improvements for this vulnerability.