Skip to content

Harden the Tor container: SOCKS policy, SafeSocks, dedicated ports, no bridge control listener #4152

Open

Description

@pithead-developer

What's the problem

The Tor container's config is permissive.

  • SocksPort 0.0.0.0:9050 listens on every interface, with no SocksPolicy. Tor accepts any client that can reach it. Only the network layout limits who can.
  • SafeSocks is off, so Tor accepts SOCKS requests where the client resolved the name itself, which is a DNS leak outside Tor.
  • All callers share one SOCKS port, and the time and DNS tracks will need their own.
  • ControlPort also listens on the bridge address (port 9051), not only on loopback. The one in-repo user found, the bootstrap healthcheck and the signal scripts, uses 127.0.0.1.
  • ClientUseIPv6 is not set, so IPv6 depends on Tor's default.
  • The Tor version comes from apk add tor on an Alpine base, so it moves with the base image (see build/tor: the apk-installed tor version is unpinned, so Alpine's 0.4.9 bump silently changed state-write semantics and broke the #3118 live proof #4125).

What it impacts

Pithead appliance and DIY owners. Any container on the bridge, or anything that gets routed to it, can use the box's Tor and its exit circuits. A client that resolves locally leaks the name. A control listener on the bridge is a larger surface than the stack needs. These are the Tor half of the Tor-only egress plan, so they decide how well the rest holds.

How I found it

Read build/tor/torrc.template and build/tor/Dockerfile on origin/develop, then grepped for 9051 across lib, os, dashboard, build and compose: the only users are the container's own healthcheck, control-signal.sh and recovery-diagnose.sh, all on 127.0.0.1. The Tor manual (older mirror, to re-check against the current one) says: no SocksPolicy means accept all, SafeSocks defaults to 0, ClientUseIPv6 defaults to 0. The coordinator's DataDirectory is already a persistent volume, so guards and the cached consensus already survive restarts. Whether a host-side caller reaches the control port by the bridge address is not proven.

How important is it

Medium to high for 2.0.5. The owner approved the full plan on 2026-11-16. This is step 7, after the clients, DNS and time are in place, and it must be proven on the canary bench before the proof gate (#4153 (step 8: proof gate)) and the firewall enforces, because a wrong SocksPolicy would cut off the dashboard, Tari or P2Pool. It is not urgent on its own because the bridge is private, but it is cheap and it closes a real gap.

Acceptance criteria

Possible solutions

  • Edit build/tor/torrc.template in place: add SocksPolicy accept lines (the entrypoint already substitutes the subnet prefix), a final SocksPolicy reject *, SafeSocks 1, dedicated SocksPort lines, and ClientUseIPv6 0.
  • Verify first that host-side callers (the update verbs and the doctor) come from an address inside the accepted range. If they reach Tor through the bridge address, the host's bridge address needs its own accept line.
  • Drop the bridge ControlPort line after a grep and a canary run show nothing else needs it. Keep the cookie-auth setting on loopback.
  • Pin Tor either by an exact apk version or by baking the image with a fixed version. Take the choice from build/tor: the apk-installed tor version is unpinned, so Alpine's 0.4.9 bump silently changed state-write semantics and broke the #3118 live proof #4125 rather than deciding here.
  • Optional: try Sandbox 1 on the canary only, and keep it only if it is stable.
  • Unknown: the Tor version the Alpine base ships, and whether the option defaults match the current manual. Check both on the built image.

Activity

  1. added this to the v2.0.5 milestone on Nov 16, 2026
  2. added
    security
    appliance
    operator-action
    on Nov 16, 2026
  3. added
    blocked
    on Nov 16, 2026
  4. pithead-developer commented on Nov 16, 2026

    @pithead-developer
    ContributorAuthor

    Blocked on #4148.
    Blocked on #4149.

    Step 7 of the rollout order in #4144: it starts when steps 4 and 5 close, and is still proven on the canary bench.

  5. removed
    operator-action
    on Nov 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    applianceblockedsecurity

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions