Background information
This was originally reported as a private security issue, but has been approved for handling in the public queue by the Drupal Security Team.
- security.drupal.org private issue: https://git.drupalcode.org/security/185002-field_encrypt-security/-/work...
(included for reference. Please do not report access denied as an error.)
Problem/Motivation
We have a website with a list field that is encrypted. The available options for this field are public but the association between a user and the selected value is sensitive data. We noticed that the encrypted value varies based on the length of the selected value. This means that if an attacker can get a dump of the database, they can deduce the selected values for this field without having to break the encryption.
Steps to reproduce
1. Enable the module
2. Create a bundle with a list field with two allowed values (_short_ and _loooooooong_ for example) and enable encryption on this field
3. Create some nodes in this bundle
4. Run this SQL query:
SELECT nid, LENGTH(encrypted_field_storage__value) FROM `node_field_data`;
The short value is always encrypted as a 396 characters string and the long value has a 416 characters string. (I tested with AES.)
Proposed resolution
I suppose a solution could be to pad the encrypted value so it has always the same length.
Remaining tasks
User interface changes
API changes
Data model changes
Issue fork field_encrypt-3594908
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
ptmkenny commentedThank you for this report.
I was able to reproduce the issue as described. My view is that this is a configuration issue that can be handled in the docs.
Rationale/Evidence
How to Fix This
I would suggest improving the documentation, noting specifically:
Comment #4
ptmkenny commentedComment #5
ptmkenny commentedPlease let me know what you think of the README text and I'll add it to the module page as well.