Skip to content

Enforce the host egress firewall: one inet output table, policy drop, both roles #4154

Open

Description

@pithead-developer

What's the problem

The clients refuse to connect without Tor, but nothing stops a client, a host-network container or a future bug from sending traffic straight out. Today's firewall (apply_tor_egress_firewall in lib/pithead) fences containers only. The dashboard and Caddy use host networking, the docker-socket proxies and the default bridge sit outside the fence, and IPv6 is not covered. The owner's plan needs a second control on every path: a default-drop outbound policy on the host. It ships log-only first (#4145 (step 1: log-only firewall and netwatch)) and enforces last, both in 2.0.5 (owner ruling 2026-11-16).

What it impacts

Every Pithead appliance and every RigForge rig, including DIY installs for the container fence. A missed dependency in the rules locks a box out of the network or breaks mining, so field safety matters as much as the rules.

How I found it

Reading the current firewall code and the egress inventory. Host-network coverage by uid or cgroup is a design choice not yet proven on the appliance; how netavark, the LAN guard and RigForge's existing input table behave alongside a new output table is unverified and must be tested in log-only mode.

How important is it

High, and last in order. It is the final control of the Tor-only egress work, so it ships only after steps 1 to 8 (#4153 (step 8: proof gate) is the last) and the benchmark gate in #4155 (benchmark) pass. Enforcing too early risks bricking boxes in the field.

Acceptance criteria

  • A single inet table with an output hook and policy drop covers IPv4 and IPv6 on both roles, and loads before the network comes up (observable: the table exists before DHCP completes on first boot).
  • It allows only: loopback; established and related; DHCP; neighbour discovery and router advertisement; LAN ranges except LAN port 53 and 123; mDNS; the Tor container address or the debian-tor uid; and the stratum exception (the xmrig uid where possible, the pool port only, to an address set resolved over Tor).
  • It fences the default bridge and proxy_net, and covers host-network containers by uid or cgroup, falling back to dedicated service users where needed.
  • Counters for each rule and the drop policy are read back by egress-status and pithead doctor, and a non-zero drop counter is shown.
  • It coexists with netavark, the LAN guard and RigForge's input table: reboot, pithead upgrade and container restarts do not remove or duplicate it.
  • A field rollback switch (a documented setting plus pithead command) returns the box to log-only without reflashing, and is covered by a test.
  • This does not merge until [benchmark] Stability and mining impact of Tor-only egress #4155 (benchmark) Run 1 has passed with the firewall log-only, the log-only drops from step 1 have been reviewed, and the five-window KVM leg from Proof gate: netwatch relay-set test, required five-window KVM leg and new-egress grep gate for Tor-only egress #4153 (step 8: proof gate) is green on both roles. [benchmark] Stability and mining impact of Tor-only egress #4155 (benchmark) Run 2 is then run on the release candidate with the firewall enforced.
  • Mining and update behaviour match the benchmark baseline within the thresholds set in [benchmark] Stability and mining impact of Tor-only egress #4155 (benchmark).

Possible solutions

  • One generated ruleset rendered from the egress map, applied by an early systemd unit ordered before network-pre.target.
  • Match host-network containers by cgroup v2 path where stable, otherwise run them as dedicated users and match by uid.
  • Use an nft set for the pool address list, refreshed by a small helper that resolves through Tor.
  • Ship the rollback as a one-line config flag read at load time, defaulting to enforce only after log-only has been through a release candidate.

Sibling work: #4144 (tracker).

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 #4153.

    Step 9 of the rollout order in #4144: work may start when step 8 closes, but the PR does not merge until benchmark Run 1 (#4155) has passed and the log-only drops are reviewed, as the tracker says.

  5. removed
    operator-action
    on Nov 16, 2026
  6. pithead-developer commented on Nov 23, 2026

    @pithead-developer
    ContributorAuthor

    The owner asked on 2026-11-23 to "just block anything that is non-Tor". This issue is that block.

    Here is the allowlist the policy drop must honour. Each entry is labelled "clearnet by choice or necessity", never "leak":

    Everything else is dropped. Please keep the allowlist in the committed egress map (data/egress-map.tsv), so the rules, the watchdog (#4385) and the panel (#4384) all read one source.

  7. pithead-architect commented on Nov 27, 2026

    @pithead-architect

    Owner decision (2026-11-27): moving to v2.0.6 with #4155, which it waits on, so 2.0.5 is not blocked by the egress-firewall chain.

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