Microsoft Foundry Subscription Key Impossible Travel
Detects the same API Management subscription key calling Microsoft Foundry from source IPs in two or more countries, far enough apart and fast enough that the hop is not physical travel. Calls are grouped by apim_subscription_id. Requests with no subscription key are ignored, because those are unauthenticated calls and share no key.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2026/10/01"
3integration = ["azure_ai_foundry"]
4maturity = "production"
5min_stack_version = "9.4.0"
6min_stack_comments = "The Microsoft Foundry integration is compatible with 9.3 and above. ES|QL FIRST/LAST aggregations and st_distance require 9.4.0+."
7updated_date = "2026/10/05"
8
9[rule]
10author = ["Elastic"]
11description = """
12Detects the same API Management subscription key calling Microsoft Foundry from source IPs in two or more countries,
13far enough apart and fast enough that the hop is not physical travel. Calls are grouped by apim_subscription_id.
14Requests with no subscription key are ignored, because those are unauthenticated calls and share no key.
15"""
16false_positives = [
17 """
18 A subscription key used from a VPN, a cloud VM, or a corporate proxy whose egress geo is far from the developer's
19 network. A home ISP and a cloud build agent on the same key look like impossible travel.
20 """,
21 """
22 One shared subscription key in front of users in different countries. Split that key per application, or raise the
23 distance and speed thresholds in the query.
24 """,
25]
26from = "now-4h"
27language = "esql"
28license = "Elastic License v2"
29name = "Microsoft Foundry Subscription Key Impossible Travel"
30note = """## Triage and analysis
31
32### Investigating Microsoft Foundry Subscription Key Impossible Travel
33
34One API Management subscription key was used from source IPs in at least two countries, and the first and last
35locations in the lookback are too far apart for the time between them. The alert is grouped by that subscription,
36the API, the operation, the API Management resource, and the URL. IP, country, ASN, and user agent stay as value
37lists because those change between the two locations. Distance and speed thresholds are in the query.
38
39A return to the first country can keep the first and last points close, so the alert may not fire. Sort the raw
40GatewayLogs for that subscription before closing it.
41
42#### Possible investigation steps
43
44- Read Esql.distance_km, Esql.travel_kmh, Esql.window_minutes, and the country, city, IP, and ASN lists. Two countries
45 and a high speed is the case this rule is for.
46- Compare user agents across the IPs. A browser or script on the distant IP that does not match the usual client for
47 that subscription is the higher priority hop.
48- Confirm the distant IP is not an approved egress for this subscription: a build VM, a NAT, or a second office.
49- Look for other GatewayLogs on the same subscription in the same window: refusals, HTTP 400 jailbreak blocks, or a
50 jump in call volume.
51
52### False positive analysis
53
54- VPN and cloud egress. The second IP often belongs to the cloud provider's ASN rather than a residential ISP.
55- A shared key used by design from more than one country. Exclude that subscription or raise the thresholds in the
56 query.
57
58### Response and remediation
59
60- If the distant IP is not approved, regenerate the API Management subscription key and update the applications that
61 use it.
62- Review Foundry calls for that subscription after the distant event for prompts, refusals, and token volume.
63"""
64references = [
65 "https://www.elastic.co/docs/reference/integrations/azure_ai_foundry",
66 "https://learn.microsoft.com/en-us/azure/api-management/diagnostic-logs-reference",
67]
68risk_score = 47
69rule_id = "49fcbc29-675b-487e-88a2-655ec067a1cc"
70setup = """## Setup
71
72This rule needs the Microsoft Foundry integration collecting Azure API Management GatewayLogs with the client IP.
73The subscription key name is apim_subscription_id, and that is the value the rule groups on. Foundry
74RequestResponse logs do not record the key, and the caller address there is masked.
75
76- Use an API Management tier that emits resource logs. Developer or higher works. Consumption does not.
77- Send the GatewayLogs category to the Event Hub the integration reads.
78- Log the client IP in API diagnostics so source.ip and source.geo are on the event. The rule uses source.geo.location for the distance.
79
80https://www.elastic.co/docs/reference/integrations/azure_ai_foundry
81"""
82severity = "medium"
83tags = [
84 "Data Source: Microsoft Foundry",
85 "Use Case: Threat Detection",
86 "Mitre Atlas: AML.T0091",
87 "Mitre Atlas: AML.T0012",
88 "Resources: Investigation Guide",
89 "Tactic: Credential Access",
90 "Tactic: Initial Access",
91 "Rule Type: ES|QL",
92 "Platform: Azure",
93 "Domain: Cloud",
94 "Domain: GenAI",
95 "Service: Azure API Management",
96 "Threat: Impossible Travel"
97]
98timestamp_override = "event.ingested"
99type = "esql"
100
101query = '''
102from logs-azure_ai_foundry.logs-*
103| where
104 data_stream.dataset == "azure_ai_foundry.logs" and
105 azure.ai_foundry.category == "GatewayLogs" and
106 azure.ai_foundry.properties.apim_subscription_id is not null and
107 source.ip is not null and
108 source.geo.location is not null and
109 source.geo.country_name is not null
110| eval
111 Esql.source_geo_lat = st_y(source.geo.location),
112 Esql.source_geo_lon = st_x(source.geo.location)
113| where Esql.source_geo_lat is not null and Esql.source_geo_lon is not null
114| stats
115 Esql.first_lat = first(Esql.source_geo_lat, @timestamp),
116 Esql.first_lon = first(Esql.source_geo_lon, @timestamp),
117 Esql.last_lat = last(Esql.source_geo_lat, @timestamp),
118 Esql.last_lon = last(Esql.source_geo_lon, @timestamp),
119 Esql.event_count = count(*),
120 Esql.country_count = count_distinct(source.geo.country_name),
121 Esql.source_ip_values = values(source.ip),
122 Esql.source_geo_country_name_values = values(source.geo.country_name),
123 Esql.source_geo_region_name_values = values(source.geo.region_name),
124 Esql.source_geo_city_name_values = values(source.geo.city_name),
125 Esql.source_as_organization_name_values = values(source.as.organization.name),
126 Esql.azure_ai_foundry_properties_user_agent_values = values(azure.ai_foundry.properties.user_agent),
127 Esql.azure_ai_foundry_properties_backend_response_code_values = values(azure.ai_foundry.properties.backend_response_code),
128 Esql.azure_ai_foundry_properties_apim_subscription_id = min(azure.ai_foundry.properties.apim_subscription_id),
129 Esql.timestamp_first_seen = min(@timestamp),
130 Esql.timestamp_last_seen = max(@timestamp)
131 by
132 azure.ai_foundry.properties.apim_subscription_id,
133 azure.ai_foundry.properties.api_id,
134 azure.ai_foundry.properties.operation_id,
135 azure.resource.name,
136 azure.resource.group,
137 url.domain,
138 url.path
139| where Esql.event_count >= 2 and Esql.country_count >= 2
140| eval
141 Esql.p1 = to_geopoint(concat("POINT(", to_string(Esql.first_lon), " ", to_string(Esql.first_lat), ")")),
142 Esql.p2 = to_geopoint(concat("POINT(", to_string(Esql.last_lon), " ", to_string(Esql.last_lat), ")"))
143| eval
144 Esql.distance_km = round(st_distance(Esql.p1, Esql.p2) / 1000.0, 0),
145 Esql.window_minutes = date_diff("minute", Esql.timestamp_first_seen, Esql.timestamp_last_seen),
146 Esql.travel_kmh = case(Esql.window_minutes > 0, round(Esql.distance_km * 60.0 / Esql.window_minutes, 0), null),
147 source.ip = MV_FIRST(Esql.source_ip_values)
148| where Esql.distance_km >= 500 and Esql.travel_kmh >= 800
149| keep
150 azure.ai_foundry.properties.apim_subscription_id,
151 azure.ai_foundry.properties.api_id,
152 azure.ai_foundry.properties.operation_id,
153 azure.resource.name,
154 azure.resource.group,
155 url.domain,
156 url.path,
157 source.ip,
158 Esql.*
159'''
160
161
162[[rule.threat]]
163framework = "MITRE ATT&CK"
164[[rule.threat.technique]]
165id = "T1528"
166name = "Steal Application Access Token"
167reference = "https://attack.mitre.org/techniques/T1528/"
168
169
170[rule.threat.tactic]
171id = "TA0006"
172name = "Credential Access"
173reference = "https://attack.mitre.org/tactics/TA0006/"
174
175[[rule.threat]]
176framework = "MITRE ATT&CK"
177[[rule.threat.technique]]
178id = "T1078"
179name = "Valid Accounts"
180reference = "https://attack.mitre.org/techniques/T1078/"
181[[rule.threat.technique.subtechnique]]
182id = "T1078.004"
183name = "Cloud Accounts"
184reference = "https://attack.mitre.org/techniques/T1078/004/"
185
186
187[rule.threat.tactic]
188id = "TA0001"
189name = "Initial Access"
190reference = "https://attack.mitre.org/tactics/TA0001/"
191
192[[rule.threat_mappings]]
193framework = "MITRE ATLAS"
194version = "2026.08"
195[[rule.threat_mappings.threat]]
196framework = "MITRE ATLAS"
197[[rule.threat_mappings.threat.technique]]
198id = "AML.T0091"
199name = "Use Alternate Authentication Material"
200reference = "https://atlas.mitre.org/techniques/AML.T0091/"
201[[rule.threat_mappings.threat.technique.subtechnique]]
202id = "AML.T0091.000"
203name = "Application Access Token"
204reference = "https://atlas.mitre.org/techniques/AML.T0091.000/"
205
206
207[rule.threat_mappings.threat.tactic]
208id = "AML.TA0015"
209name = "Lateral Movement"
210reference = "https://atlas.mitre.org/tactics/AML.TA0015/"
211[[rule.threat_mappings.threat]]
212framework = "MITRE ATLAS"
213[[rule.threat_mappings.threat.technique]]
214id = "AML.T0012"
215name = "Valid Accounts"
216reference = "https://atlas.mitre.org/techniques/AML.T0012/"
217
218
219[rule.threat_mappings.threat.tactic]
220id = "AML.TA0004"
221name = "Initial Access"
222reference = "https://atlas.mitre.org/tactics/AML.TA0004/"
223
224[rule.alert_suppression]
225group_by = ["source.ip"]
226duration = {value = 4, unit = "h"}
227missing_fields_strategy = "suppress"
228
229[rule.investigation_fields]
230field_names = [
231 "azure.ai_foundry.properties.apim_subscription_id",
232 "azure.ai_foundry.properties.api_id",
233 "azure.ai_foundry.properties.operation_id",
234 "azure.resource.name",
235 "azure.resource.group",
236 "url.domain",
237 "url.path",
238 "Esql.distance_km",
239 "Esql.travel_kmh",
240 "Esql.window_minutes",
241 "Esql.country_count",
242 "Esql.event_count",
243 "Esql.source_ip_values",
244 "Esql.source_geo_country_name_values",
245 "Esql.source_geo_region_name_values",
246 "Esql.source_geo_city_name_values",
247 "Esql.source_as_organization_name_values",
248 "Esql.azure_ai_foundry_properties_user_agent_values",
249 "Esql.azure_ai_foundry_properties_backend_response_code_values",
250 "Esql.first_lat",
251 "Esql.first_lon",
252 "Esql.last_lat",
253 "Esql.last_lon",
254 "Esql.timestamp_first_seen",
255 "Esql.timestamp_last_seen",
256]
Triage and analysis
Investigating Microsoft Foundry Subscription Key Impossible Travel
One API Management subscription key was used from source IPs in at least two countries, and the first and last locations in the lookback are too far apart for the time between them. The alert is grouped by that subscription, the API, the operation, the API Management resource, and the URL. IP, country, ASN, and user agent stay as value lists because those change between the two locations. Distance and speed thresholds are in the query.
A return to the first country can keep the first and last points close, so the alert may not fire. Sort the raw GatewayLogs for that subscription before closing it.
Possible investigation steps
- Read Esql.distance_km, Esql.travel_kmh, Esql.window_minutes, and the country, city, IP, and ASN lists. Two countries and a high speed is the case this rule is for.
- Compare user agents across the IPs. A browser or script on the distant IP that does not match the usual client for that subscription is the higher priority hop.
- Confirm the distant IP is not an approved egress for this subscription: a build VM, a NAT, or a second office.
- Look for other GatewayLogs on the same subscription in the same window: refusals, HTTP 400 jailbreak blocks, or a jump in call volume.
False positive analysis
- VPN and cloud egress. The second IP often belongs to the cloud provider's ASN rather than a residential ISP.
- A shared key used by design from more than one country. Exclude that subscription or raise the thresholds in the query.
Response and remediation
- If the distant IP is not approved, regenerate the API Management subscription key and update the applications that use it.
- Review Foundry calls for that subscription after the distant event for prompts, refusals, and token volume.
References
Related rules
- Anthropic User Activity From High Number of Countries
- Anthropic Session Reuse Impossible Travel
- Google Workspace Impossible Travel Login
- Microsoft Entra ID Impossible Travel Sign-in
- AWS Bedrock API Key Used for Destructive or Anti-Recovery Action