Restrict outbound network to api.anthropic.com only
- New egress-proxy/ container (tinyproxy) that only allows CONNECT to api.anthropic.com, refuses everything else. - docker-compose.yml: sde-meeting-toolkit is no longer on 'default' at all. Its only networks are 'proxy' (NPM, inbound) and a new private 'egress' network shared only with egress-proxy. egress-proxy is the only container with a real internet route. - server.js: route the one outbound Anthropic call through EGRESS_PROXY_URL when set, using undici's own fetch + ProxyAgent together (mixing them with Node's global fetch throws a version mismatch error - caught this locally before it hit a real deploy). - Add undici as a real dependency (package.json, package-lock.json), npm ci step in Dockerfile. - Add smoke-test-egress.sh + Step 9b in DOCKER_TESTING.md to verify this whole chain with real Docker. - Update CHANGELOG.
This commit is contained in:
@@ -1,17 +1,20 @@
|
||||
# Standalone compose file for this tool.
|
||||
#
|
||||
# Joins the "proxy" Docker network so Nginx Proxy Manager can reach this
|
||||
# container by name (sde-meeting-toolkit) the same way it reaches Work
|
||||
# Package Suite's own internal nginx container. "proxy" must already exist
|
||||
# on the host; it is not created here (external: true), since NPM's own
|
||||
# stack owns it.
|
||||
# Network layout:
|
||||
# - "proxy": external, owned by Nginx Proxy Manager's own stack. Lets NPM
|
||||
# reach sde-meeting-toolkit by container name. No internet route.
|
||||
# - "egress": private to this compose file. The ONLY thing
|
||||
# sde-meeting-toolkit can reach besides "proxy". Used to talk to the
|
||||
# egress-proxy container below.
|
||||
# - "default": Compose's own auto-created network. Only egress-proxy is on
|
||||
# it, since it's the only container here that needs real internet access.
|
||||
#
|
||||
# Also stays on "default" (Compose's own auto-created network for this
|
||||
# project). "proxy" is scoped to proxy-to-backend traffic only and has no
|
||||
# route to the public internet, so without "default" too, the AI draft
|
||||
# button's outbound call to api.anthropic.com fails (502: "Could not reach
|
||||
# the Anthropic API"). Landing page and tool pages still work without it,
|
||||
# since those never leave the container, which is why this was easy to miss.
|
||||
# sde-meeting-toolkit itself is NOT on "default" and has no direct route to
|
||||
# the internet at all. Its one outbound call (the AI draft button, to
|
||||
# api.anthropic.com) is routed through egress-proxy via EGRESS_PROXY_URL,
|
||||
# which only forwards that one destination and refuses everything else
|
||||
# (see egress-proxy/tinyproxy.conf and egress-proxy/filter). A compromised
|
||||
# app container still can't reach anything but Anthropic's API.
|
||||
services:
|
||||
sde-meeting-toolkit:
|
||||
build: .
|
||||
@@ -22,6 +25,7 @@ services:
|
||||
environment:
|
||||
- MOCK_AI=${MOCK_AI:-false}
|
||||
- ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
|
||||
- EGRESS_PROXY_URL=${EGRESS_PROXY_URL:-http://egress-proxy:8888}
|
||||
- APP_USERS=${APP_USERS:-}
|
||||
- APP_USERNAME=${APP_USERNAME:-}
|
||||
- APP_PASSWORD=${APP_PASSWORD:-}
|
||||
@@ -40,11 +44,25 @@ services:
|
||||
- ./data:/app/data
|
||||
networks:
|
||||
- proxy
|
||||
- default
|
||||
- egress
|
||||
depends_on:
|
||||
- egress-proxy
|
||||
# Hardening for a container that's reachable from the public internet
|
||||
# (through Nginx Proxy Manager) and can itself reach the public internet
|
||||
# (api.anthropic.com). Neither of these needs any Linux capability the
|
||||
# app doesn't already have, and the app never needs to escalate privilege.
|
||||
# (through Nginx Proxy Manager). Neither of these needs any Linux
|
||||
# capability the app doesn't already have, and the app never needs to
|
||||
# escalate privilege.
|
||||
cap_drop:
|
||||
- ALL
|
||||
security_opt:
|
||||
- no-new-privileges:true
|
||||
|
||||
egress-proxy:
|
||||
build: ./egress-proxy
|
||||
container_name: sde-meeting-toolkit-egress-proxy
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- egress
|
||||
- default
|
||||
cap_drop:
|
||||
- ALL
|
||||
security_opt:
|
||||
@@ -53,3 +71,5 @@ services:
|
||||
networks:
|
||||
proxy:
|
||||
external: true
|
||||
egress:
|
||||
driver: bridge
|
||||
|
||||
Reference in New Issue
Block a user