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:
2026-09-29 18:16:35 -07:00
parent d6e83dcdf5
commit 77203955a5
12 changed files with 258 additions and 18 deletions

View File

@@ -121,6 +121,23 @@ Skip this step for a normal test run. The quota ships off by default; this is on
8. Run `docker compose restart`, then confirm `tester` is still blocked. The quota survives a restart because `data` is a mounted volume.
9. Remove `TOKEN_LIMIT_PER_USER` from `.env` and restart again to turn it back off.
## Step 9b: Test the egress restriction
The container has no direct route to the internet at all. Its one outbound call (the AI draft button) is forced through a second container, `egress-proxy`, which only allows that one destination and refuses everything else. This confirms that restriction actually holds, not just that the AI draft button still works.
1. Run:
```
bash smoke-test-egress.sh
```
2. This rebuilds and starts the full stack (`sde-meeting-toolkit` and `egress-proxy` together), then checks:
- the landing page still loads normally
- the app container cannot reach an unrelated site (`example.com`) directly
- `egress-proxy` refuses to forward to that same unrelated site
- `egress-proxy` does allow a tunnel to `api.anthropic.com`
- the AI draft endpoint still works end to end through the whole chain
3. A `PASS`/`FAIL` line prints for each check, with a summary count at the end. Any `FAIL` line explains what broke and points at the relevant log command.
4. For the last check to be a full test (not just "the server route responds"), set `MOCK_AI=false` with a real `ANTHROPIC_API_KEY` in `.env` first.
## Step 10: Stop the container
1. Run this command: