Skip to content

fix(privacy): install Tor-egress firewall before containers start — close startup window (#276)#277

Merged
VijitSingh97 merged 2 commits into
developfrom
feat/276-tor-egress-startup-window
Jun 17, 2026
Merged

fix(privacy): install Tor-egress firewall before containers start — close startup window (#276)#277
VijitSingh97 merged 2 commits into
developfrom
feat/276-tor-egress-startup-window

Conversation

@VijitSingh97

Copy link
Copy Markdown
Collaborator

Closes #276. Follow-up hardening to #270 (#275), found during live validation on the gouda e2e bench.

Problem

#270 installed the Tor-egress firewall after docker compose up. Containers dial immediately, so a connection a clearnet-only app opens in the window before the rules land is matched by the leading ESTABLISHED,RELATED -j ACCEPT rule and grandfathered past the DROP.

Reproduced live: a fresh pithead up with the firewall enabled left Tari (#271, the only clearnet app) holding 2–3 DIRECT PUBLIC peers, and bench-verify-egress.sh tor → FAIL. Restarting just Tari (re-dial under the present rules) → 0 public, proving the rules work for new connections and the residue is purely install ordering.

Fix (pithead only — no image rebuild)

  • Move apply_tor_egress_firewall before compose_up_checked in stack_up, so no container dials before the rules exist.
  • Pre-create DOCKER-USER (iptables -N … || true) so the pre-compose install also succeeds on a first-ever up (where Docker hasn't created the chain yet). DOCKER-USER is a static chain Docker preserves across network (re)creation and re-jumps from FORWARD when it builds the network, so rules referencing the fixed subnet/Tor IP are safe to install early.

Validation (gouda, live)

  • Log now prints Tor-only egress enforced before Stack started successfully!.
  • Fresh pithead upTari 0 public peers at t+0 and t+25s (was 2–3); DROP counter climbs from the start.
  • bench-verify-egress.sh torfirst fully clean all-Tor PASS: monerod ✓ p2pool ✓ tari ✓ xmrig ✓.
  • down/up firewall lifecycle clean (rules 7→0→7); feat(privacy): enforce Tor-only egress fail-closed via a host firewall (#270) #275 set -e fix holds.
  • tests/stack/run.sh: 378 passed, 0 failed (adds a pre-creates the DOCKER-USER chain assertion).

🤖 Generated with Claude Code

VijitSingh97 and others added 2 commits June 16, 2026 22:53
… startup window)

The firewall was installed *after* `docker compose up`, leaving a brief startup
window in which a clearnet-only app (Tari, #271) opens connections that the
ESTABLISHED,RELATED rule then grandfathers past the DROP — observed live as Tari
holding 2-3 public peers after a fresh `up`. Move the install ahead of compose so
no container ever dials before the rules are in place, and pre-create DOCKER-USER
(idempotent) so the pre-compose install also works on a first-ever `up`.

DOCKER-USER is a static chain Docker preserves across network (re)creation, so
rules referencing the fixed subnet/Tor IP can be installed before the network
exists; Docker adds the FORWARD jump when it creates the network.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@VijitSingh97 VijitSingh97 merged commit 87ee875 into develop Jun 17, 2026
11 checks passed
@VijitSingh97 VijitSingh97 deleted the feat/276-tor-egress-startup-window branch June 17, 2026 04:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Tor-egress firewall installs after compose → startup window grandfathers clearnet connections (#270 follow-up)

1 participant