Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove insecure example from docs #29

Closed
coderdan opened this issue Dec 12, 2021 · 1 comment · Fixed by #36
Closed

Remove insecure example from docs #29

coderdan opened this issue Dec 12, 2021 · 1 comment · Fixed by #36

Comments

@coderdan
Copy link

The current docs include a usage example which suggests hashing the email field with SHA256 along with a fully encrypted (secure symmetric cipher) version of the field.

By including the SHA256 version of the data, the encryption is rendered virtually useless as the same data is now also stored in the data-base on a much weaker scheme. Storing sensitive data in this way is not secure due to the below reasons and should be removed from the docs:

  • SHA256 is a public algorithm (i.e. requires no key) so anyone can compute the hash of any email address. This would make brute force attacks to effectively decrypt email addresses encrypted in this way very simple
  • Deteministic encryption (where the same output ciphertext is generated for a give plaintext and key every time) is vulnerable to inference and chosen-plaintext attacks. Put simply, if an attacker learns the result of SHA256(foo@example.com) then they can use that knowledge to find any other records in the database that correlate with that email address

These weaknesses may be acceptable for a given application but I think the reader should be warned if you decide to include that example in the docs. And at the very least, SHA256 should be replaced by HMAC with a key known only to the application owner.

@danielberkompas
Copy link
Owner

Fixed in #36!

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 a pull request may close this issue.

2 participants