Skip to content

v0.2.0

Release Date: 2026-10-25

Highlights

  • The rollback check can no longer be switched off from the keys directory. The highest keyring generation a host has seen is now authenticated under the root key, so an older keyring cannot be put back by editing or deleting the state file beside it.
  • A rollback margin is always kept. A policy must retain at least the active key version and the previous one.
  • Two breaking changes. The first open after upgrading needs AcceptRollback once, and RetainVersions below 2 is rejected. See Upgrading.

Status

keyforge v0.2.0 has not been externally audited and is not yet recommended for production use. The envelope format and the keyring file format are unchanged from v0.1.0. See the threat model for what it defends and where it stops.

Security fixes

Authenticated rollback high-water mark

The local provider keeps the highest keyring generation it has seen in a state file beside the keyring (<keyring>.backup, keyring.kf.backup under embedded). Before this release that file was plain JSON, and a missing file was read as "nothing seen". Anyone able to write the keys directory could put back an older, still validly sealed keyring and delete or edit the state file, and Open accepted the older keyring without AcceptRollback, bringing back key versions that had been destroyed or undoing a rotation.

The state file is now authenticated with HMAC-SHA-256 under a key derived from the root key with HKDF, and bound to the keyring's file name. Open refuses:

Condition Error
A state file that does not authenticate local.ErrCorruptBackupState
No state file beside a keyring past generation 1 local.ErrBackupStateMissing
A state file in the previous, unauthenticated format local.ErrUnauthenticatedBackupState

Generation 1 without a state file is still accepted, since a crash during Create leaves exactly that. Each refusal can be accepted with AcceptRollback, which rewrites the state authenticated and keeps any existing high-water mark and backup acknowledgement. Root key rotation authenticates the state under both the old and the new root key before replacing the keyring, so a crash on either side leaves state that the surviving keyring's root key opens.

The check still cannot tell an older keyring restored together with its own older state file from the real thing; keep the keys directory writable only by the service.

Retained-versions floor of 2

Policy validation accepted RetainVersions: 1, which let a deployment retire the previous key version as soon as a rotation completed and lose the rollback margin. Policy.Validate and Set.Validate, and so rotate.New, now reject a value below 2 in the default and in every per-purpose override. The active version and the previous one are always kept, and only N-2 and older can be retired. A compromised version is still not counted by the floor and can be retired and destroyed at once.

Upgrading

1. Open each existing keyring once with AcceptRollback

The first Open of a keyring written by v0.1.0 fails with ErrUnauthenticatedBackupState. For each keyring:

  1. Stop the process.
  2. Confirm the keyring on disk is the one you expect:

    keyforge keyring inspect
    
  3. Open it once with AcceptRollback: true:

    sys, err := embedded.Open(ctx, embedded.Options{
        Dir:            "/var/lib/myapp/keyforge",
        Root:           local.FileSource("/etc/keyforge/root.key"),
        AcceptRollback: true, // once, for the upgrade
        Purposes:       purposes,
    })
    

    With the local provider directly, set AcceptRollback: true in local.Options.

  4. Remove AcceptRollback again and restart. Leaving it set accepts a rolled back keyring on every open.

The existing high-water mark and backup acknowledgement are kept; the state file is rewritten in the authenticated format.

The same one-time step is needed when a keyring past generation 1 is opened without its state file, for example after moving it to a new host (ErrBackupStateMissing).

2. Keep at least two versions

If any policy sets RetainVersions to 1, rotate.New and policy validation now return an error. Set it to 2 or more, or leave it zero to inherit the default of 2, in the default policy and in every per-purpose override:

policy.Policy{
    RetainVersions: 2, // or 0 to inherit the default
}

A deployment that relied on retiring the previous version straight after a rotation now retires it one rotation later.

3. Update the module

go get github.com/plexusone/[email protected]
go install github.com/plexusone/keyforge/cmd/[email protected]

Requires Go 1.26.

Documentation

  • Operations describes the authenticated backup state file, the new errors and the upgrade step, and states the retained-versions floor.
  • The threat model covers the authenticated high-water mark and its remaining limit.

Known limitations

The limitations listed for v0.1.0 still apply. The complete list is in the threat model.