↳ GitHub sourceAnalytics ruleMedium
Detect presence of uncommon user agents in web requests (ASIM Web Session)
Description
'This rule assists in detecting rare user agents, which may indicate web browsing activity by an unconventional process different from the usual ones. The rule specifically searches for UserAgent strings that have not been seen in the past 14 days. This query will perform better when run over summarized data'
- Rule type
- Scheduled
- Version
- 1.0.2
- Declared status
- Available
- Query frequency
- 1h
- Query period
- 14d
- Trigger
- gt 0
Declared MITRE coverage
KQL query
Original query, unchanged.
let lookBack = 14d;
let timeframe = 1h;
// calculate avg. eps(events per second)
let eps = materialize(_Im_WebSession(starttime=ago(1d))
| project TimeGenerated
| summarize AvgPerSec = count() / 3600 by bin(TimeGenerated, 1h)
| summarize round(avg(AvgPerSec))
);
let summarizationexist = (
union isfuzzy=true
(
WebSessionEssentialsCustomParser
| where Type in ("WebSession_Summarized_SrcInfo_CL", "WebSession_Summarized_SrcInfoV1_CL")
| where EventTime_t > ago(1d)
| project v = int(2)
),
(
print int(1)
| project v = print_0
)
| summarize maxv = max(v)
| extend sumexist = (maxv > 1)
);
let allUserAgents = union isfuzzy=true
(
(datatable(exists: int, sumexist: bool)[1, false]
| where toscalar(eps) > 1000
| join (summarizationexist) on sumexist)
| join (
_Im_WebSession(starttime=todatetime(ago(2d)), endtime=bin(ago(timeframe), 1h), eventresult='Success')
| where isnotempty(HttpUserAgent)
| summarize UserAgentsSet = make_set(HttpUserAgent) // This could contain upto 10,48,576 unique values
| extend exists=int(1)
)
on exists
| project-away exist*, maxv, sum*
),
(
(datatable(exists: int, sumexist: bool)[1, false]
| where toscalar(eps) between (501 .. 1000)
| join (summarizationexist) on sumexist)
| join (
_Im_WebSession(starttime=todatetime(ago(3d)), endtime=bin(ago(timeframe), 1h), eventresult='Success')
| where isnotempty(HttpUserAgent)
| summarize UserAgentsSet = make_set(HttpUserAgent) // This could contain upto 10,48,576 unique values
| extend exists=int(1)
)
on exists
| project-away exist*, maxv, sum*
),
(
(datatable(exists: int, sumexist: bool)[1, false]
| where toscalar(eps) <= 500
| join (summarizationexist) on sumexist)
| join (
_Im_WebSession(starttime=todatetime(ago(4d)), endtime=bin(ago(timeframe), 1h), eventresult='Success')
| where isnotempty(HttpUserAgent)
| summarize UserAgentsSet = make_set(HttpUserAgent) // This could contain upto 10,48,576 unique values
| extend exists=int(1)
)
on exists
| project-away exist*, maxv, sum*
),
(
WebSessionEssentialsCustomParser
| where Type in ("WebSession_Summarized_SrcInfo_CL", "WebSession_Summarized_SrcInfoV1_CL")
| where EventTime_t between (ago(14d) .. ago(timeframe))
and isnotempty(HttpUserAgent_s)
and EventResult_s =~ 'Success'
| summarize UserAgentsSet = make_set(HttpUserAgent_s) // This could contain upto 10,48,576 unique values
);
_Im_WebSession (starttime=bin(ago(timeframe), 1h), eventresult='Success')
| project
SrcIpAddr,
SrcUsername,
SrcHostname,
DstIpAddr,
DstPortNumber,
Url,
HttpUserAgent,
TimeGenerated
| where isnotempty(HttpUserAgent) and HttpUserAgent !in~ (allUserAgents)
| summarize
EventCount=count(),
EventStartTime=min(TimeGenerated),
EventEndTime=max(TimeGenerated)
by
SrcIpAddr,
SrcUsername,
SrcHostname,
DstIpAddr,
Url,
HttpUserAgent,
DstPortNumber
| extend Name = iif(SrcUsername contains "@", tostring(split(SrcUsername,'@',0)[0]),SrcUsername), UPNSuffix = iif(SrcUsername contains "@",tostring(split(SrcUsername,'@',1)[0]),"")
Declared entities
Related content
Links established from declared identifiers and solution manifests.
Source provenance
GitHubDisplayed values come from files in Azure/Azure-Sentinel. They describe the published template, not your workspace configuration.
- Commit
9800e51↗- Source identifier
2d50d937-d7f2-4c05-b151-9af7f9ec747e
GSTEP / CATALOG TRACKING
Added to catalog : 16 Sept 2026 · 05:49 UTC
Last change observed : 16 Sept 2026 · 05:49 UTC