Skip to content

Free key cache hardening - #7

Merged
timbode merged 2 commits into
mainfrom
free-key-cache-hardening
Jul 22, 2026
Merged

Free key cache hardening#7
timbode merged 2 commits into
mainfrom
free-key-cache-hardening

Conversation

@timbode

@timbode timbode commented Jul 22, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

timbode added 2 commits July 22, 2026 18:17
The disk cache itself was already right — this is the surrounding behaviour.

A cached key the server rejects was a permanent dead end: any status >= 400
threw, so a cache that outlived its key (server reset, key revoked, file
copied from another machine) 401'd every call until the user worked out
they had to rm the file by hand. A 401 now discards the cached key and
retries once, keyless, which mints a replacement and caches it.

The retry is bounded on purpose. Only a key read from disk is discarded —
never one minted in this run, never a caller-supplied `key`. A run can
mint at most one key beyond the stale one, so the recovery path cannot
become the very mint loop it exists to prevent. That is the failure mode
the sibling clients are currently showing in production (many keys per
caller), and it would be worse to fix cross-run reuse while opening a
per-call remint here.

Storage: the file is a credential, so it is now 0600 rather than 0644, and
written to a temp file that is moved into place — an interrupted or
concurrent write could otherwise leave the next run sending a truncated
key. Persisting is best-effort: an unwritable cache warns instead of
failing a solve that already succeeded.

QUICOPT_KEY_PATH overrides the location for environments whose home does
not survive the run (CI, containers), which otherwise remint per session.

solve() was growing past the point of reading as one thing, so submission
(_submit/_submit_authenticated) and the async poll loop (_await_job) are
now their own functions; the body reads as the sequence it is.

New public surface (QUICOPT_KEY_PATH) plus changed behaviour, so 0.3.0.
v0.2.0 is tagged and registered, so it cannot be revised.
The prior commit bumped to 0.3.0 on the reading that QUICOPT_KEY_PATH is new
public surface. The better reading is the other one: this is a fix restoring
behaviour the client was always meant to have, and the env var exists to serve
that fix rather than to add a feature. A caller who never touches it gets a
client that recovers from a stale cached key — a repair, not a capability.

The patch is also the stronger number downstream. Any dependent pinning
QuicoptClient = "0.2" accepts 0.2.1 under Pkg's caret rules but would reject
0.3.0, and a fix should not need a resolver change to reach the people it is
for.

v0.2.0 is registered and tagged, so 0.2.1 is the next available number.
@timbode
timbode merged commit 55ac42b into main Jul 22, 2026
2 of 3 checks passed
@timbode
timbode deleted the free-key-cache-hardening branch July 22, 2026 18:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant