0

Many of my (confidential) apps are talking to each other via the client credential flow.
They request a token from the Azure Identity platform and use this token to authenticate against another app.
A while ago I used client secrets to do so, but later I read that this is not recommended for production environments.
For this reason I changed to self-signed certificates that are valid a longer time.
Those certificates are generated by myself with Azure Keyvault. However, also this is not recommended.
Microsoft states that that in production environments you should use certificates that are signed by an official CA.

If I now use Lets encrypt, this will expire all three months what is also not such a nice solution.

My questions:

  • Why is the client secret not recommended in production environments?
  • Why is the self-signed certificate a problem? I do understand this in matters of HTTPS, but where is the security breach if its used for client credential flow? In my case I am the owner of the app and the app registration.
  • Do I need to buy a certificate that is one-year valid to do it "the right way"?

Do you have any source of best practices here?

David Mason
  • 915
  • 1
  • 9
  • 27

1 Answers1

0

• Client secrets include application credentials, SSH keys, API keys, database passwords, encryption keys, connection strings and so on to connect various resources and access the data or functionality for achieving the designated purpose of that application. Thus, if these are breached, they can put your application at great risk of compromise. Also, the client secret generated in Azure AD and used in APIs for connecting to Azure AD for authentication and authorization purpose is listed and mentioned in unencrypted form in the API code itself. Though, we have an option to store that secret in a key vault and refer to that secret through either managed identity or RBAC assignments, but their credentials too can fall in wrong hands and let the application be vulnerable if the managed identity is a user assigned or even if then access scope of the secret is not well defined according to the required specific need. Thus, client secret is not recommended to be used in a production API.

• In client credentials flow, applications are directly granted permissions by an administrator to perform a certain action regarding the API to be called through it via certificate or federated credentials. Thus, when using a self-signed certificate in client credentials grant scenario, the administrator has granted the daemon app requesting access to other API all the required privileges regarding accessibility of code, API, permissions, data, etc. which can result in poor validation and misuse as the it is very easy to generate a certificate’s key pair without reasonable entropy. Also, protecting the private key of the key pair appropriately to its use and strong validation of the same is not promised in a self-signed certificate due to which it is not recommended in client credentials flow.

• For best practices regarding web app service deployment, please refer to the documentation link below: -

https://learn.microsoft.com/en-us/azure/app-service/security-recommendations#general

It explains the best security recommendations for deploying a web app service.

Kartik Bhiwapurkar
  • 4,550
  • 2
  • 4
  • 9
  • "but their credentials too can fall in wrong hands and let the application be vulnerable if the managed identity is a user assigned or even if then access scope of the secret is not well defined according to the required specific need. Thus, client secret is not recommended to be used in a production API." Can you specify this part of the answer more? Why is a certificate then an advantage? It could also "fall into the wrong hands"? – David Mason Feb 24 '22 at 15:51
  • A certificate is an advantage because it has a public and private key assigned with it which can be verified by that entity only owns the private key through reversible encryption mechanism and that certificate can be stored securely in key vault and utilized by the applications for cross authentication purposes. Also, even if it falls in wrong hands, the whole certificate cipher mechanism is bound to the device key, user ID and other aspects of the utilising API. – Kartik Bhiwapurkar Feb 27 '22 at 14:19