Opt-in caller tokens and TLS on both hops, so clankerbox runs without a tailnet (0.44) #72
All Vouch review confidence checks passed
Residual risk 0.30 = Change Risk (0.75) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.75 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Sensitive Paths
sensitive_paths
0.075
Real PR Conversation Timeline
1 comments
"Review active on #72"
general
weight: 0.35
gjermundgaraba
Opt-in caller authentication for 0.44, so clankerbox can run without a tailnet. Each caller of the control plane presents a named bearer token, and the control plane presents its own token to each host; both hops run over TLS. Do not merge or release yet: this is for review.
What it adds
tokens: truemakes it take only a bearer token whose SHA-256 its store (server.db, newtokenstable) holds unrevoked, andtlstakes{cert, key}. Any other request is refused withUnauthenticated(401) before anything runs. The check reads the table at each request, so mint and revoke take effect from the next request with no restart. It sits after the Origin refusal and before the version check.listTokens,mintTokenandrevokeTokenactions (clankerbox token list|mint|revoke). Any caller's token may use them (Gjermund's decision: no per-token flag), so every token is full control of the fleet; the README says so, and that after a leak you list and revoke everything you don't recognise. A revoked row stays, solistshows every token, who minted it and when, including what a since-revoked token minted.callers, a file of<name> <sha256 hex>lines read at start, andtls. A host has no store, so its one token stays in config. Eachhosts[]entry in the server config can name atokenfile, which the control plane sends to that host. A host that refuses the token shows as unreachable inhosts, with the message "host X refused the control plane's token".publish.addresson a host is where machine SSH ports are published. It defaults tolisten.address, so a host's API can stay on a private address while SSH sits on a public one.Client.make({ token })in the SDK,token(a file) in the CLI config,token(a file) in the amp-orbs settings, andtoken(the value) in the Rivet provider. A refused client now getsInvalidwith a message saying what to fix, where it used to getInternal"answered unexpectedly".clankerbox-server token add <name>prints a token once. With--config <server config>it writes into the store, opened and locked as the control plane opens it. So it refuses while the control plane runs: that's the bootstrap. With--callers <file>it appends a host's hash line.The conditions
1. Opt-in is real. With no
tokens(orcallerson a host),requireTokenpasses every request and no client sends a header. The CGNAT/loopback restriction is unchanged. Every existing server, host, CLI, SDK and provider test passes without modification:vp run readyreports 16/16.2. A public listen address without auth is refused at startup. I enforced this in config validation rather than in the type.
listen.addressdecodes as any IP, andloadConfigon both sides runslistenRefusal, with{tokens, tls}on the control plane and{callers, tls}on a host. A tailnet or loopback address always passes. Any other address needs both, andtokens: falsecounts as unset; without them the config failsInvalid, naming what's missing and why.listenRefusalis the only path from a decoded address to a served one. I chose not to make the address type depend on auth, because the two come from different fields of the same struct.3. Proven off-tailnet (transcript below). The real
clankerbox-serverbinary ran on 203.0.113.10:8585 and a host on 203.0.113.20:8484, both with TLS and tokens, with machine SSH published on 203.0.113.21. These are TEST-NET-3 addresses added tolo. Notailscalebinary exists on the machine. The built CLI ran hosts, create, exec (hello from dev), stop, start and get. The control plane recordeddev's endpoint as203.0.113.21:21000while the host's API listened on.20, so the API/SSH split works. Tokens ran there too: the first was minted offline with the control plane stopped, andtoken addwas refused while it ran.token mint orbswas served at once, and orbs mintedphone;token revoke orbsrefused orbs' next call with no restart; andtoken liststill showed orbs, revoked, andphone, minted by orbs.4. Every refusal has a test that fails without it. Planted wrong implementations, each caught by a test:
- prefix comparison, empty-token acceptance, any-64-hex acceptance;
- passing when there is no Authorization header;
- routes without
requireToken, on either side;- the token set cached at startup (the revoke test gets 200 where it wants 401), revoked tokens taken,
listhiding revoked tokens or what a revoked token minted, no minter recorded, and everyone passed while no token is minted;-
listenRefusalrequiring only one of the two, accepting either one, treating every address as private, or countingtokens: falseas on;- the control plane sending no token;
- a host's 401 read as a plain unanswered call;
- the SDK sending no token, or reading 401 as unexpected;
- the CLI dropping its token;
- four bugs in
token add(writing the raw token, overwriting the file, joining onto a line without a trailing newline, allowing a duplicate name).Each commit message lists the ones for its piece.
5. Constant time.
timingSafeEqualruns over every caller's hash, even after a match. The function is namedcallerInConstantTimerather than relying on a comment, because this repo'sno-prose-commentsrule asks for names. No test asserts the timing: lint forbidsvi.mock, and a timing measurement would be flaky.Where this differs from what was agreed
Authentication. Itscaller/protectrequires a credential on every action of every deployment, so a deployment without tokens would break, which contradicts condition 1. I wroterequireTokenas router middleware instead, about 40 lines, answering with effect-actions' ownUnauthenticatedso clients decode it as a built-in.NODE_EXTRA_CA_CERTS. The README says so.Second review (3dcd116), fixed in 56e66ae0, acd30fe3, 3fc5ad42
clankerbox-server token listandtoken revoke --config, besidetoken add, each refusing while the control plane runs. Without them a leaked token could mint more and revoke the operator's, andtoken addalone left the attacker's tokens live after restart. The README's recovery is now the stopped-server sequence: list, revoke, add under a new name, start. A revoked name stays taken (Conflict) on purpose, solistkeeps saying who minted what; the README says to pick e.g.laptop-2.isTailnetOrLoopbackthat takes every IPv4-mapped address and one that takes none.CHECKontokens.hashhas no test, deliberately. The only writer always writes 64 lowercase hex; the constraint guards hand edits ofserver.db. A bad row would fail closed (every request a 500), not open.::1%lo(a zone ID) was taken as loopback by the old BlockList and is now refused by the shared rule, so such a listen address needstokensandtls. It fails closed.docs/design/control-plane.mdnow says the tailnet is the only gate only without tokens. A repo-wide search for the claim in other wordings found no other unconditional copy.Third review (3fc5ad4), fixed in 4e971702, 51b6440f, dbd61f56, c03c74dd
2001:db8::ffff:7f00:1,1::ffff:127.0.0.1,fe80::ffff:6440:1,0:0:0:0:1:ffff:7f00:1, plus the loopback near misses::ffff:0:1,::5:0:1,0:0:0:0:1:0:0:1and1::1.packages/sdk/tests/weakenings.tslists 21 weakenings of the auth guards, the eight reviewers found by hand among them. Each comes with its source edit and the test that must refuse it.node packages/sdk/tests/weakenings.ts .plants each one, runs its test, restores the file, and exits 1 if any passes. All 21 are refused at this head. AGENTS.md points to it.stateDirused to create an emptyserver.dband print an empty table with exit 0. Both commands now refuse it and create nothing, and they print only rows already read. Only the lock refusal says to stop the control plane. A newer schema or a foreign file keeps its own message. The offline revoke answersNotFound, like the online one. The table rows come from the SDK'stokenRows, which the CLI shares. The offline test lists after revoking, so alistthat drops revoked rows fails it.MINTED_BYfrom the leaked token and anything minted after the leak, re-add callers the leak revoked, and list again before starting. The README now says this restores the tokens table and nothing else.Harness verification (c03c74d), fixed in daa290cd, 08558d03, 41795afa
vpoff PATH it printed all 21 refused and exited 0. Now each weakening names the test that must refuse it. A weakening counts as refused only when its run exits 1, the named test fails on an assertion, and no file fails to load. Each test file must also pass on the unchanged code before anything is planted. Anything else exits 1. Each of these exits 1:vpoff PATH (spawnSync vp ENOENT), a pattern that no longer matches, a plant that doesn't compile, a missing test file, a plant caught only by a test other than the one it names, a dirty source file at start, SIGINT to the process group, and SIGTERM to node. After both signals the source files are clean.randomBytes(2)…repeat(16)(16 bits) andrandomBytes(16)fail it, and both are in the list. All 23 are refused, each by the test it names. No functional test can tellrandomBytesfrom a non-cryptographic generator of the same width, and the repo forbids module mocks, so the source itself is pinned only by review.weakeningsjob runs the harness on a fresh checkout. It stays out ofvp run ready, since it edits source. Its first two CI runs failed closed, never reporting success:- At 41795af the baseline failed, because the job lacked the zsh and busybox guest shells the host's tests need. 5900962 installs them and prints a failing baseline's output.
- At 5900962 all 23 runs were unproven, because CI colours vitest's
FAILlines and the harness couldn't read them. 7b7b8bf strips terminal escapes first, and on CI all 23 are now refused, each by its named test.execsurvives the procedure. When the leak's start is unknown, treat every token as minted after it.listhas no REVOKED_BY, so "revoked though you didn't" rests on memory. Then audit machines, checkpoints and templates. Neither REVOKED_BY norlast_used_atis added, by Gjermund's decision (see below).Checked against practice (7b7b8bf), with the token prefix in 53b62d6e, b0cf00a4, f8f6f222
A review compared the design with how others solve the problem, not only looking for bugs. Its verdict: this is the normal shape.
token_digestwork.credentials_filedoes it.Every token is an admin token, by Gjermund's ruling. This departs from the role split in Nomad (management against client tokens), Buildkite (agent tokens) and Tailscale (auth keys against API tokens). The likeliest leak, an unattended provider's token, can mint its own persistence. MINTED_BY, the offline
token listandrevoke, and the README's stopped-server recovery are what make this survivable. It is deliberate, not an oversight.No REVOKED_BY and no
last_used_at, by Gjermund's decision. The tokens table records who minted each token and when, and when it was revoked, and nothing more. So the README's "revoked though you didn't" step rests on the operator's memory, as a permanent property of the design rather than a gap waiting on a column. Both stay cheap to add later if operating clankerbox makes them worth having: a nullable column each, an optionalTokenfield, and forlast_used_ata coarse write at most every few minutes per token so a request doesn't become a database write.Token prefix (53b62d6e). A token used to be 64 hex digits, the same form as the SHA-256 it is kept as. GitHub left that format in 2021 because scanners can't tell such tokens from hashes.
cbx_and a host'scbxh_, each followed by 32 random bytes as hex. gitleaks, trufflehog or GitHub push protection can matchcbxh?_[0-9a-f]{64}, and the README says so.token add, the mint API and callers files refuse a SHA-256 or a token given as a name. Before, a pasted hash was taken as a valid name.- comparing only 4 bytes after checking the caller's prefix, or the host's;
- taking any prefixed token without comparing;
- hashing only a token's first 36 characters, or its digits without the prefix;
- a token file taking either hop's token;
- a SHA-256 passing as a name.
token list --configoutput pinned. Printing nothing passed every test, though the recovery procedure is built on reading that output. The offline test now runs the command itself and asserts its header and, for each row, the name, MINTED_BY and whether it is revoked. The weakenings "prints nothing" and "prints no MINTED_BY" are refused, 32 in all.The Stryker trial found two fail-opens that four review rounds and the hand-built weakenings list all missed (fixed in f8f6f222). Each would have let a control plane or host listen on a public address believing it private, with no tokens and no TLS, and let a client send its token there over plain http. That is the exact hole the startup refusal exists to close:
a === 100inisTailnetOrLoopbackacceptsx.64–127..for any first octet:10.64.0.1passed every test as tailnet;a1e0:2001:db8:a1e0::5passed every test as tailnet.Fifteen more survivors took malformed text as loopback or tailnet, such as
0::1g,127.0.0.256,127.0.0.01and a seven-groupfd7a:115c:a1e0address. Twenty table rows now kill all 146 mutants ofreach.ts.What the trial cost, for whoever adopts it properly. AGENTS.md has the same notes, beside the weakenings list.
tsconfigFilemust name no file, because TypeScript 7 has no JS API for Stryker to read a tsconfig with.inPlace: true, because Stryker's sandbox copy breaks each package's relativeextendsof the base tsconfig. Running in place edits the checkout, so it needs a scratch worktree.tokens.ts,token.tsand listen check in 60 s, with the test files narrowed.- about 15 SDK survivors were equivalent or harmless, such as bearer-regex anchors (a matching token is still required);
- the server's survivors are all in the
tokencommand layer, which is how the emptytoken listoutput was found.readTokenand the caller-name and prefix rules) have no coverage in the SDK's own suite, because their tests live inapps/cliandapps/server, so SDK coverage understates what is tested.Candidate for later: a
clankerbox-server tls inithelper, since an off-tailnet deployment now needs TLS.Not covered
publishAddress(settings)where they readlisten.address. That one-line change is checked by types only: no runtime here can boot a guest. The split was proven through the fake runtime, which now reads the same address.Release note for 0.44
0.44 adds opt-in caller authentication, so clankerbox can run without a tailnet. Set
tokens: trueandtlson the control plane,callersandtlson each host, atokenfile on eachhosts[]entry, and atokenin each client. The control plane and hosts may then listen on any address; without both fields they still refuse anything but a tailnet or loopback address. Mint your first token withclankerbox-server token add <name> --config <server config>while the control plane is stopped. A caller's token startscbx_and a host'scbxh_, so secret scanners can find a leaked one. After that, mint, list and revoke tokens withclankerbox token, which takes effect at once with no restart. Any caller's token can do this, so treat every token as full control of the fleet: after a leak, stop the control plane and follow the README's recovery steps withclankerbox-server token listandtoken revoke --config. A host can publish machine SSH onpublish.address, apart from its API. Nothing changes for a deployment that sets none of these. Upgrading is still lockstep by release as before, but turning tokens on is a separate step you take when ready.Off-tailnet transcript, before the move to the store (abridged)
The rerun against the store is
off-tailnet-store.shand its transcript, beside the original scriptoff-tailnet.sh, kept in the Amp thread's orb backup. The test harness now acceptsCLANKERBOX_HOST_CONFIG(commit 340f504f), which is what let it serve a host from a real host config.Fixes from Greptile's review
Client.makeand the server config's host entries refuse any other URL with a token.0.0.0.0/::, whether set directly or inherited from a wildcardlisten.address.token add(8780db1b): it now appends instead of rewriting. The help no longer claims the log names the caller.Each fix has a test that fails against the old behaviour or a planted wrong version.
vp run readypasses 16/16.