Azure Credential & Secret Detection
Azure credentials come in many formats — client secrets, storage account keys, SAS tokens, and connection strings. Azure's enterprise adoption means leaked Azure credentials often grant access to Active Directory, enabling lateral movement across the entire organization.
Azure Credential Landscape
Azure uses multiple credential types: Azure AD client secrets (app registration passwords), storage account access keys (base64-encoded 88-char strings), SAS tokens (query string parameters with sig= parameter), connection strings for Azure SQL, Cosmos DB, Service Bus, and Event Hubs, and managed identity tokens. Each requires specific detection patterns.
Enterprise Impact
Unlike AWS/GCP where leaked keys typically grant limited service access, leaked Azure AD credentials can provide access to the organization's entire directory — user accounts, groups, applications, and inter-tenant relationships. A compromised Azure AD app registration with Mail.Read permissions exposes every user's email.
Precogs AI Azure Detection
Precogs AI detects Azure credentials in all formats: client secrets (40-char alphanumeric), storage keys (base64 with == suffix), SAS tokens (sv= and sig= parameters), connection strings for all Azure services, managed identity endpoints, and certificate-based authentication credentials embedded in code and config files.
Attack Scenario: The Enterprise Graph Takeover
An enterprise creates an internal HR application that needs to sync employee calendars. They create an Azure App Registration granting it `Calendars.ReadWrite.All` across the Tenant.
The backend API stores the Client Secret in a transparent `.env` file.
A junior developer accidentally copies the `.env` file into a Docker container during the build process instead of injecting variables at runtime.
The Docker container is pushed to a public DockerHub registry.
An attacker downloads the container image, extracts the `.env` file, and retrieves the Azure Client Secret.
The attacker bypasses the application entirely, requesting a Microsoft Graph token directly from `login.microsoftonline.com`.
The attacker now possesses total access to the calendars, meetings, and descriptions of every single employee in the Fortune 500 company.
Real-World Code Examples
Hardcoded Azure App Registration Secrets (CWE-798)
Azure AD (Entra ID) relies heavily on App Registrations and Service Principals for service-to-service authentication. These utilize a Tenant ID, Client ID, and a Client Secret (a password) to acquire OAuth tokens. Developers frequently hardcode the Client Secret directly into the codebase or `.env` files. Since Azure App Registrations often hold broad Microsoft Graph API permissions (like reading all underlying corporate emails or SharePoint drives), a leaked secret leads to massive enterprise data exfiltration.
Detection & Prevention Checklist
- ✓Transition all Azure-hosted resources (App Services, VMs, Functions) to System-Assigned or User-Assigned Managed Identities
- ✓Scan repositories for the modern Azure Client Secret format (e.g., strings matching standard entropy and starting with `-c_` or similar known prefixes)
- ✓Enforce Azure conditional access policies (IP whitelisting) restricting Service Principal authentication strictly to known corporate or Azure datacenter subnets
- ✓Regularly review Entra ID App Registrations specifically scanning for overly permissive Microsoft Graph Application scopes (e.g., `Mail.Read.All`, `Files.ReadWrite.All`)
- ✓Set aggressive expiration dates (e.g., 3 months max) on all manually generated App Registration client secrets
How Precogs AI Protects You
Precogs AI detects all Azure credential types — AD client secrets, storage keys, SAS tokens, connection strings, and certificate credentials — across source code, configs, Docker, and CI/CD pipelines.
Start Free ScanHow do you detect Azure credentials in code?
Precogs AI detects Azure AD client secrets, storage account keys, SAS tokens, and connection strings across source code, config files, Docker images, and CI/CD pipelines using format-specific pattern matching.
Scan for Azure Credential & Secret Detection Issues
Precogs AI automatically detects azure credential & secret detection vulnerabilities and generates AutoFix PRs.