GeezerVison is showing github.com — fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates · Issue #6767 · developing-today/code
fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767Labels app/fleetpkgs/fleet multicall binary + platform cratesdesign/fleet-brokersDesign: fleet-brokers - all issues of this effort carry iteffort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)task/triageQueue packet kind: verify, reproduce, and route this item DescriptionProblem
The laptop secrets broker serves a STALE secret value long after the
secret is rotated in Bitwarden Secrets Manager. fleet secrets get
(broker-first) keeps returning the pre-rotation value, so a rotation
appears to succeed while every broker consumer keeps using the dead
credential.
Observed (2026-11-06, during the runtime-db-export Turso repoint, #5691)
- BWS secret
turso.muse-mirror-rw-token rotated via bws secret edit;
verified by direct bws secret get: new value sha256 fingerprint
6320fec2 (len 348).
fleet secrets get turso.muse-mirror-rw-token returned the OLD value
(fingerprint a0542dc2) at +20s after the edit, and STILL at +10 min:
the repointed loader's live probe at ~22:05 CST had its broker-supplied
token rejected by Turso (auth role not found) and only succeeded via
a direct-BWS fallback.
- The old token was not merely stale but WRONG for the current DB
(minted against a superseded muse-mirror instance), so the failure
mode was a hard auth rejection, not a soft staleness.
Impact
Any consumer resolving rotated secrets through the broker silently uses
dead credentials after a rotation (DB tokens, API keys). Rotation
runbooks that verify via BWS directly will report success while broker
consumers keep failing.
Expected
- The broker reflects BWS edits within its documented TTL (bounded,
minutes at most), or fleet secrets get documents that it may serve
cached values and exposes the value's age/source.
- Regression check: rotate a canary secret in BWS, assert
fleet secrets get returns the new value within the TTL.
Related: #5860 (secrets-broker vault-refresh loop defects — TTL=0 spin).
Workaround in place: ~/tools/runtime-db-export/turso_client.py falls
back to a direct BWS read when the DB rejects the broker-supplied token.
Acceptance criteria
- After a secret is edited/rotated in Bitwarden Secrets Manager,
fleet secrets get <name> returns the NEW value within a bounded, documented TTL (minutes at most) — no indefinite staleness.
- A regression check exists: rotate a canary secret in BWS, then assert the broker-served value matches the direct-BWS value within the TTL.
- If a cached value is ever served, its age/source is knowable (documented behavior or exposed metadata), so a rotation runbook can tell whether it is verifying the broker or BWS.
- The stale-value failure mode from the 2026-11-06 observation (broker token rejected by Turso at +10 min after rotation) no longer reproduces.
Activitydezren39 commented on Nov 7, 2026 Intake review
🤖 Agent note · filed
- Agent: fleet monitor (repo-fleet-monitor)
- Session / ID: cron repo-fleet-monitor run 2026-11-06 22:12 CST
- Found via: monitor reconciliation — Duty 2 intake enrichment
- Task: Intake pass: verified still live, appended acceptance criteria, normalized labels (priority/high, effort/m, status/needs-triage), marked meta/enriched.
- Expectation: A queue lane picks this up as a small-fix/triage packet; done = broker reflects BWS rotations within a bounded TTL with a canary regression check.
Still live? Yes. Searched merged PRs for a secrets-broker cache fix: PR #5506 (partial refresh keeps previous cache, issue #5504) and PR #6292 (read-through + empty values fail loudly, issue #6275) predate this report and do not address post-rotation staleness — this issue's evidence is a fresh 2026-11-06 observation (during issue #5691 work, ~22:05 CST) where the broker still served the pre-rotation value at +10 min and Turso rejected it.
Related: issue #5860 (OPEN — SECRETS_BROKER_TTL_S=0 vault-refresh spin; same broker cache/refresh subsystem, likely worth fixing in the same pass or at least not regressing), issue #5691 (the work during which this was observed).
Risks: silent credential staleness is worse than a loud failure — rotation runbooks verify via BWS directly and report success while broker consumers keep failing on dead credentials. Any fix must keep the broker-first path fast (it is on the hot path for fleet tooling) and must not reintroduce the #5860 refresh spin.
Suggested approach: make the read-through cache TTL-bounded and/or keyed to a BWS-side version signal so an edit invalidates promptly; expose value age/source if a cached value is served; add the canary rotation regression check from the acceptance criteria. The direct-BWS fallback already in ~/tools/runtime-db-export/turso_client.py is a workaround for one consumer, not the fix. developing-today commented on Nov 8, 2026 ContributorAuthor More actions agent-note:v1
state: triaged — CONFIRMED, mechanism pinned at current main, fix enqueued
Agent: repo queue worker lane code-r, task 11261 (triage of issue #6767)
Queue: repo-health-code-pilot
Revalidation (fresh, 2026-11-07)
Issue #6767 is OPEN, priority/high, no hard-stop labels, no linked PR. Read and this note via the developing.today App route (user-token GraphQL limit exceeded this shift). Source verified at current main ab35bef4cae2babea2f9835b66293b33bacbf88d (2026-11-07 19:03 CST), file pkgs/fleet/crates/fleet-queue/src/secrets_broker.rs.
Verdict: CONFIRMED — and the mechanism is more specific than "the cache never invalidates"
A TTL refresh exists, but three properties combine to produce the observed indefinite staleness:
- Cache hits are served with no age check at all.
GET /secret/<name>: Some(v) => (200, {"key", "value"}) — a hit returns the cached value unconditionally, and the response carries no age or source metadata (only /health exposes last_refresh_unix). Nothing on the read path enforces or documents a staleness bound, so acceptance item 3 (age/source knowable) is unmet by construction.
- The refresh is all-or-nothing.
do_refresh counts per-item failures and, if failed > 0, returns Err and keeps the ENTIRE previous cache ("{failed} of {total} secret fetches failed; keeping the previous cache" — the fleet(secrets-broker): a partial vault refresh silently evicts cached secrets — one failed bws get becomes a 404 and a 'successful' refresh #5504 anti-eviction contract). One persistently failing secret therefore pins every other secret's rotated value stale, refresh after refresh, indefinitely. This is the "never invalidates" path: it needs only one bad item in the vault.
- Even a healthy refresh loop is slower than the documented expectation. The loop is refresh-then-
sleep(TTL) with SECRETS_BROKER_TTL_S default 900, so worst-case staleness is TTL + full-vault refresh duration (>15 min), and the 2026-11-06 observation of a stale value at +10 min sits inside a single healthy window. Read-through (secrets broker: no read-through on cache miss — newly minted secrets invisible up to 15 min, client returned empty #6275) does not help: it fires only on cache MISSES (new names), never on a rotated existing name. POST /refresh exists as a manual escape hatch, but fleet secrets get never triggers it and a bws secret edit rotation runbook has no reason to know it exists.
Related: #5860 (SECRETS_BROKER_TTL_S=0 refresh spin) is the same file/subsystem — note ttl_s parsing here accepts 0 with no floor. The fix pass should land the TTL floor with this work or record explicit ordering against #5860; do not regress it.
Fix scope (enqueued as the follow-up task)
- Per-secret fetched-at tracking: a hit older than the TTL triggers a bounded single-flight read-through for that name (the inflight seam already exists) and installs the fresh value; if that fetch fails, serve the stale value WITH its age, never silently.
- Partial refresh installs what succeeded: on per-item failure keep the old value for the failed names only, instead of aborting the whole map — preserving fleet(secrets-broker): a partial vault refresh silently evicts cached secrets — one failed bws get becomes a 404 and a 'successful' refresh #5504's anti-eviction intent without pinning the whole vault.
/secret responses (or fleet secrets get output) expose value age/source so a rotation runbook can tell whether it verified the broker or BWS.
- Regression tests at the existing fake-runner seam in secrets_broker.rs: (a) value rotated mid-TTL is re-fetched after TTL on next read, (b) a refresh with one failing item still installs the other rotated values, (c) read-through failure on an aged hit surfaces age/error, not a silent stale 200. The live canary rotation check from the issue acceptance is the ops verification after deploy.
This triage task (task 11261) completes as triaged; issue #6767 stays OPEN for the fix. dezren39 commented on Nov 8, 2026
Agent note — task 13703 triage re-confirmation (lane code-x)
- Claimed task 13703 (triage, issue fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767); execution lane assigned: direct. This task was a monitor safety-net retry (queue/queued label with no live triage task).
- Fresh revalidation: issue fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767 OPEN, priority/high, no hard-stop labels (held / user/owned / do-not-merge / do-not-auto-edit absent), no PR references it.
- Verdict: STILL LIVE at current main 8f79a40 — confirms the task 11261 triage (2026-11-07) mechanism in pkgs/fleet/crates/fleet-queue/src/secrets_broker.rs: cache hits served with no age check, do_refresh all-or-nothing (one failing item keeps the entire previous cache), refresh-then-sleep TTL 900s, read-through only on cache misses.
- Route: the fix follow-up from task 11261 already exists and is live — task 11460 (small_fix, dedupe repo-health:v1:fix:developing-today/code:issue:6767, status queued, created 2026-11-08T01:12:06Z). Re-enqueue attempt by this lane returned that dedupe hit; no duplicate created.
- Issue fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767 stays OPEN for task 11460; queue/queued correctly remains (a queued task exists).
dezren39 commented on Nov 8, 2026
Agent note — task 13703 structured outcome (lane code-x)
The queue complete verb for task 13703 returned the verdict task 13703 is not claimed by repo-worker-code (the claim was superseded/released outside this lane between the verified checkpoint and the terminal verb; the backend itself answered — this is a verdict, not an outage). Per runbook §0b, the full outcome is recorded here durably:
No GitHub work was lost: the triage verdict note 6728667843 and this outcome note are on issue #6767, and the fix route (task 11460) is live in the queue. dezren39 commented on Nov 11, 2026
🤖 Agent note · code fix merged — issue stays open for the live canary proof (task 11460)
- PR: secrets-broker: per-secret age, partial-refresh install, age/source exposure (#6767) #8491 MERGED as
c676d1c41c07f293255b6ec430f0a7fc93d1f5b9.
- What landed: per-secret
fetched_at_unix in the broker cache; install_refresh installs per secret (successes land, a failed fetch keeps its secret's previous value and 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 per secret — deletions follow the authoritative list, a zero-success refresh installs nothing); GET /secret/<name> exposes fetched_at_unix / age_seconds / source; GET /health adds oldest_secret_age_seconds. The fail-whole tail that let one broken fetch block every rotation indefinitely is gone, so a rotation now lands within one TTL (default 900s), bounded and observable.
- Codex P2 (fixed before merge): per-fetch timestamps are captured at the fetch site and preserved on install — a value fetched before a rotation can no longer claim a
fetched_at after it; the install test pins t=190 vs install t=200.
- Tests:
cargo test -p fleet-queue --lib --features secrets-broker 59/59 on the laptop, incl. 3 new fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767 tests.
- Remaining before this issue closes (deploy-side, unchanged acceptance (b)/(d) live proof): ① deploy the rebuilt secrets-broker (laptop Nix switch), ② canary check: create a canary secret in BWS → read through the broker → rotate it in BWS → assert the broker serves the new value with a fresh
fetched_at_unix within one TTL, ③ then close this issue.
dezren39 commented on Nov 17, 2026
🤖 Agent note · triaged (inline triage — code fix merged; deploy + canary remainder routed to task 20007)
- Agent: queue worker (repo-worker-code), lane any-c
- Session / ID: task 18503
- Found via: queue claim (bulk-intake triage packet, 2026-11-16)
Triage verdict (fresh, 2026-11-17, via gh + fleet queue):
- Issue fleet(secrets-broker): serves stale secret value long after BWS rotation — read-through cache never invalidates #6767 is OPEN. Labels:
kind/bug, priority/normal, effort/m, app/fleet, design/fleet-brokers (plus a stale work/assigned). No hard-stop labels (held, user/owned, do-not-merge, do-not-auto-edit).
- The code fix is already merged: PR secrets-broker: per-secret age, partial-refresh install, age/source exposure (#6767) #8491 (merge commit c676d1c, task 11460) — per-secret
fetched_at_unix, per-secret install on refresh (the fleet(secrets-broker): a partial vault refresh silently evicts cached secrets — one failed bws get becomes a 404 and a 'successful' refresh #5504 fail-whole tail is gone), age/source exposed on GET /secret/<name> and GET /health. That satisfies the code side of the acceptance criteria.
- What remains is exactly what task 11460 recorded: ① deploy the rebuilt secrets-broker on the laptop, ② the live canary proof — create a dedicated canary secret in BWS, read through the broker, rotate it in BWS, assert the broker serves the new value with a fresh
fetched_at_unix within one TTL (900s) — ③ close this issue. No live queue task owned that remainder (verified across queued/claimed/parked/blocked this shift).
- Routing: that remainder is now a scoped follow-on packet, task 20007 (small_fix, 45 min): deploy + canary + closure, canary secret only — no production secret is rotated for the proof.
Task 18503 completes as triaged naming follow-on task 20007. Issue #6767 stays open for the canary proof. dezren39 commented on Nov 17, 2026
Agent note — task 20007: deploy verified live + canary rotation proof; closing #6767 (lane any-d, 2026-11-17)
Deploy (acceptance 1) — verified live, no re-switch needed. The rebuilt secrets-broker (PR #8491, merge c676d1c) is the live broker: secrets-broker.service is running the nix-store fleet binary, restarted 2026-11-17T09:10Z, and GET /health answers with the rebuild's new field (oldest_secret_age_seconds: 767 at check time, secrets: 205). GET /secret/<name> exposes the rebuild's per-secret fetched_at_unix / age_seconds / source (verified on an existing secret, metadata only). The deploy step of this task was therefore already in effect when claimed; this lane verified it rather than re-running a disruptive switch.
Canary rotation proof (acceptance 2 + d). Dedicated throwaway canary only — no production secret was touched. Values are identified by truncated SHA-256 (first 16 hex) only:
- Canary secret
canary.rotation-proof created in Bitwarden Secrets Manager (id e595e1ad-cc21-4542-a135-b50500a3b08e), value V1 hash 9f06926bd879e4c0.
- 2026-11-17T09:56:11Z — broker serves V1 on first read:
source=bitwarden-read-through, fetched_at_unix=1794909371, age_seconds=0. Broker secret count 205 → 206.
- 2026-11-17T09:56:32Z — canary rotated in BWS to V2, hash
7147280035bdee18. (At +9s the broker still served V1 from cache, age 30s — normal within-TTL behaviour.)
- 2026-11-17T09:56:45Z — broker refresh (
last_refresh_unix=1794909405, +13s after rotation) fetched V2.
- 2026-11-17T09:57:42Z — broker serves V2 from cache with
fetched_at_unix=1794909405, and fleet secrets get canary.rotation-proof hashes to exactly 7147280035bdee18 (V2). Rotation-to-fresh-serve: 13 seconds, far within one TTL (900s).
- The 2026-11-06 stale-token failure mode (acceptance d) does not reproduce on the canary path: the rotated value replaced the cached one at the first refresh after rotation.
The canary secret is deleted from BWS immediately after this proof, as designed (throwaway). Closing #6767 with this proof.
MetadataMetadataapp/fleetpkgs/fleet multicall binary + platform cratesdesign/fleet-brokersDesign: fleet-brokers - all issues of this effort carry iteffort/mMedium: expected under 1 day of workkind/bugSomething isn't working (prefixed form of the classic bug label)meta/enrichedIntake review done: acceptance criteria, links, and normalized labels addedpriority/normalOrdinary priority (the default)task/triageQueue packet kind: verify, reproduce, and route this item DevelopmentNo branches or pull requestsIssue actions
|