Skip to content

Comments

feat(vault): encryption-at-rest with XChaCha20-Poly1305#81

Open
penso wants to merge 3 commits intomainfrom
aes-256-gcm
Open

feat(vault): encryption-at-rest with XChaCha20-Poly1305#81
penso wants to merge 3 commits intomainfrom
aes-256-gcm

Conversation

@penso
Copy link
Collaborator

@penso penso commented Feb 10, 2026

Summary

  • New moltis-vault crate: XChaCha20-Poly1305 encryption-at-rest with trait-based Cipher abstraction, Argon2id KDF, recovery key support, and 38 unit tests
  • Gateway integration: vault feature flag (default-enabled), vault_guard middleware (423 Locked), vault API routes, CredentialStore env var encryption/decryption, GonData vault_status
  • Password lifecycle: vault initializes on setup, unseals on login, re-wraps DEK on password change
  • Plaintext migration: env var rows encrypted on first vault unseal
  • Plans: plans/encryption-at-rest-vault.md and plans/proxy-credential-injection.md

Validation

Completed

  • cargo +nightly fmt --all --check — clean
  • cargo +nightly clippy --workspace --all-targets — 0 warnings
  • cargo test -p moltis-vault — 38 tests pass
  • cargo test -p moltis-gateway — 33 tests pass (27 auth + 6 chat)
  • cargo test --workspace — all pass, 0 failures
  • taplo fmt — TOML formatted
  • cargo fetch --locked — lockfile in sync

Remaining

  • KeyStore/TokenStore file encryption (sync/async boundary — follow-up)
  • Frontend vault unlock page
  • Frontend setup flow recovery key modal
  • CHANGELOG.md / README.md updates

Manual QA

Not yet performed — requires frontend work (unlock page) to test the full user flow. Backend-only verification done via test suite.

🤖 Generated with Claude Code

New `moltis-vault` crate providing encryption-at-rest for sensitive data.
Password-derived KEK wraps a random DEK via Argon2id. Trait-based Cipher
abstraction allows swapping backends. Recovery key generated at vault
creation.

Gateway integration:
- Feature flag `vault` (default-enabled)
- vault_guard middleware returns 423 Locked when sealed
- Vault API routes: status, unlock, recovery
- Setup handler initializes vault and returns recovery key
- Login handler unseals vault and migrates plaintext env vars
- Change password re-wraps vault DEK
- CredentialStore encrypts/decrypts env variable values
- GonData exposes vault_status to frontend

Plans written for vault architecture and proxy credential injection
(TLS MITM for runtime secret protection).
@codspeed-hq
Copy link
Contributor

codspeed-hq bot commented Feb 10, 2026

Merging this PR will improve performance by ×2.1

⚡ 1 improved benchmark
✅ 33 untouched benchmarks
⏩ 1 skipped benchmark1

Performance Changes

Benchmark BASE HEAD Efficiency
session_store_list[10] 39.4 µs 18.5 µs ×2.1

Comparing aes-256-gcm (6a6c9c7) with main (5783114)

Open in CodSpeed

Footnotes

  1. 1 benchmark was skipped, so the baseline result was used instead. If it was deleted from the codebase, click here and archive it to remove it from the performance reports.

@codecov
Copy link

codecov bot commented Feb 10, 2026

Resolve conflicts from main merge:
- auth_routes: keep vault unseal on login + adopt session_response headers
  param and localhost cookie domain tests from main
- server: adopt add_feature_routes rename (middleware moved to router-level
  auth_gate), keep vault_guard as separate router-level layer
- server GonData: keep vault_status field alongside new sandbox and routes
  fields
- Rename env_variables_encrypted migration (20260210100000 → 20260210200000)
  to avoid timestamp collision with sessions' session_version migration
The vault_guard middleware was returning 423 Locked for all API routes
when the vault was uninitialized (no password set yet). Now it only
blocks when the vault is sealed (initialized but not unlocked), letting
fresh installations work normally.
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