A client secret committed to a public repo used to be a slow-burning problem. Someone had to find it, work out what it unlocked and then use it by hand. In the last two months Microsoft has published three reports showing that step is now automated: AI agent frameworks search GitHub for secrets, sign in as the service principal, map the subscription and pull credentials out of Key Vault, storage accounts and App Service settings, at machine speed. Detections tuned for a human working through an intrusion over hours or days, one alert per stage, will fire after the data has already gone.
This post covers what those reports describe, where the evidence lands in your logs, and five KQL detections for Microsoft Sentinel that cover each stage, plus the response steps that close the door.
What Microsoft reported
All three reports involve ARTEX, which Microsoft describes as an open-source, multi-agent penetration testing framework that can be driven by any AI model. Its agents run a test end to end, from reconnaissance to exfiltration, and build a graph of the assets and weaknesses they find. Threat actors have picked it up:
- October 21: Microsoft attributes ARTEX-driven activity against hundreds of organizations, and a supply chain compromise of a ConnectWise multi-tenant application, to Storm-0940, a group it assesses as China-state aligned. Using stolen credentials for the vendor's apps, the agents signed in to customer tenants through the trust those apps already had, then added app credentials for persistence and changed groups and privileged roles through Microsoft Graph. Microsoft says that in several cases it took under three hours to go from targeting to privileged cloud access.
- November 5: a campaign that started with high-volume GitHub code searches in August, combining organization names with secret, cloud-service and AI-provider keywords. From October 28, service principals signed in from attacker infrastructure against dozens of applications across multiple tenants. In one case a multi-tenant app's credential leaked at the vendor and was used against downstream tenants. In another, the agent went from searching GitHub for a client secret to exfiltrating Key Vault data in five minutes.
- November 6: a financially motivated cluster, Storm-3358, using ARTEX against financial organizations since October, exploiting anonymous file upload and SSRF flaws and dropping open-source RATs (WISP, vshell, AdaptixC2).
The November 5 report is the one to read closely, because it describes behavior you can detect. After signing in, the agent enumerated subscriptions, resource groups, role assignments and AI model deployments, then went after every operation that returns a credential: storage account keys, App Service settings and connection strings, publishing credentials, AI/ML connections and AKS user credentials. When an API call failed, it adapted. Microsoft describes a Key Vault enumeration call sent to Azure Resource Manager with a data-plane API version, which returned HTTP 400, then reissued with a valid ARM API version 28 seconds later and succeeded. With the harvested credentials it moved to other app registrations, read Key Vault secrets, searched Azure DevOps for more secrets and used VM Run Command.
Service principals don't do MFA, most Conditional Access policies don't cover them, and their sign-ins aren't in SigninLogs. If your identity detections are built on user sign-ins, this whole intrusion can run without touching a single one of them.
Where the evidence actually lands
Before writing queries, check you're collecting the right logs. Several of these are off by default.
| Stage | Log source (Sentinel table) | What to look for |
|---|---|---|
| Leaked secret used to sign in | AADServicePrincipalSignInLogs (Entra diagnostic setting: ServicePrincipalSignInLogs) | New IPs, failed secrets, one IP across many apps |
| Token requests for multiple resources | AADServicePrincipalSignInLogs | One app requesting ARM, Key Vault, Storage and Graph tokens in a short window |
| Credential harvesting through ARM | AzureActivity | listKeys, config/list, publishxml, AKS credential and Run Command actions |
| Secret reads | AZKVAuditLogs or AzureDiagnostics (Key Vault diagnostic setting: AuditEvent) | One identity reading secrets across several vaults |
| Directory and mailbox enumeration | MicrosoftGraphActivityLogs (Entra diagnostic setting) | Bursts across many endpoints with a high error rate |
| Persistence on the app | AuditLogs | "Add service principal credentials", "Certificates and secrets management", role assignments |
Two gaps catch people out. AzureActivity records write, delete and action operations, but not plain reads, so the agent's enumeration GETs won't be there; only the /action calls that return secrets will. And Key Vault data-plane access (reading a secret's value) only exists if each vault has a diagnostic setting sending audit events to your workspace. If you have vaults without one, fix that first, using Azure Policy so new vaults inherit it.
Detection 1: one IP, many service principals, bad secrets in the mix
An agent holding a handful of leaked secrets tries each one. Some are expired or rotated, some work. Microsoft calls out two Entra error codes, AADSTS7000215 (invalid client secret) and AADSTS7000222 (expired client secret), and says a failure followed by a success from the same source should be treated as urgent. It also gives a heuristic: one IP authenticating to three or more service principals with mixed results.
AADServicePrincipalSignInLogs | where TimeGenerated > ago(1d) | extend Ok = ResultType in ("0", "Success"), BadSecret = ResultType in ("7000215", "7000222") or ResultSignature has_any ("7000215", "7000222") | summarize Attempts = count(), Successes = countif(Ok), Failures = countif(not(Ok)), BadSecrets = countif(BadSecret), ServicePrincipals = dcount(ServicePrincipalId), SPNames = make_set(ServicePrincipalName, 25), Resources = make_set(ResourceDisplayName, 10) by IPAddress, bin(TimeGenerated, 1h) | where ServicePrincipals >= 3 and Failures > 0 | extend Priority = iff(Successes > 0 and BadSecrets > 0, "High", "Medium") | order by Priority asc, ServicePrincipals desc
This catches secret spraying and the "try every key we found" pattern. The query accepts both forms of the result field because Microsoft Learn documents ResultType loosely for this table; run a quick summarize count() by ResultType, ResultSignature in your workspace and tighten it to whichever form you see. The false positives are your own automation: CI/CD runners, Terraform pipelines and integration servers often authenticate as several service principals from one NAT egress IP, and a stale secret in a pipeline produces exactly this failure-then-success shape. Exclude known automation egress IPs with a watchlist, and review it; build agents are also a good place to steal secrets from.
Detection 2: one app pulling tokens for ARM, Key Vault, Storage and Graph from a new IP
Most service principals do one job and talk to one or two resources. An agent that has just obtained a secret wants to know everything it can reach, so it requests tokens for Azure Resource Manager, Key Vault, Storage and Microsoft Graph in quick succession. Microsoft lists this as a behavioral indicator. Pair it with "IP this app hasn't used before" and it gets quiet enough to alert on.
let Lookback = 14d; let Recent = 1d; let KnownIPs = AADServicePrincipalSignInLogs | where TimeGenerated between (ago(Lookback) .. ago(Recent)) | where ResultType in ("0", "Success") | distinct ServicePrincipalId, IPAddress; AADServicePrincipalSignInLogs | where TimeGenerated > ago(Recent) | where ResultType in ("0", "Success") | extend Target = case( ResourceIdentity == "797f4846-ba00-4fd7-ba43-dac1f8f63013" or ResourceDisplayName in~ ("Azure Resource Manager", "Windows Azure Service Management API"), "ARM", ResourceIdentity == "cfa8b339-82a2-471a-a3c9-0fc0be7a4093" or ResourceDisplayName =~ "Azure Key Vault", "KeyVault", ResourceIdentity == "e406a681-f3d4-42a8-90b6-c2b029497af1" or ResourceDisplayName =~ "Azure Storage", "Storage", ResourceIdentity == "00000003-0000-0000-c000-000000000000" or ResourceDisplayName =~ "Microsoft Graph", "Graph", "Other") | where Target != "Other" | join kind=leftanti KnownIPs on ServicePrincipalId, IPAddress | summarize Targets = dcount(Target), TargetList = make_set(Target), FirstSeen = min(TimeGenerated), LastSeen = max(TimeGenerated) by ServicePrincipalId, ServicePrincipalName, AppId, IPAddress | where Targets >= 3 | extend SpanMinutes = datetime_diff('minute', LastSeen, FirstSeen) | order by SpanMinutes asc
The resource is matched on both app ID and display name because the Azure Resource Manager service principal shows up under more than one display name. Results with a short SpanMinutes are the interesting ones: a human admin testing an app doesn't request four resource tokens inside a couple of minutes from a fresh IP. Apps that legitimately span resources (backup products, security tools, deployment pipelines) usually have a stable IP set, so the leftanti join removes most of them. Newly onboarded tools will fire once.
Detection 3: harvesting credentials through Azure Resource Manager
This is the stage where an app secret turns into many other secrets. Every one of these operations hands back a credential, and because they are /action operations they are recorded in AzureActivity. One caller using several different kinds of them in an hour is the pattern.
let CredOps = dynamic([ "MICROSOFT.STORAGE/STORAGEACCOUNTS/LISTKEYS/ACTION", "MICROSOFT.STORAGE/STORAGEACCOUNTS/LISTACCOUNTSAS/ACTION", "MICROSOFT.WEB/SITES/CONFIG/LIST/ACTION", "MICROSOFT.WEB/SITES/PUBLISHXML/ACTION", "MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/LISTCLUSTERUSERCREDENTIAL/ACTION", "MICROSOFT.CONTAINERSERVICE/MANAGEDCLUSTERS/LISTCLUSTERADMINCREDENTIAL/ACTION", "MICROSOFT.COMPUTE/VIRTUALMACHINES/RUNCOMMAND/ACTION" ]); AzureActivity | where TimeGenerated > ago(1d) | where OperationNameValue in~ (CredOps) | extend CallerAppId = tostring(Claims_d.appid) | summarize OpKinds = dcount(OperationNameValue), Ops = make_set(OperationNameValue), TargetResources = dcount(_ResourceId), Subscriptions = dcount(SubscriptionId), Failed = countif(ActivityStatusValue in~ ("Failure", "Failed")), IPs = make_set(CallerIpAddress, 10) by Caller, CallerAppId, bin(TimeGenerated, 1h) | where OpKinds >= 2 or TargetResources >= 5 | order by OpKinds desc, TargetResources desc
Caller is an object ID for service principals; the appid claim gives you the application ID to look up. Case varies in OperationNameValue, hence in~. The legitimate callers are predictable: backup tools and monitoring agents call listKeys on a schedule, deployment pipelines call publishxml, and admins pull AKS credentials. Baseline each caller's normal operation set over 30 days and alert on a new operation kind for that caller, or on any of these from an identity that has never called them before. Treat RUNCOMMAND from a service principal as high priority on its own; few organizations do that legitimately, and it's code execution on the VM.
Detection 4: bulk secret reads across Key Vaults
Key Vault is where the agent cashes in. The pattern is one identity performing many successful secret reads, usually across several vaults, in a short window. This version works on the resource-specific AZKVAuditLogs table.
AZKVAuditLogs | where TimeGenerated > ago(1d) | where OperationName startswith "Secret" | extend CallerAppId = tostring(Identity.claim.appid), CallerObjectId = tostring(Identity.claim["http://schemas.microsoft.com/identity/claims/objectidentifier"]) | summarize SecretGets = countif(OperationName == "SecretGet" and HttpStatusCode == 200), Forbidden = countif(HttpStatusCode == 403), Vaults = dcount(_ResourceId), VaultList = make_set(_ResourceId, 10), IPs = make_set(CallerIpAddress, 10) by CallerAppId, CallerObjectId, bin(TimeGenerated, 15m) | where Vaults >= 3 or SecretGets >= 20 or Forbidden >= 10 | order by Vaults desc, SecretGets desc
The Forbidden count matters for this attacker: an agent tries every vault it can see, and a run of 403s shows it testing the edges of its permissions. If your vaults still log to AzureDiagnostics, the same logic works with ResourceProvider == "MICROSOFT.KEYVAULT", httpStatusCode_d, CallerIPAddress and identity_claim_appid_g. Applications that load all their secrets at startup produce bursts of SecretGet against one vault; that's why the vault count is the stronger signal. Secret-rotation tooling and CSPM scanners that touch every vault are the other common false positive, and both have stable identities you can exclude by object ID.
Detection 5: Graph enumeration at machine speed
The adaptive retry behavior is a fingerprint in itself. A normal integration calls the same few Graph endpoints and rarely gets errors. An agent exploring what a token can do hits many endpoints, collects 400s and 403s, and corrects itself within seconds.
MicrosoftGraphActivityLogs | where TimeGenerated > ago(1d) | where isempty(UserId) | extend Endpoint = tostring(split(tostring(split(RequestUri, "?")[0]), "/")[4]) | summarize Requests = count(), Endpoints = dcount(Endpoint), EndpointList = make_set(Endpoint, 20), ClientErrors = countif(ResponseStatusCode between (400 .. 499)), ToolingUA = countif(UserAgent has_any ("python-requests", "Python-urllib", "curl/", "azure-toolkit")), UserAgents = make_set(UserAgent, 5) by AppId, ServicePrincipalId, IPAddress, bin(TimeGenerated, 10m) | extend ErrorRate = round(todouble(ClientErrors) / Requests, 2) | where Endpoints >= 8 and ErrorRate >= 0.2 | order by Endpoints desc
isempty(UserId) keeps it to app-only tokens, which is how a stolen client secret shows up. The endpoint is the first path segment after the version (users, groups, applications, servicePrincipals, and so on). The thresholds are starting points; run it over 30 days and set them just above your noisiest legitimate app. The ToolingUA column counts requests carrying the default user agents Microsoft listed in its Storm-0940 indicators. Use it to rank, not to filter: plenty of legitimate scripts use python-requests, and Microsoft is explicit that blocking user agents or IPs won't stop an agent that changes its fingerprint.
What to alert on and what to hunt
- Alert: detection 1 with a success after a bad-secret failure, detection 2, detection 3 for Run Command or a never-before-seen caller, and detection 4 when the vault count is 3 or more. At this attacker's speed, these need to page someone or trigger automated containment, not wait in a queue.
- Hunt weekly: detection 5, the lower-threshold versions of 3 and 4, and new credentials added to app registrations (
AuditLogsoperations "Add service principal credentials" and anything matching "Certificates and secrets management") followed by a sign-in from a new IP. - Correlate: any two of these on the same app ID within an hour is an incident. Map
AppIdandIPAddressas entities so Sentinel groups them.
Also consider deception, which Microsoft recommends for this attacker. An agent that scrapes every secret it can find will try a fake one too, and any use of a credential nothing legitimate uses is a high-confidence alert. A decoy app registration with no permissions works with detection 1 and a filter on its app ID.
Response: assume the agent already used everything the app could reach
Containment steps, following Microsoft's guidance in the November 5 report:
- Remove the credentials, not just the leaked one. Delete every client secret, certificate and federated credential on the affected app registration, including any the attacker added. Disable the service principal if the business can live without it for a few hours.
- Remember tokens outlive the secret. Access tokens already issued stay valid until they expire. Plan for activity to continue briefly after rotation, and keep watching the app's Graph and ARM activity.
- Rotate everything the app could read. If it had access to a Key Vault, every secret in that vault is compromised, and so is every storage key, connection string and publishing credential it could list. This is the expensive step and the one that gets skipped.
- Revoke related sessions and tokens: Entra sessions for affected users, Azure DevOps personal access tokens, and SSH keys. Check DevOps audit logs for PAT creation, pipeline edits and service connection changes.
- Check for persistence: new app registrations, new owners, app role assignments, and role or group changes made by the service principal (
AuditLogs, filtered onInitiatedByfor the app). The OAuth consent phishing post has queries for consent grants and app permission changes. - If the app is multi-tenant or you're a service provider, assume downstream tenants are affected, tell them, and review GDAP access.
Hardening that removes the opportunity
- Get secrets out of code. Turn on GitHub secret scanning and push protection. Treat any secret that was ever public as compromised, even after you delete the commit: forks, caches and archives keep copies, and the agents search continuously.
- Replace client secrets with managed identities or workload identity federation wherever the workload runs in Azure or in a CI system that supports OIDC. No secret, nothing to leak.
- Restrict app credentials with app management policies: block new password credentials on app registrations and enforce a maximum lifetime where you can't.
- Least privilege for service principals. An app that needs one storage container shouldn't hold Contributor on the subscription.
- Conditional Access for workload identities (requires Workload ID Premium) lets you restrict single-tenant service principals to known IP ranges, which stops a leaked secret being used from anywhere else.
- Turn on the Defender for Cloud plans for Resource Manager, Key Vault and Storage. Several of the alerts Microsoft lists for these campaigns come from them.
The defender's advantage against human attackers was always time: each stage took long enough that a decent alert could land before the next one. Against an agent that goes from a public secret to your Key Vault in minutes, that advantage only survives if the logs are switched on, the detections are tuned for service principals rather than users, and the response to "this app is being abused" is automated enough to run before anyone opens the incident.
Every issue includes a full detection rule for Sentinel, CrowdStrike or Splunk, with investigation steps, false positive guidance and MITRE mapping. Platforms rotate so you get broad coverage over time.
Join — $14.99/mo See a Sample Issue