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:
- An attacker-controlled endpoint could return one IP during the initial resolution and a different IP afterward.
- 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.
- 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.comchanges its IP addresses, the firewall would block legitimate traffic to the new IPs.
Suggested fix
- Periodically re-resolve DNS and update the ipset entries.
- Consider using dnsmasq or a similar DNS-aware firewall solution that can match on domain names rather than resolved IPs.
- Add TTL-aware DNS resolution that refreshes entries before they expire.
Environment
- File:
codex-cli/scripts/init_firewall.sh, lines 47-62
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗