Repository navigation
Encrypt stored data with the current key version and add a re-encrypt task - #15199
Conversation
…on task The encrypt filter and storage uploads use _APP_OPENSSL_KEY_CURRENT and record the version. bin/encryption re-encrypts stored values left under an older version. It is a dry run unless --commit=true and resumes with --after. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review complete. 🟡 3 medium 💬 Inline comments (3)
🧹 Nitpicks (1) — 🟢 1 low
This PR introduces key-version-aware encryption:
Reviewed commit: b44115c |
🟢 Tier S · Ready to mergeThe pull request switches encrypted database values and eligible storage uploads to the configured current key version while retaining version-based decryption. It adds a dry-run/commit task to re-encrypt older database values across platform, project, and user-defined collections, with batching, resume support, and preserved update dates. Latest changes: The latest commit counts documents in commit mode only when the transaction successfully re-encrypts them, while retaining candidate counts for dry runs.
📂 Walkthrough · 8
Reviewed the commits since |
Security rulesWARNING (2 new) — review signal only; does not fail the job.
|
Reading and writing in one transaction with the row locked keeps a client update made in between from being overwritten with the value read. Co-Authored-By: Claude Opus 5.5 <[email protected]>
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
The findings that requested changes are resolved. See the summary comment for what is still open.
There was a problem hiding this comment.
Adds version-aware OpenSSL key rotation via a new EncryptionKey flow, an encryption CLI re-encryption task, and wiring across the Dockerfile, variables, database filters, and file upload encryption.
Key findings
- 🟡 Re-encryption task rewrites failed decryptions as garbage — Encryption.php:159
- 🟡
isStale()matches any JSON containing aversionkey — Encryption.php:189 - 🟡 Encrypt paths skip empty-current-key validation — filters.php:285
…does not decrypt The encrypt filter and storage uploads throw when the current version has no key, instead of storing false. The encryption task treats only full envelopes as ciphertext, and skips a value whose recorded key is gone instead of rewriting it as an encryption of nothing. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
What
Stacked on #15198 (merge that first). After this PR, stored data is encrypted with the current key version, and a task re-encrypts data left under older versions. That lets V1 eventually be removed entirely instead of staying configured for decryption.
encryptfilter writes with_APP_OPENSSL_KEY_CURRENTand stores the version. Decryption still picks the key by the stored version.openSSLVersion.bin/encryptionre-encrypts every value using theencryptfilter that is stored under another version:_APP_REGION, and user-database columns created withencrypt: true.--commit=true, reads in batches (--batch, default 100), and resumes with--after=<projectId>.$updatedAt.Runbook (after #15198's step 2, current=2)
Per region:
docker compose exec appwrite encryption: dry run that prints counts per project and collection.docker compose exec appwrite encryption --commit=true: writes. If it stops, rerun with--after=<last project ID reported done>.Found 0 documents.Storage files already encrypted on disk with
openSSLVersion=1are not rewritten. V1 must stay configured until those are re-encrypted too, which is a separate follow-up.Tests
tests/unit/Database/EncryptFilterTest.phpchecks that:Both tests fail against the original code, which always writes version
1. Not covered: the task against a real database.🤖 Generated with Claude Code