[GH-ISSUE #77] security: migrate encryption key derivation from SHA-256 to PBKDF2 #107

Open
opened 2026-03-07 19:27:46 +03:00 by kerem · 0 comments
Owner

Originally created by @adminsyspro on GitHub (Mar 6, 2026).
Original GitHub issue: https://github.com/adminsyspro/proxcenter-ui/issues/77

Problem

The current encryption of secrets (Proxmox API tokens, SSH keys/passwords) uses a simple SHA-256 hash of APP_SECRET as the AES-256-GCM key. This is fast to brute-force if the database is compromised.

Expected

Use PBKDF2 or scrypt with a high iteration count to derive the encryption key from APP_SECRET, making brute-force attacks significantly harder.

Implementation notes

  • Transparent migration required: existing encrypted values must be re-encrypted on first startup after the update
  • Migration flow: decrypt with old SHA-256 key → re-encrypt with PBKDF2-derived key → store alongside a version marker
  • Add a key_version or prefix to encrypted fields to distinguish old vs new format
  • Must handle rollback scenario (keep old key derivation as fallback for reading)
  • Affects: lib/encryption.ts (frontend), and any backend code that decrypts tokens

Priority

Critical — if the SQLite database is leaked, secrets are vulnerable to offline brute-force.

Originally created by @adminsyspro on GitHub (Mar 6, 2026). Original GitHub issue: https://github.com/adminsyspro/proxcenter-ui/issues/77 ## Problem The current encryption of secrets (Proxmox API tokens, SSH keys/passwords) uses a simple SHA-256 hash of `APP_SECRET` as the AES-256-GCM key. This is fast to brute-force if the database is compromised. ## Expected Use PBKDF2 or scrypt with a high iteration count to derive the encryption key from `APP_SECRET`, making brute-force attacks significantly harder. ## Implementation notes - **Transparent migration required**: existing encrypted values must be re-encrypted on first startup after the update - Migration flow: decrypt with old SHA-256 key → re-encrypt with PBKDF2-derived key → store alongside a version marker - Add a `key_version` or prefix to encrypted fields to distinguish old vs new format - Must handle rollback scenario (keep old key derivation as fallback for reading) - Affects: `lib/encryption.ts` (frontend), and any backend code that decrypts tokens ## Priority Critical — if the SQLite database is leaked, secrets are vulnerable to offline brute-force.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/proxcenter-ui#107
No description provided.