Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ updates:
- package-ecosystem: "docker"
directories:
- "/dashboard"
- "/build/caddy"
- "/build/cosign"
- "/build/monero"
- "/build/p2pool"
- "/build/socket-proxy"
- "/build/tor"
- "/build/xmrig-proxy"
schedule:
Expand Down Expand Up @@ -85,10 +87,6 @@ updates:
rootfs-tools:
patterns: ["*"]

# Third-party image digests pinned directly in docker-compose.yml (Tari node + wallet,
# docker-socket-proxy, caddy) — outside build/*, so the `docker` entry above never sees them,
# and they feed both channels: pulled on the DIY stack, baked into the appliance image (#833).
# The pithead-* image lines interpolate env vars and carry no digest; Dependabot skips them.
- package-ecosystem: "docker-compose"
directory: "/"
schedule:
Expand All @@ -97,8 +95,6 @@ updates:
compose:
patterns: ["*"]
ignore:
# Same policy as the docker entry: digest + patch within the pinned tag. A Tari or Caddy
# major/minor is a deliberate migration (compose flags, config compatibility), not a CVE fix.
- dependency-name: "*"
update-types: ["version-update:semver-major", "version-update:semver-minor"]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ jobs:
strategy:
fail-fast: false
matrix:
service: [monero, p2pool, tor, xmrig-proxy, dashboard]
service: [monero, p2pool, tor, xmrig-proxy, caddy, socket-proxy, dashboard]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
Expand Down
15 changes: 15 additions & 0 deletions build/caddy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
FROM caddy:2.11.9-builder-alpine@sha256:86e132d1d6db8850352b2dbc15f82a4cb25363ac305ee41e11405873e5931f37 AS build

ARG X_NET_VERSION=v0.62.0
ENV GOPROXY=https://proxy.golang.org GOSUMDB=sum.golang.org
RUN xcaddy build "${CADDY_VERSION}" --replace "golang.org/x/net=golang.org/x/net@${X_NET_VERSION}" --output /usr/bin/caddy \
&& go version -m /usr/bin/caddy > /tmp/modules \
&& grep -Eq "^[[:space:]]+dep[[:space:]]+github.com/caddyserver/caddy/v2[[:space:]]+${CADDY_VERSION}[[:space:]]+h1:" /tmp/modules \
&& grep -Eq "^[[:space:]]+=>[[:space:]]+golang.org/x/net[[:space:]]+${X_NET_VERSION}[[:space:]]+h1:" /tmp/modules

FROM caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b

COPY --from=build /usr/bin/caddy /usr/bin/caddy
RUN apk add --no-cache --upgrade "busybox>=1.37.0-r32" "busybox-binsh>=1.37.0-r32" "ssl_client>=1.37.0-r32" libcrypto3 libssl3 \
&& setcap cap_net_bind_service=+ep /usr/bin/caddy \
&& caddy version | grep -q "^${CADDY_VERSION} "
4 changes: 4 additions & 0 deletions build/socket-proxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459

RUN apk add --no-cache --upgrade "busybox>=1.37.0-r32" "busybox-binsh>=1.37.0-r32" "ssl_client>=1.37.0-r32" libcrypto3 libssl3 musl musl-utils pcre2 zlib \
&& haproxy -v >/dev/null
28 changes: 6 additions & 22 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -897,14 +897,10 @@ services:
retries: 3
start_period: 60s

# --- Docker Socket Proxy (read-only) ---
# Read-only window onto the Docker API for the dashboard's container stats/logs.
# POST stays off, so this proxy can never write — container control goes through the
# separate, tightly-scoped docker-control proxy below.
docker-proxy:
image: tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459
image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-socket-proxy:${STACK_VERSION:-dev}
build: ./build/socket-proxy
container_name: docker-proxy
# Memory ceiling (#132 — see monerod). A tiny socket proxy (~13 MiB observed).
mem_limit: 128m
memswap_limit: 128m
restart: unless-stopped
Expand Down Expand Up @@ -945,19 +941,10 @@ services:
retries: 3
start_period: 30s

# --- Docker Control Proxy (start/stop only) ---
# A second, minimal proxy used ONLY to stop/start p2pool + xmrig-proxy — node-down worker
# failover (Issue #31), holding the miner until the nodes finish syncing (Issue #35) — plus
# tor (#424) and monerod after a tor heal (#972).
# With POST=1 but every section (CONTAINERS, EXEC, IMAGES, …) left off, the v0.5.0 ruleset
# allows exactly `POST /containers/<id>/{start,stop}` and denies everything else
# (create/kill/exec/reads — and the pause/unpause routes v0.5.0 added, which sit behind their
# own ALLOW_PAUSE/ALLOW_UNPAUSE opt-ins, left off here). Kept separate from the read-only
# proxy above so opening POST here can't widen that proxy's container access.
docker-control:
image: tecnativa/docker-socket-proxy:v0.5.0@sha256:1f5038b54f06c3e18422902cf00ba21803d1c97805aae032e5e6673d532d3459
image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-socket-proxy:${STACK_VERSION:-dev}
build: ./build/socket-proxy
container_name: docker-control
# Memory ceiling (#132 — see monerod). A tiny socket proxy (~13 MiB observed).
mem_limit: 128m
memswap_limit: 128m
restart: unless-stopped
Expand Down Expand Up @@ -997,13 +984,10 @@ services:
retries: 3
start_period: 30s

# --- Caddy Reverse Proxy ---
# Bridges the local 127.0.0.1 application binding to the LAN
# Serves HTTPS or HTTP depending on configuration
caddy:
image: caddy:2.11.9@sha256:4851e54a46b206517c574821bb5cc67f170d2156041e9fbc4c9193b45e84a75b
image: ${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-caddy:${STACK_VERSION:-dev}
build: ./build/caddy
container_name: caddy
# Memory ceiling (#132 — see monerod). Reverse proxy + local TLS only (~13 MiB observed).
mem_limit: 128m
memswap_limit: 128m
restart: unless-stopped
Expand Down
4 changes: 2 additions & 2 deletions docs/dev/appliance-release.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,11 +258,11 @@ PITHEAD_REGISTRY=<host:port> PITHEAD_REGISTRY_CA=<ca.crt> PITHEAD_REGISTRY_COSIG
```

**A dev image pulls its services; only the wizard image is baked.** At first boot the appliance
pulls `pithead-<service>:v$(cat VERSION)` for all five first-party services, and while VERSION
pulls `pithead-<service>:v$(cat VERSION)` for all seven first-party services, and while VERSION
leads the last release those tags exist nowhere public. Build without `PITHEAD_REGISTRY` and the
appliance provisions, publishes dashboard credentials, and then runs ZERO containers — five
battery legs report it and each waits up to 25 minutes (#2043). `build-image.sh` refuses such a
build; publish the five images to a registry the builder and the guest can both reach first.
build; publish the seven images to a registry the builder and the guest can both reach first.

**A dev image ships the last release's compose file, not the tree's.** Every `image:` in
`docker-compose.yml` is pinned by `STACK_VERSION`, and the appliance derives that from its baked
Expand Down
8 changes: 4 additions & 4 deletions docs/dev/file-budget.tsv
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,16 @@ lib/pithead/14-local-miner.sh 414
lib/pithead/21-doctor-stack-checks.sh 413
lib/pithead/28-parse-and-validate-config.sh 464
lib/pithead/33-render-env.sh 481
lib/pithead/36-quadlet-units.sh 418
lib/pithead/36-quadlet-units.sh 415
lib/pithead/48-os-update-verbs.sh 404
scripts/build-pithead-selftest.sh 416
scripts/watch/scheduled-run-watch.sh 416
scripts/watch/trivyignore-watch.sh 599
scripts/watch/trivyignore-watch.sh 551
tests/integration/e2e.sh 684
tests/integration/fakes/test_contract.py 437
tests/integration/lib.sh 686
tests/integration/lib/live-upgrade-support.sh 413
tests/integration/lib/run-lifecycle.sh 418
tests/integration/lib/run-lifecycle.sh 417
tests/integration/lib/wallet-fixture.py 442
tests/integration/selftest/selftest-abort-traps.sh 408
tests/integration/selftest/selftest-e2e-phases.sh 501
Expand Down Expand Up @@ -95,7 +95,7 @@ tests/stack/dashboard/test-dashboard.sh 591
tests/stack/doctor/test-doctor.sh 470
tests/stack/firewall/tor-egress-enforcement.sh 444
tests/stack/run.sh 402
tests/stack/standalone/test_compose.sh 462
tests/stack/standalone/test_compose.sh 445
tests/stack/test-backup.sh 476
tests/stack/test-cli.sh 410
tests/stack/test-config.sh 705
Expand Down
12 changes: 6 additions & 6 deletions docs/dev/releasing.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ that has stopped looks different from one with nothing to say.
CI runs a weekly CVE sweep on Mondays at 05:00 UTC from `develop`. It answers two questions with
two jobs: `build-images` rebuilds the stack images from the branch and scans them, while
`os-rootfs.yml` does the same for the appliance rootfs, so a fixable CVE is caught before a cut;
`sweep-shipped` scans all six images already published, each tag resolved to a digest, so a CVE in
`sweep-shipped` scans all eight images already published, each tag resolved to a digest, so a CVE in
the bytes users are running is caught after one.

A digest-pinned base can lag a published security fix until upstream rebuilds the image. The Alpine
Expand Down Expand Up @@ -163,9 +163,9 @@ Images are published to GitHub Container Registry (`ghcr.io/p2pool-starter-stack
images pull without a Docker Hub-style rate limit.

The stack is multi-container. Every stack image (`pithead-dashboard`, `pithead-p2pool`,
`pithead-xmrig-proxy`, `pithead-monero`, `pithead-tor`) and the appliance rootfs
`pithead-xmrig-proxy`, `pithead-monero`, `pithead-tor`, `pithead-caddy`, `pithead-socket-proxy`) and the appliance rootfs
(`pithead-os-rootfs`) is published, all tagged with the single product version. Compose references
one `${STACK_VERSION}` for the five images it runs. `docker compose pull` fetches that set with one
one `${STACK_VERSION}` for the seven images it runs. `docker compose pull` fetches that set with one
knob, replacing the "git pull + rebuild" upgrade path. The version is the bundle, not the layers.

## Release process
Expand Down Expand Up @@ -318,14 +318,14 @@ verdict is printed as a warning and the rehearsal continues, so a preview still
the `pithead` shell suite + compose validation) and the
[#54](https://github.com/p2pool-starter-stack/pithead/issues/54) integration matrix against
the real nodes. Abort the release on any failure. See [Pre-release gate](#pre-release-gate-54).
3. Build: build the five stack images with the pinned upstream versions baked in and OCI labels
3. Build: build the seven stack images with the pinned upstream versions baked in and OCI labels
stamped (`org.opencontainers.image.version` = the `VERSION` value, source revision, etc.). The
dashboard already reads `PITHEAD_VERSION` / git build-args for its header badge
([#58](https://github.com/p2pool-starter-stack/pithead/issues/58)); a release build must pass
`PITHEAD_RELEASE=1` (and `PITHEAD_VERSION` from `VERSION`) so the badge shows the clean
`vX.Y.Z` rather than the `dev · branch @ hash` it shows for working-tree builds. Then build the
appliance rootfs with that staged dashboard digest baked in. The rootfs builder receives
`PITHEAD_PIN_TAG=$STAGING_TAG` and resolves all five first-party index digests from that tag,
`PITHEAD_PIN_TAG=$STAGING_TAG` and resolves all seven first-party index digests from that tag,
while the baked Compose references retain their version tags. Without an override, the
builder resolves the version tag; an empty override uses that same default. Its push guard
reads the exported rootfs and refuses any artifact carrying the debug SSH key. It records that tar's SHA-256; the
Expand Down Expand Up @@ -731,7 +731,7 @@ round trip above must pass on it.

`pithead` verifies before it changes anything:

- `pithead upgrade` on a release install with `cosign.pub` present verifies all five first-party
- `pithead upgrade` on a release install with `cosign.pub` present verifies all seven first-party
images (`cosign verify --key cosign.pub --private-infrastructure`) and aborts on the first
failure. Nothing is pulled or restarted.
- The dashboard upgrade ([#59](https://github.com/p2pool-starter-stack/pithead/issues/59))
Expand Down
2 changes: 1 addition & 1 deletion docs/operations.md
Original file line number Diff line number Diff line change
Expand Up @@ -516,7 +516,7 @@ curl -fsSL https://github.com/p2pool-starter-stack/pithead/releases/latest/downl
```

**Source checkout:** pull the latest code, then upgrade. `upgrade` **rebuilds** the first-party
images locally and pulls only the pinned third-party images (Tari, Caddy, the socket proxies) that
images locally and pulls only the pinned third-party images (Tari) that
are not on the host. After the build, it recreates any container whose image ID differs from its
Compose declaration and fails if the IDs still differ. `setup` and `up` fetch missing third-party
images the same way:
Expand Down
3 changes: 2 additions & 1 deletion docs/privacy.md
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,8 @@ attacker can't substitute what you receive.
|---|---|---|
| Source clone / release bundle | `github.com` | install / update (`git checkout vX.Y.Z` or downloading the release bundle) |
| Component binaries (monerod / p2pool / xmrig-proxy) | `downloads.getmonero.org`, `github.com` | **image build only** — verified against a published **SHA256** / checksum. A release install *pulls* prebuilt images instead, so it never runs these. |
| Container images | **`ghcr.io`** (the `pithead-*` images, #44), `quay.io` (Tari), Docker Hub (caddy, socket-proxy) | image **pull** on a release install / `pithead upgrade`, or build from source. All pinned by **`@sha256:` digest** (#135). |
| Go modules for the caddy image | `proxy.golang.org`, `sum.golang.org` | **image build only** (`build/caddy`). A release install pulls the prebuilt image. |
| Container images | **`ghcr.io`** (the `pithead-*` images, including `pithead-caddy` and `pithead-socket-proxy`, #44), `quay.io` (Tari), Docker Hub (the base images of a source build) | image **pull** on a release install / `pithead upgrade`, or build from source. All pinned by **`@sha256:` digest** (#135). |

Mitigation: run the install/build behind a VPN or with `torsocks`, or pre-pull the images and clone
on another machine and copy them over. The downloads are pinned (SHA256 + image digests), so the
Expand Down
6 changes: 0 additions & 6 deletions lib/pithead/01-lifecycle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -194,13 +194,7 @@ compose_up_checked() {
[ "${#KEEP_SCOPED_ARGS[@]}" -gt 0 ] || return 0
set -- "${KEEP_SCOPED_ARGS[@]}"
fi
# Deactivated-profile containers go BEFORE the up (#795): the old local node must stop before
# p2pool (re)starts against the remote one, not linger beside it.
remove_deactivated_profile_containers
# #2654: a source checkout's `never` policy builds the first-party `:dev` images, but the
# digest-pinned third-party ones (tari, caddy, the socket-proxies) have no build context, so
# after `uninstall` or on a fresh host `up` fails on them. Fetch only those that are missing;
# a pinned digest bump is a new ref, so this also covers `upgrade`. An explicit PITHEAD_PULL wins.
if [ -z "${PITHEAD_PULL:-}" ] && is_source_checkout; then
docker compose pull --policy missing --ignore-buildable ||
warn "Could not pull the missing third-party images — 'compose up' reports which ones below."
Expand Down
12 changes: 2 additions & 10 deletions lib/pithead/03-release-verify.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# The @sha256 digest the bundled compose pins pithead-<suffix> to (#461 writes these into the
# released compose). Empty if the image line carries no digest (an un-pinned/dev compose). Mirrors
# the caddy-digest read at bcrypt-hash time (grep straight from docker-compose.yml at cwd).
compose_pinned_digest() {
grep -oE "pithead-$1:[^[:space:]]*@sha256:[0-9a-f]+" docker-compose.yml |
grep -oE 'sha256:[0-9a-f]+' | head -1
Expand Down Expand Up @@ -79,20 +76,15 @@ verify_release_images() {
fi
cosign_available ||
error "cosign.pub is present but docker is not available to run the verifier — refusing an unverified pull. Install Docker ($DOCS_URL/docs/getting-started.md#1-prerequisites) and re-run '$0'."
# The 5 first-party images, verified by the exact digest compose pins them to (#451/#461).
local suffix repo sha image out said cosign_registry_args=()
# A debug build's private-registry CA is program material beside cosign.pub, so the install-dir
# mount already carries it into the container — a relative name, like --key on the same command.
if [ -f cosign.registry-ca.crt ]; then
cosign_registry_args=(--registry-cacert cosign.registry-ca.crt)
elif [ -n "${PITHEAD_REGISTRY:-}" ] && [ "$PITHEAD_REGISTRY" != "ghcr.io/p2pool-starter-stack" ] &&
[ "$(tr -d ' \t\r\n' <"${PITHEAD_VARIANT_FILE:-/etc/pithead-variant}" 2>/dev/null || true)" = debug ]; then
cosign_registry_args=(--allow-http-registry)
fi
for suffix in tor monero p2pool xmrig-proxy dashboard; do
for suffix in tor monero p2pool xmrig-proxy caddy socket-proxy dashboard; do
repo="${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-${suffix}"
# #557: plain `sha="$(...)"` aborts under errexit on a no-match grep BEFORE this error()
# fires — `if !` suspends errexit for the assignment so the crafted diagnostic is reachable.
if ! sha="$(compose_pinned_digest "$suffix")" || [ -z "$sha" ]; then
error "cosign.pub is present but pithead-${suffix} is not digest-pinned in docker-compose.yml — cannot bind verification to the bytes compose pulls; refusing. A signed release bundle pins every first-party image by @sha256."
fi
Expand All @@ -110,7 +102,7 @@ verify_release_images() {
error "Signature verification FAILED for $image — the published image does not match the release key; refusing to pull or restart, nothing was changed. cosign said: $said"
fi
done
log "All 5 release images verify against their pinned digest (cosign.pub)."
log "All release images verify against their pinned digest (cosign.pub)."
}

reconcile_compose_images() {
Expand Down
17 changes: 6 additions & 11 deletions lib/pithead/35-caddyfile-and-auth-helpers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,13 @@ hmac_sha256_hex() { # <key> <message>
} | openssl dgst -sha256 | sed 's/^.*= //'
}

# bcrypt-hash a dashboard password with the PINNED Caddy image (read straight from docker-compose.yml
# so it tracks the digest), returned base64-encoded so the raw bcrypt '$' never lands in .env (#8).
# Returns non-zero if Docker / the image isn't available.
caddy_hash_password_b64() {
local pw="$1" img hash
img=$(grep -oE 'caddy:[0-9.]+@sha256:[a-f0-9]+' docker-compose.yml | head -1)
[ -n "$img" ] || return 1
# Fully qualified, because `docker run` here may be podman's shim: docker IMPLIES docker.io
# for a short name, podman's native path refuses one outright — the compose pull worked (the
# compat API keeps docker semantics) while this exact line killed appliance provisioning.
img="docker.io/library/$img"
# Keep the credential hash out of the runtime journal while capturing stdout here.
local pw="$1" img hash digest
digest=$(compose_pinned_digest caddy) || digest=""
img="${PITHEAD_REGISTRY:-ghcr.io/p2pool-starter-stack}/pithead-caddy:${STACK_VERSION:-dev}${digest:+@$digest}"
if is_source_checkout; then
docker image inspect "$img" >/dev/null 2>&1 || docker compose build caddy >/dev/null 2>&1 || return 1
fi
hash=$(printf '%s\n' "$pw" | docker run --rm -i --log-driver none "$img" caddy hash-password 2>/dev/null) || return 1
[ -n "$hash" ] || return 1
printf '%s' "$hash" | openssl base64 -A
Expand Down
9 changes: 3 additions & 6 deletions lib/pithead/36-quadlet-units.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@ render_quadlet_units() {
_qcompose_require() {
_qcompose_image "$1" >/dev/null || error "render-quadlet: $composef has no image for service $1. Refusing to render; no output was created."
}
_qcompose_require caddy
_qcompose_require docker-proxy
_qcompose_require docker-control
case ",$profiles," in *,local_tari,*) _qcompose_require tari ;; esac
case ",$profiles," in *,tari_payout_confirm,*) _qcompose_require tari-wallet ;; esac
mkdir -p "$outdir"
Expand Down Expand Up @@ -310,7 +307,7 @@ EOF
Description=pithead caddy
[Container]
ContainerName=caddy
Image=$(_qcompose_image caddy)
Image=$reg/pithead-caddy:$ver
Network=host
Volume=$(_qenv QUADLET_CADDYFILE):/etc/caddy/Caddyfile:ro
Volume=pithead-caddy-data:/data
Expand All @@ -335,7 +332,7 @@ EOF
Description=pithead read socket proxy
[Container]
ContainerName=docker-proxy
Image=$(_qcompose_image docker-proxy)
Image=$reg/pithead-socket-proxy:$ver
Network=proxy.network
Environment=CONTAINERS=1 LOGS=1
Volume=$proxy_sock:/var/run/docker.sock:ro
Expand All @@ -356,7 +353,7 @@ EOF
Description=pithead control socket proxy
[Container]
ContainerName=docker-control
Image=$(_qcompose_image docker-control)
Image=$reg/pithead-socket-proxy:$ver
Network=proxy.network
Environment=CONTAINERS=1 POST=1 ALLOW_START=1 ALLOW_STOP=1
Volume=$proxy_sock:/var/run/docker.sock:ro
Expand Down
Loading
Loading