47ng / 47ng/prisma-field-encryption
Getting ciphertext back from the database
- Lingua principale
- TypeScript
- Stelle
- 306
- Fork
- 40
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
This issue somehow got turned into a thread about ciphertext not being decrypted and returned as-is from the database.
Such issues usually indicate:
1. That the setup is correct (encryption works, which means fields are correctly interpreted, and the encryption key is supplied correctly)
2. That there is something wrong with the decryption process.
Decryption will throw an error when in strict mode (using `/// @encrypted?mode=strict`), but will log a warning to the console in other modes. This could be the sign that you are missing the right key to decrypt data.
If there are no errors, it usually means that the ciphertext has been corrupted somehow, and failed to be detected by the middleware (so is passed through as any other data). Make sure your field maximum length is high enough to contain the largest expected ciphertext, which is larger than the clear-text. [Calculator available here](https://cloak.47ng.com/ciphertext-length-calculator).
---
Original issue content:
Adding a global strict decryption mode that throws errors when decryption fails (missing key) should help avoid building layers of encryption in migrations.
Use-case:
1. The decryption key is missing, encrypted data is returned in ciphertext (A)
3. The data migration re-encrypts ciphertext A with encryption key, producing ciphertext B
4. Decryption of re-encrypted records yield ciphertext A
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
The issue describes a decryption failure scenario where ciphertext is returned from the database instead of plaintext, potentially leading to re-encryption of ciphertext. Examine the middleware decryption logic, particularly the handling of strict mode versus other modes. Look for where decryption errors are caught and whether ciphertext is passed through. Check the field length validation and the ciphertext length calculator. Understanding the encryption/decryption flow and the Prisma middleware is essential.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- databases, security
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100