Skip to content

Enforce complete, versioned master key rotation - #24

Open
pantharshit007 wants to merge 1 commit into
masterfrom
fix/versioned-master-key-rotation
Open

pantharshit007 wants to merge 1 commit into
masterfrom
fix/versioned-master-key-rotation

Conversation

@pantharshit007

Copy link
Copy Markdown
Owner

Master key rotation could accept an incomplete project list or changed project salts, leaving recovery data incompatible with the new key. Rotation now validates the current master key revision, exactly one update per owned project, unchanged salts, and the previous recovery ciphertext before atomically saving all rewraps and advancing the revision.

Settings reads a consistent rotation snapshot and re-verifies the current key before encryption. Empty rotations use the same mutation; direct master key writes are restricted to initial setup without projects. Project creation checks the revision used for encryption, closing the opposite race where a stale creation arrives after rotation. Legacy configurations start at revision zero.

Adds Convex mutation regression tests and a real crypto round trip covering recovery and variable decryption. Bumps the package to 0.0.19 and documents the concurrency constraints.

Validation:

  • bun test: 19 passing tests, including simultaneous rotations, creation race orderings, malformed/stale snapshots, unchanged data after rejection, and recovery after rotation.
  • bun run tsc: passed (adds the missing bun-types development dependency already referenced by tsconfig).
  • bun run build: passed.
  • ESLint and Prettier on changed code: passed.
  • bun run check: blocked by existing formatting issues in 51 repository files.

The new mutation arguments are required: stale clients fail safely and must refresh. No production deployment or authenticated browser session was used; backend tests run with convex-test.

Closes #19

@coderabbitai

coderabbitai Bot commented Oct 15, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Repository: pantharshit007/tijori/.coderabbit.yml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a6ea8a82-9269-4145-9790-952feb193dc4
  • 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

Comment @coderabbitai help to get the list of available commands.

@pantharshit007 pantharshit007 left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Independent sub-agent review of ce857b9: no actionable findings.

Reviewed the issue #19 acceptance criteria against transaction validation, initial setup restrictions, master-key and recovery-ciphertext write paths, frontend snapshot handling, and project-creation revision capture. The complete-project checks, unchanged salts, and revision guards cover stale rotations and both orderings of the creation/rotation race.

Validation: the reviewer independently ran bun test test/master-key-rotation.test.ts — 16 tests passed, 0 failed, 46 assertions.

Review scope: source inspection and local Convex tests; no deployed or authenticated browser validation. No inline comments were added because the review identified no concrete bugs.

This branch has not been deployed

No deployments
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.

Enforce complete, versioned master-key rotation without changing project salts

1 participant