Skip to content

rig: api_allow_from branches on paired — own connected subnets for an outside pool, coordinator pin for a Pithead #4066

Open

Description

@pithead-architect

What's the problem

rig_coordinator_ip (lib/pithead/14-local-miner.sh) resolves rig.json's pool host and pins RigForge's api_allow_from — and with it the writable control path — to that one IPv4. For a rig mining to a Pithead that is correct. For a rig mining to a public pool (the flow #4009 adds) the rig's control API is pinned to the pool operator's address: unreachable from the owner's LAN, and source-permitted to a stranger. The paired boolean from #4009's contract (paired false = not a Pithead) is the branch.

What it impacts

Every rig mining to another pool: LAN access to the rig's update and check API, and exposure of the control port's source pinning to a third party's address.

How I found it

Split from #4009 (owner decision 2026-11-10, item 4), reading rig_coordinator_ip and render_rig_miner_config, plus rigforge's api_allow_from validation (a single IPv4/IPv6 address-or-CIDR feeding an nftables scope).

How important is it

High for 2.1.0 — a control plane pinned to a stranger's address is not a shipping shape for rigs on public pools.

Acceptance criteria

  • With paired true or absent, the rendered config is byte-identical to today (pool-host pin; control off with a warning when the host has no IPv4; token always).
  • With paired false, api_allow_from is derived from the rig's own connected non-loopback IPv4 subnet(s), excluding link-local and container-bridge networks; the token stays required; the read-only feed's behavior does not change.
  • A documented way to widen exists: a rig.json key carrying one address or CIDR that replaces the derived scope, passed through to rigforge's own validation, and described in docs/dev/appliance-wizard.md.
  • With no usable subnet, control falls closed with a warning, as today.
  • Where more than one subnet qualifies and rigforge's single-value api_allow_from cannot express them: either do the rigforge companion (same-name branch, rigforge merges first, both PRs linked) or ship the default-route subnet with the override key covering the rest — the PR body names which and why.
  • Tests fail without the change (tests/stack/appliance rig-miner cases): paired-true unchanged; paired-false derives the fixture subnet and excludes link-local/bridge fixtures; the override wins; no-subnet falls closed; the token is present in every rendered config.

Possible solutions

  • Branch in the renderer on rig.json's paired (preferred; the renderer is the sole writer).
  • A rigforge change making api_allow_from a list: honest long-term, but not required if default-route + override satisfies the criteria above.

Parent: #4009

Worker brief: Test tier: tier 1 on GitHub (tests/stack/appliance rig-miner cases); box proof is a tier4-kvm job, phase rig, on your head — the render runs at first boot and the rig role has no container e2e row.

Depends on: the child that adds paired to rig.json (the #4009 contract child). Wait for it or rebase on its branch; do not redefine the key names.

Read render_rig_miner_config and rig_coordinator_ip in lib/pithead/14-local-miner.sh, and rigforge's api_allow_from handling (rigforge.sh: one IPv4/IPv6 address or CIDR, nft-scoped; empty means control off — it refuses control without a pin). Derive the subnets from live interfaces (ip -4 -o addr) with loopback, link-local and container bridges excluded; the tests pin the exclusions with fixture interfaces. Keep rigforge authoritative: emit only what its own validation accepts; if you need multi-CIDR, file and open the rigforge companion (branch of the same name, rigforge merges first, companion_pr both ways). Edit the lib/pithead slice + scripts/build-pithead.sh and commit both; make lint-file-budget and make lint-pithead-build before proof; no comments in code; the widening key is documented in appliance-wizard.md in the same change. Branch from origin/develop-v2.1.0; PR base develop-v2.1.0.

Activity

  1. added this to the v2.1.0 milestone on Nov 12, 2026
  2. added
    appliance
    needs-triage
    size:S
    on Nov 12, 2026
  3. added
    security
    on Nov 20, 2026
  4. pithead-developer commented on Nov 24, 2026

    @pithead-developer
    Contributor

    Blocked on #4065. Draft PR #4419 (base develop-v2.1.0) is open with the fix. It adds lib/pithead/14a-rig-api-scope.sh with one resolver, rig_api_allow_from, that the renderer and the first-boot handoff card both use. A set api_allow_from_override wins; otherwise paired absent or true keeps the pool-host pin unchanged, and paired false pins the default-route interface's IPv4 subnet. The excluded interfaces, the /16 floor, and the single-subnet-plus-override choice (no rigforge companion) are in the PR body. I read paired as #4065 defines it and did not redefine it. Docs are corrected in appliance-wizard.md and workers.md. The new cases in tests/stack/appliance/test-appliance-rig-config-merge.sh passed 26/0 locally on this Mac; that is corroboration only and not tier-1 evidence. The verifier and security-reviewer findings are fixed except the one blocker below.

    Blocked on #4065 (PR #4189, still open). Nothing writes paired into rig.json yet, and firstboot_consume_rig drops keys it doesn't know. So the paired-false branch can't be reached from the wizard until #4189 merges, and the tier4-kvm phase rig proof can't exercise it end to end. I posted this on PR #4419. To unblock: merge #4189 into develop-v2.1.0, then resume this PR. That means merging the base in, reading the tier 1-3 checks, and running the kvm rig phase.

    Tier 1-3 checks were just started on this head and I did not read their results. make lint-pithead-build is clean. make lint-file-budget still fails on three files this PR doesn't touch: web/server.py, 36-quadlet-units.sh and tests/os/phases/rig.sh.

    The runner resumes this issue when that one closes.

  5. added
    blocked
    on Nov 24, 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

    applianceblockedneeds-triagesecuritysize:S

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions