Egress Broker (docker/egress_broker.py)

crawl4ai-cobaltai · infra, Infra / DevOps, ssrf, egress, security, networking, docker

Validates and pins outbound IPs, blocking non‑global addresses to prevent SSRF in Docker deployments.

# Source: https://github.com/mperkins0155/crawl4ai-cobaltai | License: Apache-2.0
# Provided via justclaw.it.com; keep this notice with the code.
"""
egress_broker.py - the single rule and primitive for all outbound traffic.

Every SSRF defense before this was enumerate-badness (a hand-maintained list of
blocked CIDRs) and resolve-then-discard: the validator resolved a hostname,
checked the IP against the list, then threw the IP away and let the real
connection re-resolve (DNS rebinding / TOCTOU). It also missed whole families:
the IPv6 unspecified ::, NAT64 64:ff9b::/96, 6to4 2002::/16, and
host.docker.internal as anything but a literal prefix.

This module replaces the blocklist with one rule:

    reject any resolved IP where `not ip.is_global`

evaluated on every transition-embedded IP

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search 40K more like it.

Get a free API key