OdeToCode IC Logo

Separating Concerns with Key Vault

Tuesday, April 3, 2018

In an earlier post we looked at decrypting an asymmetric key using Key Vault. After decryption, we could use the key to decrypt other secrets from Key Vault, like encrypted connection strings.

This raises the question – do we need to encrypt our secrets in Key Vault? If we still need to encrypt our secrets, what value does Key Vault provide?

The short answers are maybe, and a lot.

Encrypting Secrets

It’s not a requirement to encrypt secrets before storing the secrets into key vault, but for those of use who work in highly regulated industries, it is difficult to justify to an auditor why we are not encrypting all sensitive pieces of information.

Keep in mind that Key Vault already encrypts our secrets at rest and will only use secure communication protocols, so secrets are safe on the network, too. The only benefit of us encrypting the secret before giving the secret to key vault is to keep the plain text from appearing in the portal or as the output of a script.

For applications running outside of “encrypt all secrets no matter the cost” mandates, the built-in safety mechanisms of Key Vault are good enough if you follow the right practices.

Separation of Concerns

Key Vault allows us to separate the roles of key managers, key consumers, and developers. The separation is important in the production data environment.

Key Vault Separation of Concerns

The security team is the team who can create key vaults for production and create keys and secrets inside a vault. When a system needs access to a given database, the security team can create a login for the application, then add the connection string as a secret in the vault. The team can then give developers a URL that leads to the secret.

Developers never need to read or see the secret. Developers only need to place the secret URL in a location where the running application can retrieve the URL as a parameter. The location could be a configuration file, or developers could place the URL into an ARM template to update application settings during a deployment.

The security team grants the application read access to secrets in the Key Vault. At run time, an application can read a connection string from the vault and connect to a database.

Finally, an auditor can review access logs and make sure the security team is rotating keys and secrets on a regular basis.

Rolling Secrets

Best security practices require periodic changes to passwords and access keys. Azure services that rely on access keys enable this scenario by providing two access keys – a primary and secondary. Azure Key vault also helps with this scenario by versioning all secrets in the vault and allowing access to multiple versions (this month's key, and last month's key, for example). We can also roll connection strings.

Take the following scenario as an example.

1. Security team creates a login for an application in Azure SQL. They place a connection string for this login into Key Vault. We'll call this connection string secret C1.

2. Devops deploys application with URL to the C1 secret.

3. After 30 days, security team creates a new login for application. They place the connection string in KeyVault. This is C2.

4. At some point in the next 30 days, devops will deploy the application and update the URL to point to C2.

5. After those 30 days, security team removes the login associated with C1.

6. GOTO 1

Summary

Key Vault is an important piece of infrastructure for applications managing sensitive data. Keeping all the secrets and keys for a system in Azure Key Vault not only helps you protect those secrets, but also gives you a place to inventory and audit your secrets.


Comments
Gravatar Steve Collins Wednesday, April 4, 2018
Hey Scott, I've recently written a four-part blog about taking a SOLID approach to configuration in ASP.Net Core, culminating in the latest which I posted today at https://stevetalkscode.co.uk/configuration-bridging-part-4 which discusses encrypting configuration settings and injecting a decryption algorithm to decrypt some settings before being used by the controllers. Whilst the focus is on appsettings.json as the source of the configuration, it is equally applicable to Key Vault as well. Would be interested in your thoughts. Thanks Steve
Gravatar scott Thursday, April 5, 2018
@Steve: Great post. For storing secrets outside of source, did you consider the user secrets feature of core?
Gravatar Andrew Tuesday, April 24, 2018
Hi Scott, do you think the service limits on Key Vault make using in certain applications prohibitive? I think it's 50,000 ops per month and a limit of 200 per minute. I could see a large enterprise or SaaS app eating through this pretty quick if using to verify tokens or something like that. Thanks!
Gravatar scott Tuesday, April 24, 2018
@Andrew: Yes, the limits are something to be careful about for some applications. I guess HSM modules have some throughput limitations.
Comments are closed.