Skip to content

docs: define env key rotation, recovery, and lost-key handling flows - #28

Closed
roodboi wants to merge 2 commits into
mainfrom
codex/define-env-key-rotation-and-recovery-flows
Closed

docs: define env key rotation, recovery, and lost-key handling flows#28
roodboi wants to merge 2 commits into
mainfrom
codex/define-env-key-rotation-and-recovery-flows

Conversation

@roodboi

@roodboi roodboi commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Motivation

  • Make the portable env/key lifecycle explicit so operators can choose the correct action (value rotation, share rotation, or project-key rotation) and avoid accidental secret churn.
  • Define concrete recovery and lost-key handling rules so portable env custody cannot be made the sole authority without an explicit recovery path.
  • Provide clear UX and audit expectations for recovery packages, forced overrides, and when to treat an event as lost-access vs compromised-key.

Description

  • Add a new "Planned portable key lifecycle flows" section to docs/env.md that documents value rotation, share rotation, project-key rotation, recovery rules, lost-key scenarios, and CLI/desktop UX expectations.
  • Extend docs/plans/2026-03-13-env-portability-and-secret-management-design.md with an operator decision matrix, detailed lost-key vs compromised-key handling flows, and minimum metadata requirements for encrypted recovery packages.
  • Update docs/plans/2026-03-13-env-portability-and-secret-management-plan.md to require tests and CLI/broker command work to distinguish lost-key recovery/share reissue from compromised-key rotation.
  • Opened a follow-up ticket T-YZP66GA9P5 to track the implementation work (CLI/broker commands, storage, and tests) required to enforce the documented guardrails.

Testing

  • Ran bun x ultracite check which completed but reported pre-existing repository complexity warnings unrelated to these documentation-only changes.
  • No code unit tests were necessary for the docs-only updates; implementation work will add focused automated tests per the updated plan.

Codex Task

@changeset-bot

changeset-bot Bot commented Mar 23, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 6add36f

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@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: c345c9fb0e

ℹ️ 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".

| Situation | Correct action | Why |
| --- | --- | --- |
| The underlying secret changed | Value rotation | The trust anchor can stay the same while publishing a new immutable value snapshot |
| A teammate left or a new teammate joined | Share rotation | Membership changed, but the current project key may still be trusted |

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Treat teammate offboarding as requiring secret rotation

In the offboarding case where a teammate has already applied the current bundle, Share rotation is not a sufficient “correct action”: the sharing rules in docs/plans/2026-03-13-env-portability-and-secret-management-design.md:246-249 explicitly say revocation only blocks fresh unwraps and does not remove old local materializations. As written, this matrix will push the CLI/broker toward a flow that leaves the departed user with still-valid DB/API credentials until operators also rotate the affected secret values.

Useful? React with 👍 / 👎.


1. rotate the project key
2. re-wrap the latest active bundle keys to the new project key
3. regenerate all active recipient and recovery shares

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Regenerate recovery packages during project-key rotation

This compromise-handling flow rotates the project key and recreates shares, but it never reissues encrypted recovery packages. That breaks the case where a recovery package is the only remaining recovery path, because the new section later ties packages to a specific project key identifier in docs/plans/2026-03-13-env-portability-and-secret-management-design.md:367-376; after rotation, the old package can no longer unwrap the new key even though the guardrails still count a package as valid recovery. The rotation flow needs to explicitly regenerate or invalidate recovery packages to avoid silently stranding the project.

Useful? React with 👍 / 👎.

Expected flow:

1. rotate the project key
2. re-wrap the latest active bundle keys to the new project key

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Re-wrap every retained bundle version after key compromise

Re-wrapping only the “latest active bundle keys” is not enough for a compromised-project-key scenario, because the design elsewhere keeps bundle versions immutable and fetchable by version (docs/plans/2026-03-06-remote-encrypted-project-env-portability-plan.md:158-160). Any older bundle that remains wrapped by the superseded project key is still decryptable by the attacker, so compromise rotation would leave historical secret snapshots exposed and still applicable. This flow needs to cover all retained bundle versions or explicitly retire old history.

Useful? React with 👍 / 👎.

@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: 6add36f3d2

ℹ️ 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".

Comment on lines +327 to +330
1. authenticate as an authorized owner or designated recovery recipient
2. unwrap the current project key through the remaining recovery path
3. re-apply the latest active portable bundle to new local compatibility storage
4. reissue recipient shares for replacement devices as needed

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Require owner/admin approval before recovery holders re-share

When the surviving authority is a designated recovery recipient, this Case 1 flow lets that backup-only identity complete step 4 and mint fresh recipient shares. That effectively promotes recovery holders into share administrators, even though manual sharing is described as the trust boundary earlier in this doc (docs/plans/2026-03-13-env-portability-and-secret-management-design.md:219-251). In a lost-laptop recovery, a designated recovery recipient could re-grant access to any user or device unless the reissue step is limited to owners/admins or requires explicit re-approval.

Useful? React with 👍 / 👎.

Comment on lines +338 to +340
1. verify that the recipient is still entitled to access
2. mint a fresh wrapped project-key share for that recipient
3. preserve existing bundle versions and project-key lineage

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Bind share repair to recipient key material

Case 2 assumes we can "mint a fresh wrapped project-key share for that recipient", but the only key-share schema defined here records recipient.id plus wrapMethod/wrappedProjectKey and nothing about which public key or device the share targets (docs/plans/2026-03-13-env-portability-and-secret-management-design.md:223-240). In the normal lost-key scenario where the user creates a replacement keypair, the broker has no stable key identity to encrypt to or supersede, so this recovery flow cannot be implemented reliably without adding recipient key metadata.

Useful? React with 👍 / 👎.

@roodboi roodboi closed this Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant