Skip to content

secrets-broker: per-secret age, partial-refresh install, age/source exposure (#6767) - #8491

Merged
dezren39 merged 2 commits into
mainfrom
queue/11460-6767-secrets-broker-age
Nov 11, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/11460-6767-secrets-broker-age

Conversation

@dezren39

@dezren39 dezren39 commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

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 get failed, 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 rotated turso.muse-mirror-rw-token's old value at +20s and still at +10 min. Cache hits were never re-checked, and GET /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)

  • Per-secret age — cache entries are now {value, fetched_at_unix}.
  • Partial-refresh install — new 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.
  • Age/source exposure — GET /secret/<name> now returns fetched_at_unix, age_seconds, and source (cache | bitwarden-read-through); GET /health adds oldest_secret_age_seconds. Response additions are backward-compatible for existing clients (fleet secrets get, queue broker) which read value only.

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:

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_unix within one TTL. The unit tests pin the mechanism; the canary run is the live proof.

🤖 repo-worker-code lane code-y, task 11460

…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.
@dezren39
dezren39 requested a review from a team as a code owner November 11, 2026 03:22
@coderabbitai

coderabbitai Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You'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.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a172abb7-c5a2-45c4-b066-9431187875e0
Commits

Reviewing files that changed from the base of the PR and between 69b339e and 7c9c2b5.

Files selected for processing: 1

  • pkgs/fleet/crates/fleet-queue/src/secrets_broker.rs
Pre-merge checks: Passed 1 · Inconclusive 1

Failed Failed checks: 1 inconclusive

Check name Status Explanation Resolution
Title check Pending This assessment has not completed. The check will be retried on the next pre-merge check run.
Passed Passed checks: 1 passed

Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-11T03:28:02.160704Z 7c9c2b5 New commits
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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()) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
@dezren39
dezren39 merged commit c676d1c into main Nov 11, 2026
1 of 7 checks passed
@dezren39
dezren39 deleted the queue/11460-6767-secrets-broker-age branch November 11, 2026 03: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