mirror of
https://github.com/RuoJi6/ARTEX.git
synced 2026-12-02 20:01:51 +08:00
- Implement full-traffic transparent gateway (cmd/artex-gateway, traffic/netstack.go, traffic/transparent.go) using Linux TUN + gVisor netstack deferred TCP handshakes (eliminating nmap/nc false-positive open ports), real ICMPv4 Echo proxying, UDP/DNS interception, and per-container upstream proxy overrides. - Add egress blacklist + asset-intercept sync, non-HTTP flow/DNS SQLite persistence and APIs, and /system/proxy & /function/traffic TCP/UDP/DNS UI panels. - Fix sandbox Playwright MCP browser loopback --proxy-server rewrite and NODE_EXTRA_CA_CERTS override in server/mcpstdio.go. - Strip all SUID/SGID binaries in Dockerfile.sandbox, grant minimal cap_net_raw+ep to nmap/nping/ping with ARTEX_SANDBOX_ALLOW_NET_RAW toggle, and enforce IPv4/IPv6 anti-spoofing in iptables and netstack. - Remove hardcoded Chinese "(全局)" from GET /api/proxy/routes, localize ContainerRoutesTab / NonHTTPTrafficPanel labels, and expose reactive locale/isEn from useLiveTranslation for React Compiler compatibility.
75 lines
3.2 KiB
Bash
Executable File
75 lines
3.2 KiB
Bash
Executable File
#!/bin/sh
|
|
# Close the host paths a sandbox container can use to reach ARTEX itself.
|
|
# The recording proxy already refuses loopback, metadata, postgres and the
|
|
# admin port. This script covers traffic that never enters the proxy:
|
|
# - packets from the sandbox bridge to the host's published :8787
|
|
# - packets routed from the sandbox bridge into the compose internal network
|
|
# (postgres, docker-socket-proxy, the ARTEX container)
|
|
# - packets toward the cloud metadata address
|
|
#
|
|
# Run on the Docker host after the networks exist. Safe to repeat.
|
|
set -eu
|
|
|
|
sandbox_net="${ARTEX_SANDBOX_NETWORK:-artex-sandbox}"
|
|
|
|
bridge_for() {
|
|
id=$(docker network inspect "$1" --format '{{.Id}}')
|
|
printf 'br-%.12s\n' "$id"
|
|
}
|
|
|
|
ensure() {
|
|
chain=$1
|
|
shift
|
|
if iptables -C "$chain" "$@" 2>/dev/null; then
|
|
return 0
|
|
fi
|
|
iptables -I "$chain" "$@"
|
|
}
|
|
|
|
if ! docker network inspect "$sandbox_net" >/dev/null 2>&1; then
|
|
echo "sandbox network $sandbox_net not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
sandbox_br=$(bridge_for "$sandbox_net")
|
|
ensure INPUT -i "$sandbox_br" -p tcp --dport 8787 -j REJECT
|
|
|
|
# If the ARTEX control-plane container is directly attached to artex-sandbox
|
|
# (SNAT-free source IP attribution, #218), allow ONLY sandbox -> ARTEX :8788
|
|
# (plus established return packets) while keeping enable_icc=false between
|
|
# sandbox containers and explicitly rejecting :8787.
|
|
artex_ct=$(docker ps --filter "network=$sandbox_net" --format '{{.Names}}' | awk '/artex/ && !/artex-sbx-/ {print; exit}')
|
|
if [ -n "$artex_ct" ]; then
|
|
artex_sbx_ip=$(docker inspect "$artex_ct" --format "{{with index .NetworkSettings.Networks \"$sandbox_net\"}}{{.IPAddress}}{{end}}")
|
|
if [ -n "$artex_sbx_ip" ]; then
|
|
ensure DOCKER-USER -i "$sandbox_br" -o "$sandbox_br" -d "$artex_sbx_ip/32" -p tcp --dport 8787 -j REJECT
|
|
ensure DOCKER-USER -i "$sandbox_br" -o "$sandbox_br" -s "$artex_sbx_ip/32" -m conntrack --ctstate ESTABLISHED,RELATED -j ACCEPT
|
|
ensure DOCKER-USER -i "$sandbox_br" -o "$sandbox_br" -d "$artex_sbx_ip/32" -p tcp --dport 8788 -j ACCEPT
|
|
fi
|
|
fi
|
|
|
|
# Compose prefixes the internal network with the project name.
|
|
internal_net=$(docker network ls --format '{{.Name}}' | awk '/artex-internal$/ {print; exit}')
|
|
if [ -n "$internal_net" ]; then
|
|
internal_cidr=$(docker network inspect "$internal_net" --format '{{(index .IPAM.Config 0).Subnet}}')
|
|
if [ -n "$internal_cidr" ]; then
|
|
# Published :8788 is DNATed onto the ARTEX container, which lives in this
|
|
# subnet. Let only that port through, then refuse postgres, the Docker
|
|
# socket proxy, and the admin port.
|
|
ensure DOCKER-USER -i "$sandbox_br" -d "$internal_cidr" -j REJECT
|
|
ensure DOCKER-USER -i "$sandbox_br" -d "$internal_cidr" -p tcp --dport 8788 -j RETURN
|
|
fi
|
|
fi
|
|
|
|
ensure DOCKER-USER -i "$sandbox_br" -d 169.254.169.254/32 -j REJECT
|
|
|
|
# Optional transparent gateway mode (#218 Phase 3): allow traffic routed into
|
|
# artex-tun0 (gVisor netstack) and reject any direct outbound NAT bypass.
|
|
if [ "${ARTEX_SANDBOX_TRANSPARENT:-false}" = "true" ] || [ "${ARTEX_SANDBOX_TRANSPARENT:-0}" = "1" ]; then
|
|
ensure DOCKER-USER -i "$sandbox_br" ! -o "$sandbox_br" -j REJECT
|
|
ensure DOCKER-USER -i "$sandbox_br" -o artex-tun0 -j ACCEPT
|
|
ensure DOCKER-USER -i artex-tun0 -o "$sandbox_br" -j ACCEPT
|
|
fi
|
|
|
|
echo "sandbox firewall applied on $sandbox_br"
|