47ng / 47ng/prisma-field-encryption

Getting ciphertext back from the database

Abierto
#8 23 comentarios 0 reacciones 0 asignados Ver en GitHub
knowledge-base
Lenguaje dominante
TypeScript
Estrellas
306
Forks
40
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

Guía de contribución

Abrir la guía de contribución

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
typescript
Área
databases, security
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.