Repository navigation
secrets-broker: per-secret age, partial-refresh install, age/source exposure (#6767) - #8491
Conversation
…xposure (#6767) The full-vault refresh was fail-whole (#5504): one failed bws get discarded the entire refresh, so a single broken fetch could block every rotation in the vault indefinitely — the 2026-11-06 stale turso token incident, where the broker served the old value at +10min with no bound and no way to see the cached values age. - Cache entries now carry fetched_at_unix (per-secret age). - install_refresh installs per secret: successes land with the new timestamp; a failed fetch keeps the previous value AND age (the #5504 no-eviction rule, per secret); deletions follow the authoritative list; a zero-success refresh installs nothing. - GET /secret/<name> exposes fetched_at_unix, age_seconds, source (cache | bitwarden-read-through); /health adds oldest_secret_age_seconds. A rotation now lands within one TTL, and a runbook can verify the broker against BWS by age. - Tests: partial install oracle, zero-success keep-whole, and the age/source response shape. 59/59 lib tests pass with the secrets-broker feature. Post-deploy verification (needs the rebuilt broker live): create a canary secret in BWS, read it through the broker, rotate it, and assert the new value + a fresh fetched_at_unix within one TTL.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 17 minutes. View limit details
Pre-merge checks:
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f899dd8983
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| // EVERY fetch failed keeps the whole previous cache (the | ||
| // fail-whole tail this replaces let one broken fetch block every | ||
| // rotation in the vault indefinitely). | ||
| match install_refresh(state, &items, fetched, now_unix()) { |
There was a problem hiding this comment.
Preserve each successful fetch's actual timestamp
When one bws get is slow, earlier successful fetches wait for every worker to join and are then stamped with the refresh-completion time. A secret fetched before a rotation can consequently be served with fetched_at_unix after the rotation and age_seconds: 0, making a stale value appear freshly verified against Bitwarden. Capture a timestamp alongside each successful fetch and preserve it during installation rather than assigning the entire batch this completion timestamp.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 7c9c2b5 — thank you, this was a real correctness hole in the age exposure itself. The worker pool now stamps each successful fetch with its own completion time ((value, now_unix()) at the fetch site), and install_refresh preserves the per-fetch timestamp instead of the batch install time. The install test oracle now pins exactly your scenario: alpha fetched at t=190 during a refresh installed at t=200 keeps fetched_at_unix: 190. Broker suite: 14/14 pass; full lib suite with the secrets-broker feature: 59/59.
…Codex PR #8491) The worker pool stamps each successful fetch with its own completion time and install_refresh preserves it, so a value fetched before a rotation can no longer claim a fetched_at_unix after it. Test oracle strengthened: alpha fetched at 190 during a refresh installed at 200 keeps 190.
Refs #6767 — the issue stays open for the post-deploy canary verification named below; the code fix lands here.
Root cause
The broker's full-vault refresh was fail-whole (#5504): if any one secret's
bws getfailed, the entire refresh was discarded and the previous cache kept. One persistently failing fetch therefore blocked every rotation from landing, indefinitely — the 2026-11-06 incident, where the broker served the rotatedturso.muse-mirror-rw-token's old value at +20s and still at +10 min. Cache hits were never re-checked, andGET /secret/<name>exposed no age/source, so a rotation runbook could not distinguish "the broker is stale" from "Bitwarden itself holds this value".Change (
secrets_broker.rs, per the issue's named design){value, fetched_at_unix}.install_refresh: successful fetches land with the refresh timestamp; a failed fetch keeps its secret's previous value and previous age (the fleet(secrets-broker): a partial vault refresh silently evicts cached secrets — one failed bws get becomes a 404 and a 'successful' refresh #5504 no-eviction rule, applied per secret instead of failing the whole refresh); names absent from the authoritative list are removed; a refresh in which every fetch fails installs nothing (source outage ≠ vault news). Partial installs are logged with the kept-failed count.GET /secret/<name>now returnsfetched_at_unix,age_seconds, andsource(cache|bitwarden-read-through);GET /healthaddsoldest_secret_age_seconds. Response additions are backward-compatible for existing clients (fleet secrets get, queue broker) which readvalueonly.A rotation now lands within one TTL (default 900s) even while another secret's fetch is broken, and staleness is bounded and observable.
Tests
cargo test -p fleet-queue --lib --features secrets-broker: 59/59 pass, including 3 new tests:install_refresh_lands_successes_keeps_failures_and_drops_delisted— the fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767 oracle (rotate lands, failed fetch keeps old value+age, delisted removed);install_refresh_with_zero_successes_keeps_the_whole_previous_cache;secret_response_exposes_age_and_source.Post-deploy verification (remaining, named on #6767)
With the rebuilt broker deployed: create a canary secret in BWS, read it through the broker, rotate it in BWS, and assert the broker serves the new value with a fresh
fetched_at_unixwithin one TTL. The unit tests pin the mechanism; the canary run is the live proof.🤖 repo-worker-code lane code-y, task 11460