Menu ▾ ▴

#120 [Feature]: Overlapping (dual-key) secret rotation

open
nobody
None
2026-10-24
2026-10-16
Anonymous
No

Originally created by: bosd

For API keys and database credentials, rotating by replacing the single value causes downtime for consumers that have not yet picked up the new value.

Proposal

  • A secret can hold two active values (slot A and slot B). Rotation writes the new value to the inactive slot, marks it as current, and keeps the previous value valid for a configurable grace period, after which it is retired.
  • dopbase secret rotate <key> --grace 24h, with runtime reads returning the current value and an --include-previous option for verification tooling.
  • Audit events for rotate, promote and retire.
  • Optional later step: a rotation hook (command or webhook) that creates the new credential at the provider.

Out of scope for a first version: provider-specific rotators.

Related to the secret version history proposal in [#33]; the revision storage could be shared.

Related

Tickets: #119
Tickets: #122
Tickets: #126
Tickets: #33

Discussion

  • Anonymous

    Anonymous - 2026-10-23

    Originally posted by: thomijasir

    [#33] is adding a secret_versions table that keeps encrypted versions of each secret. Dual-key rotation could keep its previous slot there instead of adding separate storage.

     

    Related

    Tickets: #33

  • Anonymous

    Anonymous - 2026-10-23

    Originally posted by: bosd

    Agreed that the previous slot belongs in secret_versions once [#33] exists. [#122] stores it as nullable previous_* columns for now, with each slot keeping its own version and AAD, so moving it into a versions row later is a plain data migration that doesn't re-encrypt anything. The API (previousVersion / previousExpiresAt, rotate/promote) doesn't depend on where the slot is stored. I'd rather not design the versions table inside the rotation PR, so I'll leave a note on [#33] to fold the rotation slot in when it's implemented.

     

    Related

    Tickets: #122
    Tickets: #33

  • Anonymous

    Anonymous - 2026-10-24

    Originally posted by: dopbase

    Holding this for now. Before adding a grace period me and @thomijasir need to study how providers handle rotation on their side (AWS IAM, Stripe, database roles), since a grace window in dopbase doesn't revoke anything at the provider.

    In the meantime, secret rollback from [#33] covers recovery from a bad rotation, though not overlap. @bosd, thanks for [#122]. I'd like to revisit it on top of secret_versions once the model is clearer.

     

    Related

    Tickets: #122
    Tickets: #33

  • Anonymous

    Anonymous - 2026-10-24

    Originally posted by: bosd

    Makes sense, and agreed on the core point: a grace window in Dopbase only keeps the old value readable, it revokes nothing at the provider. In case it saves some research, how overlap works at the providers you named:

    • AWS IAM: a user can hold two access keys at once. Create the second, move consumers over, then deactivate and delete the first. Revocation is an explicit step at AWS.
    • Stripe: rolling a key can be immediate or scheduled, so the old key keeps working until an expiry Stripe enforces itself. Stripe recommends keeping that window short.
    • Database roles: alternate between two login roles (or two credentials) and switch consumers between them. PostgreSQL's VALID UNTIL sets an expiry on the database side, but only for password authentication.

    In each case the overlap is enforced at the provider. That suggests Dopbase's part is to know which credential is current, when the old one should be revoked, and to prompt or hook that revocation, rather than owning the grace period itself. That would also fit naturally on secret_versions.

    I'll mark [#122] as a draft so it stays available when you revisit this.

     

    Related

    Tickets: #122


Log in to post a comment.