Repository navigation
Description
What's the problem
Found while gathering tier-4 evidence for PR #2102 (issue #1882).
The gap
tests/integration/lib/run-hardening.sh has a leg that reaches the dashboard onion from an independent external Tor client. _onion_reachable_external() (line 55) fetches the client key with ./pithead onion-client-key and dials the onion with it. The leg runs only when DASHBOARD_ONION_ADDRESS is provisioned on the box (line 154). Nothing provisions it:
- No row in
scenario_matrix()(tests/integration/scenarios.sh) setsdashboard.onion.enabled. The onion is not one of the matrix axes. - The hardening phase's own control-check config sets
dashboard.secure,dashboard.authanddashboard.control, but not the onion.
So on every tier4-e2e run the leg reports [missing] dashboard onion external reachability (#424/#343) — onion not provisioned on this box and skips. Job 576 (commit 386b29beaa3b643878f86c3bf459e57b3d72db9e, phases: ["hardening"]) shows it. As a result, no bench run has ever:
- reached a client-authorized dashboard onion from outside;
- used the key
onion-client-keyprints, which is the check that the CLI verb's output actually opens the onion; - exercised the Tor stuck on a failing guard silently breaks all clearnet egress (Healthchecks, Telegram, XvB) — add detection + self-heal #424 recovery half (the onion comes back after a tor restart).
#1882 (PR #2102) adds a second reader of the same key, the dashboard's Show client key control verb. That verb is covered at tiers 1-3. It has no tier-4 leg for the same reason.
Related
- Tier-4:
rotate-dashboard-onionnever runs on a bench — nothing dials the new onion, and nothing checks the old one stopped answering #2345:rotate-dashboard-onionis never dialled on a bench either. It needs the same provisioned onion, so one fixture could serve both. - Appliance onion: client_auth defaults on, the key is printed only by a host verb, and no screen on the machine shows it — an onion that is on, in the header, and unreachable #1882 / PR Hand the dashboard onion's client key to an operator with no shell (#1882) #2102: the Show client key verb this leg would cover end to end.
What it impacts
Impact is not separately established in the existing report; confirm the affected users or behavior.
How I found it
Discovery details are not separately established in the existing report; preserve and verify the evidence already recorded.
How important is it
Importance has not been assessed explicitly; triage must state the priority and its reason.
Acceptance criteria
Acceptance
- A
tier4-e2ephases: ["hardening"]run reportsdashboard onion reachable from an independent external Tor clientas a pass, not a[missing]skip. - The key it uses comes from the product's own surface (CLI verb, and ideally the control kit), never from the harness reading
.env. - The phase restores the box's onion state and control-unit state to baseline, and
baseline_verifiedstays true. - Real Tor network flakiness does not fail the gate: keep the existing "only assert recovery when the baseline reached it" rule.
Acceptance script
Operator ruling accepted for this change: C4 applies to authorized hardening probes, with a separate clean keyless negative probe. Preserve the existing rotation-recovery readers introduced by PR #2377. The checker below reflects that scope, checks successful fresh CLI acquisition, and uses the current Tor-client verdict contract. Historical baseline counts below refer to the original checker.
The script below operationalizes the four boxes in Acceptance above. It drives the real hardening phase at tier 1 and checks the tier4-e2e phases: ["hardening"] job the first box asks for. The control-kit route ("ideally the control kit") is optional in the issue and is not checked.
Done means the script at the end of this section prints ACCEPTED and exits 0 on the PR head. Every check is a mechanical pass or fail, so no judgment call is needed. Paste the script's full output into the PR body.
# save the script below as $TMPDIR/accept_2603.py (outside the repo), then, from the repo root:
python3 $TMPDIR/accept_2603.py --results DIR
Run the maintained checker from the repository root: python3 tests/integration/selftest/hardening_onion.py --results DIR --base-ref origin/develop-v2.1.0. The named base is the current PR target; omit --base-ref only for a PR targeting develop. CI registers its Docker-free --selftest mode through selftest-hardening-onion.sh. Local execution uses Bash and GNU grep/sed; no Docker daemon is involved.
C2 to C7 run run_hardening, loaded the way run.sh loads it, against a fake box in a temporary directory. The box starts with the onion disabled and DASHBOARD_ONION_ADDRESS=placeholder. Its stubbed ./pithead apply provisions the dashboard onion from config.json the way the product does, and refuses control on a non-client-auth onion. Its ./pithead onion-client-key prints the client-auth line. Its docker run of the tor-client image follows the contract of tests/integration/tor-client/probe.sh: it answers PROBE-OK only for the provisioned address, and only with the right key on stdin.
DIR is a bench-ci tier4-e2e job on the PR head with options {"phases": ["hardening"]}. Fill it with the bench-ci client:
bench-ci evidence <id>@<head-sha> --json > DIR/evidence.json
bench-ci artifacts <id>@<head-sha> e2e-harness.log --out DIR/e2e-harness.log
bench-ci artifacts <id>@<head-sha> results/manifest.txt --out DIR/results/manifest.txt
| Check | Passes when |
|---|---|
| C1 | Something under tests/integration/ differs from develop, and nothing outside it and docs/ does. CHANGELOG.md is also allowed. |
| C2 | On the fake box, dashboard onion reachable from an independent external Tor client (#343/#360) passes, and the phase prints no skipped leg dashboard onion external reachability. |
| C3 | The first probe comes after an apply whose config has dashboard.onion.enabled: true, client_auth: true and dashboard.control.enabled: true. It dials the address that apply provisioned and carries that onion's client key. |
| C4 | Every authorized hardening probe obtains fresh credentials successfully through pithead onion-client-key; the negative probe uses a clean client without credentials and must be refused. Hardening does not read private keys directly. Existing rotation-recovery readers remain permitted. |
| C5 | A pithead restart tor follows the first probe, another probe follows the restart, and dashboard onion reachable from outside AFTER the tor restart (#424 recovery) passes. |
| C6 | When the phase ends, config.json and the full environment match baseline, the hidden-service identity or its absence is restored exactly, the last apply runs with the onion off, and control systemd units removed after the hardening phase (#477) passes. |
| C7 | With the first probe failing, as a live-Tor flake would: at least one probe ran, no row containing onion fails, and the recovery row is not asserted. |
| B1 | DIR/evidence.json names the full HEAD commit, tier tier4-e2e, status completed, options.phases exactly ["hardening"] and baseline_verified: true. DIR/results/manifest.txt has a git_rev: of at least 7 characters that HEAD starts with. |
| B2 | In DIR/e2e-harness.log, the reachability row and the #424 recovery row each pass and never fail. The keyless-refusal and control-units rows pass. No - [<class>] leg dashboard onion external reachability line appears in the did-NOT-run list. |
| C8 | A clean independent client without credentials is refused. |
| C9 | Failed or empty CLI reads before any authorized probe fail an onion row without dialing, and baseline is restored. |
| C10 | Unexpected keyless access, keyless bootstrap/infrastructure failures and post-restart reachability failure each fail the appropriate row and restore baseline. |
| C11 | A failed provisioning apply must fail an onion row, run no onion probe, and restore baseline. |
| C12 | An interrupted phase restores exact environment bytes and onion identity/absence. |
| C13 | A failed normal restore is reported and the EXIT hook safely completes restoration from retained copies. |
| C14 | Phase restoration uses the captured phase-entry configuration and matching environment when the run-wide baseline differs; run-level baseline restoration remains separate. |
| C15 | Restore starts Tor even when apply has no changes; a failed start fails restoration and retains protected recovery copies. |
Without --results, B1 and B2 print FAIL ... [bench evidence not supplied].
Rules:
- Do not change the script's test IDs, anchors or expected outcomes. If a check prints
DRIVER-ERRORorerror(...), harness code has moved since this issue was filed. Stop and comment here with the output instead of editing the script. - A reviewer re-runs the same script on the head they review. A changed head needs a fresh run and a fresh bench job.
- The repo's normal gates still apply on top of this:
make test,make test-patch-coverage, and the adversarial review.
Baseline, run 2026-10-03 on 3822294 (develop): unmodified develop prints NOT ACCEPTED: 1/9 checks pass. Only C6 passes. The phase skips the onion leg as onion not provisioned on this box, so no probe runs. With --results pointing at a fixture modelled on job 576 (the leg in the did-NOT-run list as [missing]), it prints NOT ACCEPTED: 2/9 checks pass. A throwaway prototype, not committed, printed NOT ACCEPTED: 7/9 checks pass without results, all local checks green. With pass fixtures it printed ACCEPTED: 9/9 checks pass on two runs. The prototype added .dashboard.onion={enabled:true,client_auth:true} to the control-check config and moved the onion block after that apply. The bench checks were validated only against synthetic fixtures: run_hardening and summary output from the fake box, plus record_manifest output and a hand-written evidence object in the bench-ci API shape. No real job was used. All runs were made on a macOS host, and no check here depends on GNU tools.
Hint, not binding: the existing end-of-phase push_config "$BASELINE_CONFIG" and apply already restore the onion state, so moving the onion block after the control apply is most of the change.
Independent re-check, 2026-10-03: a second session re-ran this script in a fresh worktree at 3822294. Develop printed NOT ACCEPTED: 2/9 checks pass, and with the throwaway prototype applied and the pass fixtures it printed ACCEPTED: 9/9 checks pass. Files the script mutates were left unchanged after each run.
accept_2603.py
import argparse
import json
import os
import re
import subprocess
import sys
import tempfile
from pathlib import Path
BASELINE = {
"dashboard": {"secure": False, "onion": {"enabled": False, "client_auth": True}},
"monero": {"mode": "local", "wallet_address": "4" + "A" * 94},
}
BASE_ENV = (
"COMPOSE_PROFILES=local_node\nDASHBOARD_ONION_ENABLED=false\nDASHBOARD_ONION_CLIENT_AUTH=true\n"
"DASHBOARD_ONION_ADDRESS=placeholder\nDASHBOARD_ONION_CLIENT_PRIVKEY=placeholder\n"
)
PITHEAD = r"""#!/usr/bin/env bash
umask 077
envset() { if grep -q "^$1=" .env; then sed "s|^$1=.*|$1=$2|" .env >.env.t && mv .env.t .env; else echo "$1=$2" >>.env; fi; }
envget() { sed -n "s/^$1=//p" .env | head -n1; }
case "$1" in
apply)
on=$(jq -r '.dashboard.onion.enabled // false' config.json)
ca=$(jq -r 'if .dashboard.onion.client_auth == false then "false" else "true" end' config.json)
ctl=$(jq -r '.dashboard.control.enabled // false' config.json)
echo "apply onion=$on client_auth=$ca control=$ctl" >>"$STUB/events.log"
if [ "$on" = true ] && [ "$ca" = false ] && [ "$ctl" = true ]; then exit 1; fi
envset DASHBOARD_ONION_ENABLED "$on"
if [ "$on" = true ]; then
mkdir -p "$STUB/box/tor/dashboard"
printf 'synthetic identity\n' >"$STUB/box/tor/dashboard/hs_ed25519_secret_key"
chmod 700 "$STUB/box/tor/dashboard"
chmod 600 "$STUB/box/tor/dashboard/hs_ed25519_secret_key"
fi
envset DASHBOARD_ONION_CLIENT_AUTH "$ca"
if [ "$on" = true ] && [ "$(envget DASHBOARD_ONION_ADDRESS)" = placeholder ]; then
envset DASHBOARD_ONION_ADDRESS "$(printf 'b%.0s' $(seq 56)).onion"
envset DASHBOARD_ONION_CLIENT_PRIVKEY "SYNTHETICCLIENTKEY"
fi
if [ "$on" = true ] && [ "${APPLY_FAIL:-0}" = 1 ]; then
echo "apply-result failed" >>"$STUB/events.log"
exit 1
fi
echo "apply-result ok" >>"$STUB/events.log" ;;
onion-client-key)
if [ "$(envget DASHBOARD_ONION_ENABLED)" = true ] && [ "$(envget DASHBOARD_ONION_CLIENT_AUTH)" = true ] &&
[ "$(envget DASHBOARD_ONION_ADDRESS)" != placeholder ]; then
echo x >>"$STUB/keys"
n=$(wc -l <"$STUB/keys" | tr -d ' ')
envset DASHBOARD_ONION_CLIENT_PRIVKEY "SYNTHETICCLIENTKEY$(printf '%s' "$n" | tr '1234567890' 'ABCDEFGHIJ')"
if [ "$n" = "${CLIENT_EMPTY_ON:-}" ]; then
echo "client-key empty" >>"$STUB/events.log"
exit 0
fi
if [ "$n" = "${CLIENT_FAIL_ON:-}" ]; then
echo "client-key refused" >>"$STUB/events.log"
echo "CLIENT-CREDENTIAL-SECRET-SENTINEL" >&2
else
echo "client-key ok" >>"$STUB/events.log"
fi
a=$(envget DASHBOARD_ONION_ADDRESS)
printf 'Dashboard onion address: http://%s\n\n %s:descriptor:x25519:%s\n' "$a" "${a%.onion}" "$(envget DASHBOARD_ONION_CLIENT_PRIVKEY)"
[ "$n" != "${CLIENT_FAIL_ON:-}" ] || exit 1
else
echo "client-key refused" >>"$STUB/events.log"
echo "no client key" >&2
exit 1
fi ;;
restart) echo "restart $2" >>"$STUB/events.log" ;;
esac
exit 0
"""
DOCKER = r"""#!/usr/bin/env bash
case "$1" in
compose)
if [ "${2:-}" = stop ] && [ "${3:-}" = tor ]; then
touch "$STUB/tor-stopped"
elif [ "${2:-}" = up ] && [ "${3:-}" = -d ] && [ "${4:-}" = tor ]; then
[ "${TOR_START_FAIL:-0}" = 0 ] || exit 1
rm -f "$STUB/tor-stopped"
fi ;;
ps) echo synthetic ;;
inspect) echo '[{"Mounts":[]}]' ;;
exec) echo "touch: cannot touch '/.rootfs-write-probe': Read-only file system"; exit 1 ;;
run)
addr="" stdin_key=0
for a in "$@"; do case "$a" in ONION_ADDR=*) addr=${a#ONION_ADDR=} ;; AUTH_STDIN=1) stdin_key=1 ;; esac; done
line=""
[ "$stdin_key" = 1 ] && read -r line
box="$STUB/box"
want=$(sed -n 's/^DASHBOARD_ONION_ADDRESS=//p' "$box/.env")
key=$(sed -n 's/^DASHBOARD_ONION_CLIENT_PRIVKEY=//p' "$box/.env")
ca=$(sed -n 's/^DASHBOARD_ONION_CLIENT_AUTH=//p' "$box/.env")
on=$(sed -n 's/^DASHBOARD_ONION_ENABLED=//p' "$box/.env")
echo x >>"$STUB/probes"
n=$(wc -l <"$STUB/probes" | tr -d ' ')
keyed=no
[ "$line" = "${want%.onion}:descriptor:x25519:$key" ] && keyed=yes
ok=0
if [ "$on" = true ] && [ "$addr" = "$want" ] && { [ "$ca" != true ] || [ "$keyed" = yes ]; }; then
case ",${PROBE_FAIL_ON:-}," in *",$n,"*) ;; *) ok=1 ;; esac
fi
clean=yes
if [ "$stdin_key" = 0 ]; then
[ -z "$line" ] || clean=no
case "${KEYLESS_RESULT:-}" in
reachable) ok=1 ;;
bootstrap) echo "probe $n keyed=no clean=$clean" >>"$STUB/events.log"; echo "PROBE-FAIL: tor did not bootstrap"; exit 2 ;;
error) echo "probe $n keyed=no clean=$clean" >>"$STUB/events.log"; echo "unexpected failure"; exit 3 ;;
esac
fi
case ",${PROBE_BOOTSTRAP_ON:-}," in
*",$n,"*) echo "probe $n clean=$clean onion=provisioned keyed=$keyed ok=0" >>"$STUB/events.log"; echo "PROBE-FAIL: tor did not bootstrap PROBE-SECRET-SENTINEL"; exit 2 ;;
esac
case ",${PROBE_ERROR_ON:-}," in
*",$n,"*) echo "probe $n clean=$clean onion=provisioned keyed=$keyed ok=0" >>"$STUB/events.log"; echo "PROBE-SECRET-SENTINEL"; exit 3 ;;
esac
echo "probe $n clean=$clean onion=$([ "$addr" = "$want" ] && echo provisioned || echo other) keyed=$keyed ok=$ok" >>"$STUB/events.log"
if [ "$ok" = 1 ]; then echo "PROBE-OK: reachable"; exit 0; else echo "PROBE-FAIL: HTTP 000 PROBE-SECRET-SENTINEL"; exit 1; fi ;;
esac
exit 0
"""
DRIVER = r"""
set -uo pipefail
HERE="$PWD/tests/integration"
INTEGRATION_RUN_SUITE=1
while IFS= read -r lib; do
# shellcheck disable=SC1090
source "$HERE/$lib" >/dev/null 2>&1 || { echo "DRIVER-ERROR: cannot source $lib"; exit 90; }
done < <(sed -n 's|^source "\$HERE/\([^"]*\)".*|\1|p' "$HERE/run.sh")
declare -F run_hardening >/dev/null || { echo "DRIVER-ERROR: run_hardening is not defined"; exit 91; }
IT_MODE=local IT_REMOTE_DIR="$STUB/box" IT_PITHEAD=./pithead IT_CURRENT_SCENARIO=hardening OUT_DIR="$STUB/out"
BASELINE_CONFIG="${RUN_BASELINE_CONFIG:-$(cat "$STUB/box/config.json")}"
_SAFETY_RESTORE_ARMED=0 _SAFETY_FOREIGN_TRAP="" SAFETY_ARCHIVE="" SAFETY_RESTORE_FAILED=0
export PATH="$STUB:$PATH"
wait_status_ok() { [ ! -e "$STUB/tor-stopped" ]; }
wait_for() { return 0; }
sleep() { :; }
capture_artifacts() { :; }
if [ "${INTERRUPT_PROBE:-0}" = 1 ]; then
_onion_reachable_external() { kill -TERM $$; }
fi
run_hardening
"""
SUDO = r"""#!/usr/bin/env bash
[ "$1" != -n ] || shift
if [ "${3:-}" = restore ] && [ "${RESTORE_FAIL_ONCE:-0}" = 1 ]; then
if [ ! -e "$STUB/restore-attempted" ]; then
touch "$STUB/restore-attempted"
"$@" || exit $?
exit 1
fi
fi
exec "$@"
"""
REACH = "dashboard onion reachable from an independent external Tor client (#343/#360)"
RECOVER = "dashboard onion reachable from outside AFTER the tor restart (#424 recovery)"
KEYLESS = "dashboard onion refuses an independent client without a key (#2603)"
KEY_ERROR = "dashboard onion authorized probe obtains CLI credentials (#2603)"
RESTORED = "dashboard onion identity and environment restored exactly (#2603)"
UNITS = "control systemd units removed after the hardening phase (#477)"
SKIP_LEG = "dashboard onion external reachability"
ANSI = re.compile(r"\x1b\[[0-9;]*[A-Za-z]")
ROW = re.compile(r"^\s*(✓|✗) (.*)$")
BENCH = (
"B1 tier4-e2e hardening job on the PR head: completed, baseline_verified, evidence and manifest name HEAD",
"B2 authorized reachability, keyless refusal, recovery and control-unit cleanup execute and pass",
)
results = []
def report(name, ok, detail=""):
results.append(ok)
print(f"{'PASS' if ok else 'FAIL'} {name}" + (f" [{detail}]" if detail else ""), flush=True)
def git(*args):
return subprocess.run(["git", *args], capture_output=True, text=True, check=True).stdout # noqa: S603, S607
def parse_rows(text):
rows = []
for ln in text.splitlines():
m = ROW.match(ANSI.sub("", ln).rstrip())
if m:
rows.append(("pass" if m[1] == "✓" else "fail", m[2].strip()))
return rows
def drive(
fail_on="",
client_fail="",
client_empty="",
bootstrap_on="",
error_on="",
keyless="",
apply_fail="0",
interrupt="0",
restore_fail="0",
entry_auth=True,
tor_start_fail="0",
):
with tempfile.TemporaryDirectory() as stub:
s = Path(stub).resolve()
box = s / "box"
box.mkdir()
entry = json.loads(json.dumps(BASELINE))
entry["dashboard"]["onion"]["client_auth"] = entry_auth
(box / "config.json").write_text(json.dumps(entry) + "\n")
entry_env = BASE_ENV.replace(
"DASHBOARD_ONION_CLIENT_AUTH=true",
f"DASHBOARD_ONION_CLIENT_AUTH={str(entry_auth).lower()}",
)
(box / ".env").write_text(entry_env + f"TOR_DATA_DIR={box / 'tor'}\n")
(box / ".env").chmod(0o600)
(box / "tor").mkdir()
helper = box / "tests/integration/lib/hardening_onion_state.py"
helper.parent.mkdir(parents=True)
helper.write_text(Path("tests/integration/lib/hardening_onion_state.py").read_text())
for name in ("10-installer-preseed.sh", "50-control-runner-provisioning.sh"):
source = Path("lib/pithead") / name
target = box / source
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(source.read_bytes())
before_env = (box / ".env").read_bytes()
for path, body in (
(box / "pithead", PITHEAD),
(s / "docker", DOCKER),
(s / "systemctl", "#!/usr/bin/env bash\nexit 0\n"),
(s / "sudo", SUDO),
):
path.write_text(body)
path.chmod(0o755)
env = {
**os.environ,
"STUB": stub,
"PROBE_FAIL_ON": fail_on,
"CLIENT_FAIL_ON": client_fail,
"CLIENT_EMPTY_ON": client_empty,
"PROBE_BOOTSTRAP_ON": bootstrap_on,
"PROBE_ERROR_ON": error_on,
"KEYLESS_RESULT": keyless,
"APPLY_FAIL": apply_fail,
"INTERRUPT_PROBE": interrupt,
"RESTORE_FAIL_ONCE": restore_fail,
"RUN_BASELINE_CONFIG": json.dumps(BASELINE),
"TOR_START_FAIL": tor_start_fail,
}
r = subprocess.run( # noqa: S603
["bash", "-c", DRIVER], # noqa: S607
capture_output=True,
text=True,
env=env,
timeout=60,
)
out = ANSI.sub("", r.stdout + r.stderr)
events = (s / "events.log").read_text().splitlines() if (s / "events.log").exists() else []
final = json.loads((box / "config.json").read_text() or "null")
restored_state = (
(box / ".env").read_bytes() == before_env
and not (box / "tor/dashboard").exists()
and not list(box.glob(".hardening-onion-*"))
and not list(box.glob("backups/.hardening-onion-*"))
)
err = re.search(r"DRIVER-ERROR: .*", out)
return {
"rows": parse_rows(out),
"out": out,
"events": events,
"final": final,
"restored_state": restored_state,
"returncode": r.returncode,
"error": err[0] if err else "",
}
def verdicts(run, name):
return [v for v, t in run["rows"] if t == name]
def probes(events):
return [
(i, dict(kv.split("=", 1) for kv in e.split()[2:]))
for i, e in enumerate(events)
if e.startswith("probe ")
]
parser = argparse.ArgumentParser()
parser.add_argument("--results", type=Path)
parser.add_argument("--base-ref", default="origin/develop")
parser.add_argument("--selftest", action="store_true")
args = parser.parse_args()
if not args.selftest:
base = git("merge-base", args.base_ref, "HEAD").strip()
head = git("rev-parse", "HEAD").strip()
changed = set(git("diff", "--name-only", base).split())
outside = sorted(
f
for f in changed
if not f.startswith(("tests/integration/", "docs/")) and f != "CHANGELOG.md"
)
report(
"C1 changes touch tests/integration/ and stay in it and docs/ (CHANGELOG.md allowed)",
not outside and any(f.startswith("tests/integration/") for f in changed),
f"changed: {sorted(changed)}",
)
A, B = drive(), drive(fail_on="1")
names = [
"C2 on a box with no onion, the phase passes the reachability row and does not skip the onion leg",
"C3 the first probe follows an apply with onion enabled, client_auth true and control on, and dials "
"the provisioned onion with its client key",
"C4 each authorized probe gets fresh CLI credentials; the keyless probe is clean; hardening reads no private key directly",
"C5 tor is restarted after the first probe, a later probe runs, and the #424 recovery row passes",
"C6 the phase ends on the baseline: config.json restored exactly, last apply has the onion off, units removed",
"C7 the first probe failing (live Tor flake): a probe ran, no onion row fails, recovery is not asserted",
]
if A["error"] or B["error"]:
for n in names:
report(n, False, A["error"] or B["error"])
else:
ev, pr = A["events"], probes(A["events"])
skipped = re.search(rf"skipped leg {re.escape(SKIP_LEG)}", A["out"]) is not None
report(
names[0],
verdicts(A, REACH) == ["pass"] and not skipped,
f"reachability verdicts {verdicts(A, REACH)}, onion leg skipped {skipped}",
)
first = pr[0] if pr else None
applies = [e for e in ev[: first[0]] if e.startswith("apply ")] if first else []
report(
names[1],
bool(first)
and applies[-1:] == ["apply onion=true client_auth=true control=true"]
and first[1].get("onion") == "provisioned"
and first[1].get("keyed") == "yes"
and "apply-result ok" in ev[: first[0]]
and "apply-result failed" not in ev[: first[0]],
f"last apply before it {applies[-1:]}, first probe {first[1] if first else None}",
)
authorized = [(i, p) for i, p in pr if p.get("keyed") == "yes"]
fresh = all(
[
e
for e in ev[max((j for j, _ in pr if j < i), default=-1) + 1 : i]
if e.startswith("client-key ")
]
== ["client-key ok"]
for i, _ in authorized
)
keyless = [(i, p) for i, p in pr if p.get("keyed") == "no"]
probe_source = Path("tests/integration/lib/run-onion-targets.sh").read_text()
hardening_probe = re.sub(r" auto\)\n.*? ;;\n", "", probe_source, flags=re.S)
readers = "DASHBOARD_ONION_CLIENT_PRIVKEY" in (
Path("tests/integration/lib/run-hardening.sh").read_text() + hardening_probe
)
report(
names[2],
len(authorized) == 3
and fresh
and len(keyless) == 1
and keyless[0][1].get("clean") == "yes"
and not readers,
f"authorized probes {len(authorized)}, fresh CLI reads {fresh}, clean keyless probes "
f"{sum(p.get('clean') == 'yes' for _, p in keyless)}, hardening direct reader {readers}",
)
restart = [i for i, e in enumerate(ev) if e == "restart tor"]
later = bool(pr) and any(r > pr[0][0] and any(i > r for i, _ in pr) for r in restart)
report(
names[3],
later and verdicts(A, RECOVER) == ["pass"],
f"restart then probe {later}, recovery verdicts {verdicts(A, RECOVER)}",
)
last_apply = [e for e in ev if e.startswith("apply ")][-1:]
report(
names[4],
A["final"] == BASELINE
and A["restored_state"]
and last_apply
and last_apply[0].startswith("apply onion=false")
and verdicts(A, UNITS) == ["pass"]
and verdicts(A, RESTORED) == ["pass"],
f"config restored {A['final'] == BASELINE}, last apply {last_apply}, units {verdicts(A, UNITS)}",
)
onion_red = [t for v, t in B["rows"] if v == "fail" and "onion" in t.lower()]
report(
names[5],
len(probes(B["events"])) >= 1 and not onion_red and not verdicts(B, RECOVER),
f"probes {len(probes(B['events']))}, failing onion rows {onion_red}, recovery verdicts {verdicts(B, RECOVER)}",
)
report("C8 a clean client without credentials is refused", verdicts(A, KEYLESS) == ["pass"])
for label, kwargs in (
("failed first CLI read despite valid output", {"client_fail": "1"}),
("empty first CLI output", {"client_empty": "1"}),
("failed second CLI read despite valid output", {"client_fail": "2"}),
("empty second CLI output", {"client_empty": "2"}),
("failed final CLI read despite valid output", {"client_fail": "3"}),
("empty final CLI output", {"client_empty": "3"}),
):
run = drive(**kwargs)
report(
f"C9 {label} fails an onion row and restores baseline",
any(v == "fail" and "onion" in t for v, t in run["rows"])
and len(probes(run["events"])) == (0 if next(iter(kwargs.values())) == "1" else 3)
and run["final"] == BASELINE
and run["restored_state"],
)
for label, kwargs, row in (
("keyless access succeeds", {"keyless": "reachable"}, KEYLESS),
("keyless bootstrap fails", {"keyless": "bootstrap"}, KEYLESS),
("keyless infrastructure fails", {"keyless": "error"}, KEYLESS),
("authorized control after keyless probe fails", {"fail_on": "3"}, KEYLESS),
):
run = drive(**kwargs)
report(
f"C10 {label} fails its row and restores baseline",
verdicts(run, row) == ["fail"]
and run["final"] == BASELINE
and run["restored_state"]
and (
kwargs.get("fail_on") != "3"
or "authorized control failed after the keyless probe (exit 1; keyless exit 1)"
in run["out"]
),
)
for label, kwargs, stage, code in (
("HTTP unreachable", {"fail_on": "4"}, "http-unreachable", 1),
("bootstrap", {"bootstrap_on": "4"}, "bootstrap", 2),
("client error", {"error_on": "4"}, "client-error", 3),
("credentials", {"client_fail": "3"}, "credentials", 4),
):
run = drive(**kwargs)
diagnostic = f"external client probe failed (stage {stage}; exit {code})"
report(
f"C10 post-restart {label} failure is categorical and restores baseline",
verdicts(run, RECOVER) == ["fail"]
and diagnostic in run["out"]
and "PROBE-SECRET-SENTINEL" not in run["out"]
and "CLIENT-CREDENTIAL-SECRET-SENTINEL" not in run["out"]
and run["final"] == BASELINE
and run["restored_state"],
)
run = drive(apply_fail="1")
report(
"C11 failed provisioning apply never probes and restores baseline",
any(v == "fail" and "onion" in t for v, t in run["rows"])
and not probes(run["events"])
and run["final"] == BASELINE
and run["restored_state"],
)
run = drive(interrupt="1")
report(
"C12 interrupted hardening restores exact environment and identity",
run["returncode"] != 0 and run["final"] == BASELINE and run["restored_state"],
)
run = drive(restore_fail="1")
report(
"C13 failed normal restore is reported and EXIT safely completes restoration",
verdicts(run, RESTORED) == ["fail"] and run["restored_state"] and run["final"] == BASELINE,
)
run = drive(entry_auth=False)
report(
"C14 restoration uses the captured phase-entry configuration when the run baseline differs",
verdicts(run, RESTORED) == ["pass"]
and run["restored_state"]
and run["final"]["dashboard"]["onion"]["client_auth"] is False,
)
run = drive(tor_start_fail="1")
report(
"C15 a failed Tor restore start fails the row and retains protected recovery copies",
verdicts(run, RESTORED) == ["fail"]
and not run["restored_state"]
and "hardening onion restore failed at tor-start" in run["out"],
)
if args.selftest:
pass
elif args.results is None:
for n in BENCH:
report(n, False, "bench evidence not supplied")
else:
d = args.results
p = d / "evidence.json"
ev = json.loads(p.read_text()) if p.is_file() else {}
ev = ev.get("evidence", ev)
man = d / "results" / "manifest.txt"
rev = (
re.search(r"^git_rev:\s*([0-9a-f]+)\s*$", man.read_text(), re.M) if man.is_file() else None
)
phases = (ev.get("options") or {}).get("phases")
report(
BENCH[0],
ev.get("commit") == head
and ev.get("tier") == "tier4-e2e"
and ev.get("status") == "completed"
and phases == ["hardening"]
and ev.get("baseline_verified") is True
and rev is not None
and len(rev[1]) >= 7
and head.startswith(rev[1]),
f"commit {str(ev.get('commit'))[:12]}, tier {ev.get('tier')}, status {ev.get('status')}, phases {phases}, "
f"baseline_verified {ev.get('baseline_verified')}, manifest git_rev {rev[1] if rev else None}",
)
log = d / "e2e-harness.log"
text = ANSI.sub("", log.read_text(errors="replace")) if log.is_file() else ""
run = {"rows": parse_rows(text)}
skipped = re.search(rf"^\s*- \[[a-z-]+\] leg\s+{re.escape(SKIP_LEG)}", text, re.M) is not None
r, c, u, k, restored = (
verdicts(run, name) for name in (REACH, RECOVER, UNITS, KEYLESS, RESTORED)
)
report(
BENCH[1],
"pass" in r
and "fail" not in r
and "pass" in c
and "fail" not in c
and not skipped
and "pass" in u
and "fail" not in u
and "pass" in k
and "fail" not in k
and "pass" in restored
and "fail" not in restored,
f"reachability {r}, keyless refusal {k}, recovery {c}, onion leg skipped {skipped}, units {u}, exact restoration {restored}",
)
print(
f"\n{('SELFTEST PASS' if args.selftest else 'ACCEPTED') if all(results) else 'NOT ACCEPTED'}: {sum(results)}/{len(results)} checks pass"
)
sys.exit(0 if all(results) else 1)Possible solutions
Fix
Give the hardening phase an onion leg that provisions its own onion. Enable dashboard.onion.enabled with client_auth: true and the control channel on, then apply. Run _onion_reachable_external against it, restart tor, and run it again. Restore the baseline afterwards, as the control leg already does for the path unit. It also belongs to this leg to spool an onion-client-key request through pithead-control.path and dial the onion with the key from the resulting kit. That proves the dashboard's route end to end, not only the CLI verb's.
Release: date 2026-11-30
Who: operator
Activity
pithead-developer commentedon Sep 24, 2026
Investigation brief (operator pre-read, 2026-09-23) — corrected
still_valid: yes, confirmed on current develop head (a5af51a).
scenario_matrix()(tests/integration/scenarios.sh:57-74) has no row that setsdashboard.onion.enabled, and the hardening phase's own control-check apply (tests/integration/lib/run-hardening.sh:183) sets only.dashboard.secure,.dashboard.auth,.dashboard.controlvia jq — never.dashboard.onion._onion_reachable_external()(run-hardening.sh:55) and the gated leg around it (run-hardening.sh:152-176) still skip viait_skip_leg(run-hardening.sh:154) wheneverDASHBOARD_ONION_ADDRESSis placeholder/empty, which is always. PR #2102 (merged 2026-09-23T15:24:38Z, closes #1882) explicitly deferred this gap to #2603 in its own "What is not tested" section rather than fixing it.root_cause: the hardening phase provisions dashboard.secure/auth/control for its own control-channel leg but never turns the onion on, so the CLI-verb/control-verb key reader (
onion_client_credential, lib/pithead/32-onion-provisioning.sh:142) that PR #2102 added a second caller for is never exercised end to end from outside.fix_shape: extend the existing ctrl_config jq (run-hardening.sh:183) to also set
.dashboard.onion={enabled:true,client_auth:true}(required, not optional — lib/pithead/28-parse-and-validate-config.sh:462-463 refusescontrol.enabled+onion.enabled+client_auth:false), then run the existing_onion_reachable_externalreachability/restart/recovery block against the onion that apply provisions, restoring to BASELINE_CONFIG after (the single end-of-function restore already covers this). Correction: this requires an explicit reorder, not just a jq edit — the reachability block currently sits at lines 152-176, before the ctrl_config apply at line 183+, so it must be moved to run after that apply (or the apply moved earlier), otherwise the onion still won't exist yet when the leg runs. No new scenario_matrix axis needed — this stays hardening-phase-local, matching the issue's own "Fix" section. Optional per the issue's own Fix section and acceptance criterion 2 ("ideally the control kit"): also spool anonion-client-keyrequest throughpithead-control.pathand dial with the resulting kit, to cover the control-verb route in addition to the CLI verb the existing leg already uses — not required to close the issue.evidence_tier: inferred from job 576 (commit 386b29b, phases:[hardening]) — confirmed by reading the job's own log, which shows the literal line
[missing] leg dashboard onion external reachability (#424/#343) — onion not provisioned on this box. Cited in both the issue body and PR #2102. A fix needs a fresh tier4-e2e hardening run on its own head (tier-follows-the-path: this changes what runs on the box during the phase — onion + control provisioning).duplicates_or_blockers: related but not duplicate — #2345 (rotate-dashboard-onion never runs at tier 4) needs the same provisioned-onion fixture; keep separate PRs, can share a fixture helper. No blocker: PR #2102 is merged and is the only other work in this area.
Triage — corrected: not "MOVE-2.0.x" (no such milestone exists). gh confirms #2603 is already sitting in milestone "maintenance & gates" (frozen until GA). Verdict: KEEP it there — no move needed. The substance of the original reasoning is right (test-coverage gap on an already-tiers-1-3-tested, already-merged feature; not a security hole, not a Tari-fork blocker, not on the release checklist), it just argues for staying put, not moving.
Verify against the code before relying on this; it was written by an investigator, not the implementer.
VijitSingh97 commentedon Oct 3, 2026
The manual release checklist (#3065, step 9.4) also checks the negative half: without the client key, the onion does not load at all. The acceptance here names only positive reachability. When this leg lands, please also assert that a dial without the client key fails. The appliance counterpart is #3074, tracked under #3068.
pithead-developer commentedon Oct 19, 2026
Grouped with #2402, but PR #3517 does not close it: Dashboard onion provisioning and positive/negative client authorization require a separate live Tor proof, outside viewport screenshot tooling.. Released for its own pick.
pithead-developer commentedon Oct 19, 2026
Questions before work continues (answer here, then remove the
questionlabel):May acceptance check C4 be narrowed to require product-CLI credentials for hardening's authorized probes, permit its required keyless negative probe, and preserve the existing rotation-recovery credential readers in run-onion-targets.sh and run-rotate-onion.sh? My default is this scoped revision because the current repository-wide prohibition rejects already-merged recovery behavior unrelated to #2603.
pithead-architect commentedon Oct 19, 2026
Ruling: Accept the scoped C4 revision and update its acceptance checker consistently: every authorized hardening probe must obtain fresh credentials successfully through pithead onion-client-key, while the owner-required negative probe uses a clean client without credentials and must fail. Limit the direct-private-key prohibition to this hardening path; preserve the existing rotation-recovery readers in run-onion-targets.sh and run-rotate-onion.sh. Retain provisioning, successful authorized reachability before and after Tor restart, and baseline-restoration requirements. Prove the revised checks can fail, then record a completed current-head tier4-e2e hardening job with the required rows executed; do not expose credentials.
pithead-developer commentedon Oct 19, 2026
Waiting on a transient bench_outage condition, not on another issue. tier4-e2e submission and same-key retry both failed with [Errno 65] No route to host; neither returned a job ID. The runner re-checks it (first at 2026-10-19T15:21Z, at most 5 times).
pithead-developer commentedon Oct 19, 2026
Questions before work continues (answer here, then remove the
questionlabel):A bench_outage condition has held since 2026-10-19T15:06Z through 5 re-checks: Re-check 5: tier4-e2e phase-only submission refused with 503 draining: the runner is shutting down; no job ID returned. Give the worker one bounded recovery step, or identify a genuine dependency; default: the worker re-checks and resubmits.
pithead-architect commentedon Oct 19, 2026
Ruling: Stop resubmitting and return blocked on bench-ci#2125, whose trusted diagnosis reports an intentional owner maintenance drain. Reuse that existing manual infrastructure ticket; retain this implementation issue, worktree and PR #3539. Do not restart, resume, reroute around or time out the hold. After the owner releases it and admission recovery is verified, reconcile the original request, then submit once with the same idempotency key if no job exists, using only the hardening phase option. Return waiting with the confirmed job in bench_jobs. Completion requires current-head tier4-e2e evidence and artifacts, an ACCEPTED result from tests/integration/selftest/hardening_onion.py --results, and the full checker output plus unedited generated evidence in the PR. Preserve required reviews, approvals and current lane policy.
pithead-developer commentedon Oct 19, 2026
Blocked on p2pool-starter-stack/bench-ci#2125. Blocked on p2pool-starter-stack/bench-ci#2125: the intentional owner maintenance hold prevents required proof admission. Implementation, local checks and reviews are complete in PR #3539, where the blocker is documented. After the owner releases the hold and admission recovery is verified, reconcile the original request before submitting once if no job exists.
The runner resumes this issue when that one closes.
53 remaining items
pithead-architect commentedon Nov 27, 2026
Owner decision (2026-11-27): the earlier request to rewrite this work onto develop-v2.0.5 is cancelled, because bug and security fixes now go to develop. The open PR is redone on develop (rebase, conflicts fixed, fresh review); the prepared candidate is not force-pushed. This hold is lifted for that redo.
pithead-architect commentedon Nov 27, 2026
Held again for a few days, without an owner action: the owner's cancellation of the rewrite stands, and this PR will be redone on develop automatically (held until the 2.0.5 fold, or rebuilt on a fresh branch from develop with a replacement PR). This hold only stops wasted review passes until that change is live, and is lifted then.
pithead-developer commentedon Nov 28, 2026
Hold lifted: the runner change for the owner's 2026-11-27 decision is live. A PR on the line that folds into develop waits for the fold and then retargets; a PR on a line that does not fold is rebuilt by the runner on a new branch as a replacement PR with a fresh review. No force-push.
pithead-developer commentedon Nov 28, 2026
Waiting on a transient release_hold condition, not on another issue. bench-submit held: release-window hold: pithead tier4-e2e for the current patch milestone is queued or running (job 4682) and pithead#2603 is not in it; nothing was submitted. The runner re-checks it (first at 2026-11-28T07:17Z, then every 240 minutes until the release e2e queue drains).
pithead-developer commentedon Nov 29, 2026
Waiting on a transient release_hold condition, not on another issue. bench-submit exit 75: release-window hold: pithead tier4-e2e for the current patch milestone is queued or running (job 4746) and pithead#2603 is not in it; nothing was submitted. The runner re-checks it (first at 2026-11-29T11:37Z, then every 240 minutes until the release e2e queue drains).
pithead-developer commentedon Nov 29, 2026
Blocked on p2pool-starter-stack/bench-ci#2820. Pithead PR #4622 is blocked on p2pool-starter-stack/bench-ci#2820. The hardening proof on head e154d4d needs a tier4-e2e job that reserves a pithead rig, and that job has not run. Jobs 4778 and 4779 (the --new-attempt resubmission) were both fleet-routed to a bench that lends 0 pithead rigs, and both errored at reserve after 1s, before any check ran. The only bench that lends a pithead rig serves the node, and submitters may not pin jobs there. What is finished: the head merges current develop with its one conflict resolved, and the PR's own diff is unchanged. GitHub reports 45 checks passed and 2 skipped, and the PR is mergeable. The touched selftests pass locally. Job 4752 passed on the previous head 7f4d883, and the checker accepts its artifacts 29/29 there. What clears it: a fix to bench-ci#2820 by the bench-ci maintainers, or a non-node-serving bench that lends a pithead rig. Then resubmit the hardening-only job on this head, run the checker on its artifacts, and tick acceptance boxes 1 and 2. I recorded both jobs on bench-ci#2820 and posted this explanation on the PR.
The runner resumes this issue when that one closes.
pithead-developer commentedon Dec 4, 2026
Blocked on p2pool-starter-stack/bench-ci#2905. PR #4622 is blocked on p2pool-starter-stack/bench-ci#2905. Its remaining proof is a pithead tier4-e2e job with only phases=hardening on head e154d4d. Only one bench lends a pithead tier4-e2e rig, and it refuses deploying e2e jobs at preflight because too few hugepages are free (1256, with 1296 needed). Job 4885@e154d4d01b506249b465d3a2bf140104646af133 errored there at preflight with run and collect skipped, and every pithead tier4-e2e job that started on that bench from 12:08Z to 18:43Z was refused the same way, so a resubmission would repeat it. Already done: the change, GitHub tiers 1 to 3 on this head (45 passed, 2 skipped), and job 4752 passing on the previous head with the offline checker accepting its artifacts. I added this job's evidence to bench-ci#2905, put the final 4885 block in the PR body, and commented on the PR. To unblock, a bench-ci change or the operator must fix bench-ci#2905, by reserving that bench's hugepage pool and keeping it free between jobs, or by treating the shortfall as a capacity wait. Then the worker resubmits the hardening job, runs hardening_onion.py on its artifacts and updates the proof.
The runner resumes this issue when that one closes.