Active
Project:
Drupal core
Version:
main
Component:
base system
Priority:
Normal
Category:
Plan
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
19 Jan 2021 at 16:50 UTC
Updated:
24 Feb 2026 at 20:51 UTC
Jump to comment: Most recent
Drupal doesn't encourage best practice when storing secrets. For example:
Other frameworks have secret management baked into the core capabilities. For example, https://symfony.com/blog/new-in-symfony-4-4-encrypted-secrets-management
There is work in contrib, notably https://www.drupal.org/project/key
We could follow Symfony's lead and leverage the fact that PHP since 7.2 ships with lib-sodium support so generating a public private key pair and encrypting/decrypting information no longer requires PHP extensions.
The plan could be:
Comments
Comment #2
alexpottI'm pretty sure there are existing issues around reading config from environment variables. Going to flesh out the plan and create / or find matching existing tasks.
Comment #3
larowlanShould this go in the ideas queue first for product manager sign-off
Pretty sure there's existing issues in that queue for encryption
Plus one from me
Comment #5
damienmckennaI couldn't find one myself, though that doesn't mean there isn't one amongst the 22,000 open core issues.
This would be useful for allowing people to encrypt API passwords, security tokens, etc.
(keywords to make it easier to find via the search)
Comment #9
mcdruid commentedSorry to add little more than a +1 but this is definitely a problem; I've seen a variety of secrets of varying degrees of sensitivity end up in public repos as a result of being stored in config that ends up being exported and committed.
API keys for things like the recaptcha module are a frequent flyer; linking an issue about that which was closed some time ago but remains valid IMHO.
Comment #11
damienmckennaencrypted storage variables data API.
(adding more keywords to make this more findable)
Comment #12
solideogloria commentedI agree that this would be incredibly useful. Accidently committing keys is a concern, and developers with less experience are more likely to assume that the default is secure, when it's not.
Comment #13
pwolanin commentedThere are interesting ideas from symfony about what to support. Their style of key rotation doesn't seem great for us where values are likely in the database an prod rotation happens only on the live site.
Comment #14
prudloff commentedComment #15
mxr576FYI, we are working on providing an easy to use and as secure as possible within the given constraints solution for Drupal CMS here. We are waiting for a review from the Drupal Security Team before we would tag a release. Symfony's Vault feature was an inspiration when we made a vote on Sodium sealed box design, but of course, we had Drupalize a couple of things.
https://www.drupal.org/project/easy_encryption
https://project.pages.drupalcode.org/easy_encryption
Comment #16
ghost of drupal pastThis would be great but I have a hard time imagining how would this work well without lifting Key wholesale from contrib to core.
Now, of course, an argument can be made that in 2026 any self respecting CMS should have that functionality... but I am not making it, I am just raising the potential idea.
Comment #18
mxr576Two months passed and since then Easy Encryption has changed and improved a lot.
Easy Encryption uses the Key module under the hood (the default Sodium sealed box encryptor resolves its key material through it), and it also provides integration for storing encrypted data as Key entities. Outside of those two touchpoints, though, the module stands on its own. It has grown into a standalone, pluggable encryption abstraction for Drupal that can work independently of the Key module entirely.
It introduces its own domain for
* Encryption: https://project.pages.drupalcode.org/easy_encryption/architecture/domain...
* Key Management: https://project.pages.drupalcode.org/easy_encryption/architecture/domain...
* even Key Transfer (was a Drupal CMS need): https://project.pages.drupalcode.org/easy_encryption/architecture/domain...
These foundations could be good examples for an Encryption API that could be also added to Drupal core, with or without leveraging Sodium Sealed box design as default encryption, which just works :tm:.
If this idea makes sense, I can update the IS with ideas on how similar low level APIs could provide the secret storage foundations in Drupal core.