Skip to main content

Common Misconfiguration

Exposed Azure service principal credentials and storage keys can compromise your entire Azure subscription.

Vulnerable Example

Secure Example

Detection Patterns

  • Azure Client Secret: [A-Za-z0-9~._-]{30,}
  • Storage Account Key: [A-Za-z0-9+/]{86}==
  • CosmosDB Key: [A-Za-z0-9+/]{86}==
  • Connection String (Storage): DefaultEndpointsProtocol=https;AccountName=[a-zA-Z0-9]+;AccountKey=[A-Za-z0-9+/]{86}==

Prevention Best Practices

  1. Use Managed Identity: Always prefer Managed Identities for resources like VMs, App Services, and Functions.
  2. Use Azure Key Vault: Store all secrets, keys, and connection strings in Azure Key Vault.
  3. Use App Configuration: Store non-sensitive configuration settings in Azure App Configuration.
  4. Implement RBAC: Use Role-Based Access Control (RBAC) to grant least-privilege access to Key Vault and other resources.
  5. Use Azure Policy: Enforce security standards, such as preventing the creation of public storage accounts.
  6. Rotate Secrets: Use Key Vault’s automated rotation features for secrets and keys.