Security: init_firewall.sh does not re-resolve DNS, allowing DNS rebinding bypass

Resolved 💬 1 comment Opened Apr 20, 2026 by hobostay Closed Apr 22, 2026

Description

In codex-cli/scripts/init_firewall.sh, the firewall resolves allowed domains to IP addresses once at startup (lines 47-62) and stores them in an ipset:

for domain in "${ALLOWED_DOMAINS[@]}"; do
    ips=$(dig +short A "$domain")
    # ... adds IPs to ipset
done

This creates a DNS rebinding vulnerability:

  1. An attacker-controlled endpoint could return one IP during the initial resolution and a different IP afterward.
  2. The TTL of DNS responses is not checked. If a domain's DNS record changes, the firewall will continue allowing the old IP (which may no longer be the intended service) and block the new IP.
  3. The ipset is never refreshed, so any DNS changes are not reflected.

Impact

  • If a previously-resolved IP is reassigned to a malicious service, traffic to that IP would still be allowed through the firewall.
  • If api.openai.com changes its IP addresses, the firewall would block legitimate traffic to the new IPs.

Suggested fix

  1. Periodically re-resolve DNS and update the ipset entries.
  2. Consider using dnsmasq or a similar DNS-aware firewall solution that can match on domain names rather than resolved IPs.
  3. Add TTL-aware DNS resolution that refreshes entries before they expire.

Environment

  • File: codex-cli/scripts/init_firewall.sh, lines 47-62

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗