top of page

Azure API Management Classic Exploited: Rotate APIM Secrets

Writer: Inception Security
Inception Security
8 minutes ago
13 min read
Four-panel comic. Step 1, Secrets stored in APIM Classic got read: a hooded figure walks away from an API gateway booth with keys, saying Spare keys? Thanks. Step 2, Hunt the logs: a monitor alert reads Secret read: unknown caller. Step 3, Rotate every secret: a technician works at a backend door lock holding a clipboard that says Rotate at the issuer. Step 4, Revoke the old one: the technician cuts off an old key. The bottom caption reads The fix does not revoke stolen keys. Inception Security is in the corner.

What this means for your clients: A Microsoft cloud service that connects business apps had a weakness that let an unknown attacker read passwords and keys stored inside it. Microsoft closed the hole, but anything taken may still work until it is changed. Ask your IT provider whether you use this service, and if so, to replace those passwords and check that nobody used the old ones.


Which of your clients still keep backend passwords in named values on an Azure APIM Classic gateway, and would you know if someone read them last week? Norway's National Security Authority, NSM, says an unknown actor actively went after access tokens, secrets and named values in Azure API Management. Microsoft's customer advisory, as reported by BleepingComputer, says it found the issue on November 18 and closed the path on November 19. The same advisory says the fix "does not automatically invalidate credentials that may have been accessed before the fix was deployed." In our judgment, that sentence is the story: the work now is credential rotation at each issuer, then a hunt for secret reads and stolen credentials in use.


As of 6:36 AM MST, Wednesday, November 25, 2026, Microsoft has not published a CVE or a public advisory page; its notice MZK9-GH0 went to customers through Azure Service Health.


What the Azure APIM Classic flaw exposed


According to Microsoft's advisory as quoted by Help Net Security, the flaw could allow unauthorized access to certain management functionality "if the service was not configured according to documented security best practices," including administrative operations such as reading secrets. Affected tiers are Classic Developer, Basic, Standard and Premium. Classic Consumption and all v2 tiers are not affected. Help Net and The Register say exposure centers on Classic instances without Microsoft's recommended network integration, or with secrets stored in APIM instead of referenced from Key Vault. Possibly exposed, per the advisory: secrets in named values, identity provider client secrets, OpenID Connect client secrets, subscription keys and tokens used to call direct management APIs. The fix is service side; Microsoft told BleepingComputer it was fully deployed to Microsoft-hosted instances and required no customer action.


NSM, in a notice updated November 23, says Equinor and Skagerak Energi are among the organizations that have been hit, that the flaw affects several sectors in Norway and beyond, and that the extent of exploitation is still unclear.


How the attacker got in is not public. In a Reddit post BleepingComputer did not verify, an administrator claimed the path left no customer logs. That is an unverified claim, and it shapes the hunts: if true, your logs show what happened next, not the theft.


Why MSPs should care


An API gateway holds the keys to everything behind it. Researcher Anders Kristiansen put it plainly to Help Net: "If someone obtains a credential from that configuration, they may be able to use it directly against the service it protects, outside APIM." In our judgment, MSPs with Azure APIM Classic clients carry this risk several times over: one client's gateway can hold keys to its ERP, payroll or customer APIs, and you may run a dozen client tenants.


What to do today


First, find every instance and its tier across client subscriptions; Microsoft's guide shows a Resource Graph query. For each Classic instance, run NSM's documented RuntimeVersion check: 0.52.x is patched at 31936 or higher, 0.53.x at 31938 or higher, other patterns are v2 or Consumption, and lower numbers are still vulnerable. If an instance is not patched, contact your provider directly.


Then assume named values and secrets are exposed, as NSM advises, and rotate everything Microsoft's rotation guide covers: subscription keys, named values that contain secrets, backend credentials in headers, query parameters and client certificates, OAuth 2.0 and OpenID Connect client secrets, connection strings such as Event Hubs loggers, credentials written directly into policies, and both tenant access keys. When both credentials can remain valid during the change, use Microsoft's order:


  1. Create the replacement at the issuer, such as the backend service or identity provider.

  2. Update API Management with the new secret.

  3. Test your APIs.

  4. Revoke the old secret.


Microsoft warns: "Updating the value in API Management doesn't revoke the old credential at its issuer." Afterward, use a managed identity where supported, keep secrets in Key Vault referenced as named values, and "review your configuration for subscriptions, users, policies or backends that you did not create." Map what each instance can reach.


How to hunt


We have not run these searches live; test each before trusting a clean result. They read the Azure Activity log, APIM GatewayLogs, Entra ID service principal sign-ins and Key Vault AuditEvent logs, with field and table names from Microsoft's schema documentation. Splunk, Elastic and CrowdStrike LogScale need those Azure and Entra logs ingested, usually through Event Hub; Falcon endpoint telemetry does not see this cloud activity. Every YOUR_ name is a placeholder, and every date window and count is our threshold.


Test 1: every APIM instance and its tier


Purpose: each instance from a Resource Graph export, its tier, and whether logging covers it.


Splunk


| inputlookup YOUR_APIM_INVENTORY.csv
| eval inst=lower(id), tier=coalesce(tier, ""), in_inv=1
| append [ search index=YOUR_AZURE_INDEX (sourcetype=YOUR_ACTIVITY_SOURCETYPE OR sourcetype=YOUR_GATEWAY_SOURCETYPE) earliest=-30d resourceId=*
    | eval rid=lower(resourceId), inst=replace(rid, "^(/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\.apimanagement/service/[^/]+).*$", "\1")
    | where like(inst, "/subscriptions/%microsoft.apimanagement/service/%")
    | eval al=if(sourcetype=="YOUR_ACTIVITY_SOURCETYPE", _time, null()), gw=if(sourcetype=="YOUR_GATEWAY_SOURCETYPE", _time, null())
    | stats min(al) as al_first max(al) as al_last max(gw) as gw_last by inst ]
| stats max(in_inv) as in_inv values(name) as name values(subscriptionId) as subscriptionId max(tier) as tier min(al_first) as al_first max(al_last) as al_last max(gw_last) as gw_last by inst
| eval classic=if(match(tier, "(?i)^(Developer|Basic|Standard|Premium)$"), 1, 0)
| eval flag=case(isnull(in_inv), "1 seen in logs, missing from inventory: inventory incomplete",
    tier=="", "1 tier unknown: check in the portal",
    isnull(al_first), "2 no Activity log in 30 days: check the subscription diagnostic setting",
    al_first>strptime("2026-11-01", "%Y-%m-%d"), "2 first Activity log event after Nov 1: verify coverage",
    classic==1 AND (isnull(gw_last) OR gw_last<relative_time(now(), "-7d")), "2 Classic, no GatewayLogs in 7 days: diagnostic setting missing or idle",
    classic==1, "3 Classic: run the NSM RuntimeVersion check and rotate",
    true(), "4 Consumption or v2: not affected per Microsoft")
| appendpipe [ stats count as n | where n==0 | eval flag="0 no inventory and no logs: nothing checked" ]
| convert ctime(al_first) ctime(al_last) ctime(gw_last)
| table flag inst subscriptionId name tier al_first al_last gw_last
| sort flag

Elastic


FROM YOUR_APIM_INVENTORY_INDEX, YOUR_AZURE_ACTIVITY_INDEX, YOUR_APIM_GATEWAY_INDEX METADATA _index
| EVAL src = CASE(_index LIKE "*YOUR_APIM_INVENTORY_INDEX*", "inv", _index LIKE "*YOUR_AZURE_ACTIVITY_INDEX*", "al", "gw")
| WHERE src == "inv" OR @timestamp >= NOW() - 30 days
| EVAL rid = TO_LOWER(CASE(src == "inv", id, resourceId))
| GROK rid "(?<inst>/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\\.apimanagement/service/[^/]+)"
| WHERE inst IS NOT NULL
| STATS in_inv = SUM(CASE(src == "inv", 1, 0)), tier = MAX(CASE(src == "inv", tier, NULL)),
    al_first = MIN(CASE(src == "al", @timestamp, NULL)), al_last = MAX(CASE(src == "al", @timestamp, NULL)),
    gw_last = MAX(CASE(src == "gw", @timestamp, NULL)) BY inst
| EVAL classic = TO_LOWER(tier) RLIKE "(developer|basic|standard|premium)"
| EVAL flag = CASE(in_inv == 0, "1 seen in logs, missing from inventory: inventory incomplete",
    tier IS NULL OR tier == "", "1 tier unknown: check in the portal",
    al_first IS NULL, "2 no Activity log in 30 days: check the subscription diagnostic setting",
    al_first > TO_DATETIME("2026-11-01T00:00:00Z"), "2 first Activity log event after Nov 1: verify coverage",
    classic AND (gw_last IS NULL OR gw_last < NOW() - 7 days), "2 Classic, no GatewayLogs in 7 days: diagnostic setting missing or idle",
    classic, "3 Classic: run the NSM RuntimeVersion check and rotate",
    "4 Consumption or v2: not affected per Microsoft")
| KEEP flag, inst, tier, al_first, al_last, gw_last
| SORT flag

CrowdStrike


// Time picker: last 30 days. Data: Azure Activity log and APIM GatewayLogs ingested into LogScale.
#repo=YOUR_AZURE_REPO (#type=YOUR_ACTIVITY_PARSER OR #type=YOUR_GATEWAY_PARSER) resourceId=*
| rid := lower(resourceId)
| regex("^(?<inst>/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\\.apimanagement/service/[^/]+)", field=rid, strict=true)
| case { #type=YOUR_GATEWAY_PARSER | gw := @timestamp ; * | al := @timestamp }
| groupBy([inst], function=[min(al, as=al_first), max(al, as=al_last), max(gw, as=gw_last)])
| match(file="YOUR_apim_inventory.csv", field=inst, column=id, include=[tier], ignoreCase=true, strict=false)
| default(field=tier, value="")
| default(field=[al_first, al_last, gw_last], value=0)
| case {
    tier="" | flag := "1 seen in logs, missing from inventory: inventory incomplete" ;
    al_first=0 | flag := "2 no Activity log in 30 days: check the subscription diagnostic setting" ;
    test(al_first > 1793491200000) | flag := "2 first Activity log event after Nov 1: verify coverage" ;
    tier=/^(Developer|Basic|Standard|Premium)$/i | test(gw_last < now() - 604800000) | flag := "2 Classic, no GatewayLogs in 7 days: diagnostic setting missing or idle" ;
    tier=/^(Developer|Basic|Standard|Premium)$/i | flag := "3 Classic: run the NSM RuntimeVersion check and rotate" ;
    * | flag := "4 Consumption or v2: not affected per Microsoft" }
| sort(flag, order=asc, limit=1000)
// Results are limited to 1,000 instances. Increase the limit if needed, then compare inst with the export's id column case-insensitively; an export ID absent from complete results has no matching logs in the selected window.

Microsoft KQL


let coverage_start = datetime(2026-11-01); // our threshold
let inv = _GetWatchlist('YOUR_APIM_INVENTORY') | project inst = tolower(tostring(id)), tier = tostring(tier), in_inv = 1;
let al = AzureActivity
    | where TimeGenerated > ago(30d) and ResourceProviderValue =~ "MICROSOFT.APIMANAGEMENT"
    | extend inst = tolower(extract(@"(?i)^(/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\.apimanagement/service/[^/]+)", 1, _ResourceId))
    | where isnotempty(inst)
    | summarize al_first = min(TimeGenerated), al_last = max(TimeGenerated) by inst;
let gw = ApiManagementGatewayLogs
    | where TimeGenerated > ago(7d)
    | summarize gw_last = max(TimeGenerated) by inst = tolower(_ResourceId);
let result = inv
    | join kind=fullouter al on inst
    | extend inst = coalesce(inst, inst1)
    | project-away inst1
    | join kind=fullouter gw on inst
    | extend inst = coalesce(inst, inst1)
    | project-away inst1
    | extend classic = tier matches regex @"(?i)^(Developer|Basic|Standard|Premium)$"
    | extend flag = case(isnull(in_inv), "1 seen in logs, missing from inventory: inventory incomplete",
        isempty(tier), "1 tier unknown: check in the portal",
        isnull(al_first), "2 no Activity log in 30 days: check the subscription diagnostic setting",
        al_first > coverage_start, "2 first Activity log event after Nov 1: verify coverage",
        classic and isnull(gw_last), "2 Classic, no GatewayLogs in 7 days: diagnostic setting missing or idle",
        classic, "3 Classic: run the NSM RuntimeVersion check and rotate",
        "4 Consumption or v2: not affected per Microsoft")
    | project flag, inst, tier, al_first, al_last, gw_last;
result
| union (print flag = "0 no inventory and no logs: nothing checked" | where toscalar(result | count) == 0)
| order by flag asc

Field mapping: the inventory is a Resource Graph export with id, name, subscriptionId and sku.name as tier; KQL uses AzureActivity and ApiManagementGatewayLogs; the others use the exported resourceId. LogScale cannot show inventory rows with no events, so compare IDs case-insensitively with the export. The RuntimeVersion check stays manual.


Hunt 1: who read your APIM secrets


Purpose: listSecrets and listValue calls on APIM since November 1, by caller, IP and instance, against a 30-day baseline.


Splunk


index=YOUR_AZURE_INDEX sourcetype=YOUR_ACTIVITY_SOURCETYPE earliest="10/02/2026:00:00:00"
| eval op=lower(operationName)
| where match(op, "^microsoft\.apimanagement/service/(workspaces/)?[a-z]+/(listsecrets|listvalue)/action$")
| eval inst=replace(lower(resourceId), "^(/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\.apimanagement/service/[^/]+).*$", "\1"), caller=coalesce(YOUR_CALLER_FIELD, "unknown"), ip=coalesce(callerIpAddress, "none")
| eval hunt=if(_time>=strptime("2026-11-01", "%Y-%m-%d"), 1, 0)
| stats sum(eval(1-hunt)) as base sum(hunt) as reads min(eval(if(hunt==1, _time, null()))) as first max(_time) as last values(op) as operations by caller ip inst
| where reads>0
| eval flag=if(base==0, "1 caller and IP pair not in the 30-day baseline", "2 known pair: match to a change record")
| convert ctime(first) ctime(last)
| sort flag -reads

Elastic


FROM YOUR_AZURE_ACTIVITY_INDEX
| WHERE @timestamp >= TO_DATETIME("2026-10-02T00:00:00Z")
| EVAL op = TO_LOWER(operationName), rid = TO_LOWER(resourceId)
| WHERE op RLIKE "microsoft\\.apimanagement/service/(workspaces/)?[a-z]+/(listsecrets|listvalue)/action"
| GROK rid "(?<inst>/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\\.apimanagement/service/[^/]+)"
| EVAL caller = COALESCE(YOUR_CALLER_FIELD, "unknown"), ip = COALESCE(TO_STRING(callerIpAddress), "none"),
    hunt = @timestamp >= TO_DATETIME("2026-11-01T00:00:00Z")
| STATS base = SUM(CASE(hunt, 0, 1)), reads = SUM(CASE(hunt, 1, 0)), first_seen = MIN(CASE(hunt, @timestamp, NULL)),
    last_seen = MAX(@timestamp), operations = VALUES(op) BY caller, ip, inst
| WHERE reads > 0
| EVAL flag = CASE(base == 0, "1 caller and IP pair not in the 30-day baseline", "2 known pair: match to a change record")
| SORT flag, reads DESC

CrowdStrike


// Time picker: Oct 2, 2026 to now. Data: Azure Activity log ingested into LogScale.
#repo=YOUR_AZURE_REPO #type=YOUR_ACTIVITY_PARSER
| op := lower(operationName)
| op=/^microsoft\.apimanagement\/service\/(workspaces\/)?[a-z]+\/(listsecrets|listvalue)\/action$/
| rid := lower(resourceId)
| regex("^(?<inst>/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\\.apimanagement/service/[^/]+)", field=rid, strict=false)
| caller := YOUR_CALLER_FIELD
| default(field=[caller, callerIpAddress], value="none")
| case { test(@timestamp < 1793491200000) | base := 1 | hunt := 0 ; * | base := 0 | hunt := 1 }
| groupBy([caller, callerIpAddress, inst], function=[sum(base, as=base), sum(hunt, as=reads), max(@timestamp, as=last), collect([op])])
| test(reads > 0)
| case { base=0 | flag := "1 caller and IP pair not in the 30-day baseline" ; * | flag := "2 known pair: match to a change record" }
| sort([flag, reads], order=[asc, desc], limit=1000)

Microsoft KQL


let hunt_start = datetime(2026-11-01);
let base_start = hunt_start - 30d; // our baseline
AzureActivity
| where TimeGenerated >= base_start
| where OperationNameValue matches regex @"(?i)^microsoft\.apimanagement/service/(workspaces/)?[a-z]+/(listsecrets|listvalue)/action$"
| extend inst = tolower(extract(@"(?i)^(/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\.apimanagement/service/[^/]+)", 1, _ResourceId)),
    Who = iff(isempty(Caller), "unknown", Caller), Ip = iff(isempty(CallerIpAddress), "none", CallerIpAddress)
| summarize Base = countif(TimeGenerated < hunt_start), Reads = countif(TimeGenerated >= hunt_start),
    First = minif(TimeGenerated, TimeGenerated >= hunt_start), Last = max(TimeGenerated),
    Operations = make_set(OperationNameValue, 20) by Who, Ip, inst
| where Reads > 0
| extend Flag = iff(Base == 0, "1 caller and IP pair not in the 30-day baseline", "2 known pair: match to a change record")
| order by Flag asc, Reads desc

Field mapping: KQL uses OperationNameValue, Caller and CallerIpAddress; the others use operationName, callerIpAddress and a caller placeholder mapped to identity claims. False positives: the portal and DevOps pipelines read secrets legitimately; the signal is a caller or IP with no change record. The Activity log only records calls through Azure Resource Manager.


Hunt 2: subscriptions, users, policies and backends you did not create


Purpose: writes and deletes on APIM subscriptions, users, policies, backends and APIs since November 1, to compare with change tickets.


Splunk


index=YOUR_AZURE_INDEX sourcetype=YOUR_ACTIVITY_SOURCETYPE earliest="11/01/2026:00:00:00"
| eval op=lower(operationName)
| where match(op, "^microsoft\.apimanagement/service/(subscriptions|users|policies|policy|backends|apis|apis/policies|apis/policy|apis/operations/policies|apis/operations/policy|products/policies|products/policy)/(write|delete)$")
| eval inst=replace(lower(resourceId), "^(/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\.apimanagement/service/[^/]+).*$", "\1"), caller=coalesce(YOUR_CALLER_FIELD, "unknown"), ip=coalesce(callerIpAddress, "none")
| lookup YOUR_KNOWN_CHANGE_CALLERS.csv caller OUTPUT caller as known
| fillnull value="no" known
| stats count as changes values(op) as operations values(resourceId) as objects min(_time) as first max(_time) as last by caller ip inst known
| eval flag=if(known=="no" OR known=="", "1 caller not on your change list", "2 known caller: match to a change ticket")
| convert ctime(first) ctime(last)
| sort flag -changes

Elastic


FROM YOUR_AZURE_ACTIVITY_INDEX
| WHERE @timestamp >= TO_DATETIME("2026-11-01T00:00:00Z")
| EVAL op = TO_LOWER(operationName), rid = TO_LOWER(resourceId)
| WHERE op RLIKE "microsoft\\.apimanagement/service/(subscriptions|users|policies|policy|backends|apis|apis/policies|apis/policy|apis/operations/policies|apis/operations/policy|products/policies|products/policy)/(write|delete)"
| GROK rid "(?<inst>/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\\.apimanagement/service/[^/]+)"
| EVAL caller = COALESCE(YOUR_CALLER_FIELD, "unknown"), ip = COALESCE(TO_STRING(callerIpAddress), "none")
| EVAL known = caller IN ("YOUR_CHANGE_CALLER_1", "YOUR_CHANGE_CALLER_2")
| STATS changes = COUNT(*), operations = VALUES(op), objects = VALUES(rid), first_seen = MIN(@timestamp), last_seen = MAX(@timestamp) BY caller, ip, inst, known
| EVAL flag = CASE(known, "2 known caller: match to a change ticket", "1 caller not on your change list")
| SORT flag, changes DESC

CrowdStrike


// Time picker: Nov 1, 2026 to now. Data: Azure Activity log ingested into LogScale.
#repo=YOUR_AZURE_REPO #type=YOUR_ACTIVITY_PARSER
| op := lower(operationName)
| op=/^microsoft\.apimanagement\/service\/(subscriptions|users|policies|policy|backends|apis|apis\/policies|apis\/policy|apis\/operations\/policies|apis\/operations\/policy|products\/policies|products\/policy)\/(write|delete)$/
| rid := lower(resourceId)
| regex("^(?<inst>/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\\.apimanagement/service/[^/]+)", field=rid, strict=false)
| caller := YOUR_CALLER_FIELD
| default(field=[caller, callerIpAddress], value="none")
| match(file="YOUR_known_change_callers.csv", field=caller, column=caller, include=[known], strict=false)
| default(field=known, value="no")
| groupBy([caller, callerIpAddress, inst, known], function=[count(as=changes), collect([op, rid]), min(@timestamp, as=first), max(@timestamp, as=last)])
| case { known="no" | flag := "1 caller not on your change list" ; * | flag := "2 known caller: match to a change ticket" }
| sort([flag, changes], order=[asc, desc], limit=1000)

Microsoft KQL


let known_callers = _GetWatchlist('YOUR_KNOWN_CHANGE_CALLERS') | project caller = tostring(SearchKey);
AzureActivity
| where TimeGenerated >= datetime(2026-11-01)
| where OperationNameValue matches regex @"(?i)^microsoft\.apimanagement/service/(subscriptions|users|policies|policy|backends|apis|apis/policies|apis/policy|apis/operations/policies|apis/operations/policy|products/policies|products/policy)/(write|delete)$"
| extend inst = tolower(extract(@"(?i)^(/subscriptions/[^/]+/resourcegroups/[^/]+/providers/microsoft\.apimanagement/service/[^/]+)", 1, _ResourceId)),
    Who = iff(isempty(Caller), "unknown", Caller), Ip = iff(isempty(CallerIpAddress), "none", CallerIpAddress)
| extend Known = Who in~ (known_callers)
| summarize Changes = count(), Operations = make_set(OperationNameValue, 20), Objects = make_set(_ResourceId, 50),
    First = min(TimeGenerated), Last = max(TimeGenerated) by Who, Ip, inst, Known
| extend Flag = iff(Known, "2 known caller: match to a change ticket", "1 caller not on your change list")
| order by Flag asc, Changes desc

Field mapping: operation names come from Microsoft's access control reference; unverified workspace variants are left out. False positives: deployments write these constantly, so start with callers outside your change list.


Hunt 3: stolen APIM credentials in use elsewhere


Purpose: sign-ins from new IPs by app registrations whose client secrets APIM held, and Key Vault secret reads by any identity but APIM's.


Splunk


index=YOUR_AZURE_INDEX ((sourcetype=YOUR_ENTRA_SP_SIGNIN_SOURCETYPE) OR (sourcetype=YOUR_KEYVAULT_SOURCETYPE operationName=SecretGet)) earliest="10/02/2026:00:00:00" latest="YOUR_ROTATION_DATE"
| eval src=if(sourcetype=="YOUR_KEYVAULT_SOURCETYPE", "keyvault", "entra")
| eval who=if(src=="entra", YOUR_SP_APPID_FIELD, 'identity.claim.http://schemas.microsoft.com/identity/claims/objectidentifier')
| eval ip=coalesce(if(src=="entra", YOUR_SP_IP_FIELD, callerIpAddress), "none"), vault=lower(resourceId)
| where (src=="entra" AND in(who, "YOUR_APIM_APP_ID_1", "YOUR_APIM_APP_ID_2")) OR (src=="keyvault" AND in(vault, "YOUR_APIM_VAULT_ID_LOWERCASE") AND NOT in(who, "YOUR_APIM_MI_OBJECT_ID"))
| eval hunt=if(_time>=strptime("2026-11-01", "%Y-%m-%d"), 1, 0)
| stats sum(eval(1-hunt)) as base sum(hunt) as hits min(eval(if(hunt==1, _time, null()))) as first max(_time) as last by src who ip
| where hits>0 AND (src=="keyvault" OR base==0)
| eval flag=if(src=="keyvault", "1 Key Vault secret read by an identity that is not the APIM managed identity", "1 APIM app signing in from an IP not in the 30-day baseline")
| convert ctime(first) ctime(last)
| sort -hits

Elastic


FROM YOUR_ENTRA_SP_SIGNIN_INDEX, YOUR_KEYVAULT_INDEX METADATA _index
| WHERE @timestamp >= TO_DATETIME("2026-10-02T00:00:00Z") AND @timestamp < TO_DATETIME("YOUR_ROTATION_DATE")
| EVAL src = CASE(_index LIKE "*YOUR_KEYVAULT_INDEX*", "keyvault", "entra")
| WHERE src == "entra" OR operationName == "SecretGet"
| EVAL who = CASE(src == "entra", YOUR_SP_APPID_FIELD, YOUR_KV_OBJECTID_FIELD),
    ip = COALESCE(TO_STRING(CASE(src == "entra", YOUR_SP_IP_FIELD, callerIpAddress)), "none"), vault = TO_LOWER(resourceId)
| WHERE (src == "entra" AND who IN ("YOUR_APIM_APP_ID_1", "YOUR_APIM_APP_ID_2"))
    OR (src == "keyvault" AND vault IN ("YOUR_APIM_VAULT_ID_LOWERCASE") AND who NOT IN ("YOUR_APIM_MI_OBJECT_ID"))
| EVAL hunt = @timestamp >= TO_DATETIME("2026-11-01T00:00:00Z")
| STATS base = SUM(CASE(hunt, 0, 1)), hits = SUM(CASE(hunt, 1, 0)), first_seen = MIN(CASE(hunt, @timestamp, NULL)), last_seen = MAX(@timestamp) BY src, who, ip
| WHERE hits > 0 AND (src == "keyvault" OR base == 0)
| EVAL flag = CASE(src == "keyvault", "1 Key Vault secret read by an identity that is not the APIM managed identity", "1 APIM app signing in from an IP not in the 30-day baseline")
| SORT hits DESC

CrowdStrike


// Time picker: Oct 2, 2026 to YOUR_ROTATION_DATE. Data: Entra ID sign-in and Key Vault logs ingested into LogScale.
#repo=YOUR_AZURE_REPO (#type=YOUR_ENTRA_SP_SIGNIN_PARSER OR (#type=YOUR_KEYVAULT_PARSER operationName="SecretGet"))
| case {
    #type=YOUR_KEYVAULT_PARSER | src := "keyvault" | who := YOUR_KV_OBJECTID_FIELD | ip := callerIpAddress | vault := lower(resourceId) ;
    * | src := "entra" | who := YOUR_SP_APPID_FIELD | ip := YOUR_SP_IP_FIELD | vault := "" }
| default(field=ip, value="none")
| case {
    src="entra" | in(field=who, values=["YOUR_APIM_APP_ID_1", "YOUR_APIM_APP_ID_2"]) ;
    src="keyvault" | in(field=vault, values=["YOUR_APIM_VAULT_ID_LOWERCASE"]) | !in(field=who, values=["YOUR_APIM_MI_OBJECT_ID"]) }
| case { test(@timestamp < 1793491200000) | base := 1 | hunt := 0 ; * | base := 0 | hunt := 1 }
| groupBy([src, who, ip], function=[sum(base, as=base), sum(hunt, as=hits), max(@timestamp, as=last)])
| test(hits > 0)
| case {
    src="keyvault" | flag := "1 Key Vault secret read by an identity that is not the APIM managed identity" ;
    base=0 | flag := "1 APIM app signing in from an IP not in the 30-day baseline" }
| sort(hits, order=desc, limit=1000)

Microsoft KQL


let hunt_start = datetime(2026-11-01);
let rotated = datetime(YOUR_ROTATION_DATE); // placeholder: stop at each client's rotation date
let apim_apps = dynamic(["YOUR_APIM_APP_ID_1", "YOUR_APIM_APP_ID_2"]);
let apim_vaults = dynamic(["YOUR_APIM_VAULT_ID_LOWERCASE"]);
let apim_mi = dynamic(["YOUR_APIM_MI_OBJECT_ID"]);
let sp = AADServicePrincipalSignInLogs
    | where TimeGenerated between (hunt_start - 30d .. rotated) and AppId in (apim_apps)
    | summarize Base = countif(TimeGenerated < hunt_start), Hits = countif(TimeGenerated >= hunt_start),
        First = minif(TimeGenerated, TimeGenerated >= hunt_start), Last = max(TimeGenerated),
        Asn = make_set(AutonomousSystemNumber, 5) by Who = AppId, Ip = IPAddress
    | where Hits > 0 and Base == 0
    | extend Src = "entra", Flag = "1 APIM app signing in from an IP not in the 30-day baseline";
let kv = AZKVAuditLogs
    | where TimeGenerated between (hunt_start .. rotated) and OperationName == "SecretGet" and tolower(_ResourceId) in (apim_vaults)
    | extend Who = tostring(Identity.claim["http://schemas.microsoft.com/identity/claims/objectidentifier"]) // confirm path
    | where Who !in (apim_mi)
    | summarize Hits = count(), First = min(TimeGenerated), Last = max(TimeGenerated) by Who, Ip = CallerIpAddress
    | extend Src = "keyvault", Flag = "1 Key Vault secret read by an identity that is not the APIM managed identity";
union sp, kv
| order by Hits desc

Field mapping: KQL uses AADServicePrincipalSignInLogs and AZKVAuditLogs; the others use exported records, so confirm the identity claim paths. False positives: rotation creates new sign-in patterns, so stop at each client's rotation date.


Reading the results before you escalate


Act now on a secret read or a configuration change from a caller and IP with no change record, on an APIM app signing in from a new IP, and on a Key Vault read by an identity that is not the gateway. Check first on unknown tiers, missing logs and short coverage, which are usually gaps in diagnostic settings rather than an intrusion. A clean Hunt 1 does not clear an instance, so rotate anyway.


One next step


Gateway secrets often trace back to app registrations in Entra ID. For a look at that identity side, start with a free Inception Foresight M365 Assessment.


bg-map-white.png

INCEPTION SECURITY™

A cybersecurity company with in depth knowledge of the threat landscape and security controls.

NAVIGATION

GET IN TOUCH

© 2025 All Rights Reserved by INCEPTION SECURITY™ .

bottom of page