User-Agent
Table of Contents
A string sent in the User-Agent HTTP request header identifying
the client application, OS, and device type making the request.
Used by servers for content negotiation and by security tools
as a network-level indicator of compromise — certain tools,
malware families, and attack frameworks have characteristic
User-Agent strings.
Related: HTTP Content Negotiation Indicators of Compromise User-Agent Spoofing Network Traffic Analysis
Structure
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 Components: — Mozilla/5.0 historical artefact, present in almost all browsers — (Windows NT 10.0; Win64; x64) OS and architecture — AppleWebKit/537.36 rendering engine — (KHTML, like Gecko) compatibility token — Chrome/127.0.0.0 actual browser and version — Safari/537.36 compatibility token
Modern browser UA strings are intentionally convoluted due to decades of server-side UA sniffing — every browser claims to be every previous browser for compatibility.
Common User-Agent Patterns
Legitimate browsers
# Chrome (Windows) Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36 # Firefox (Linux) Mozilla/5.0 (X11; Linux x86_64; rv:128.0) Gecko/20100101 Firefox/128.0 # Safari (macOS) Mozilla/5.0 (Macintosh; Intel Mac OS X 14_5) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.5 Safari/605.1.15
Tool and script default strings (suspicious in web logs)
python-requests/2.31.0 python-urllib3/1.26.18 Go-http-client/1.1 curl/8.6.0 Wget/1.21.3 Java/17.0.8 nikto sqlmap/1.7 masscan/1.0 nmap scripting engine
Malware / C2 framework indicators
# Cobalt Strike default (before operators change it) Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0; 125LA; .NET CLR 2.0.50727) # Metasploit Meterpreter Mozilla/4.0 (compatible; MSIE 6.1; Windows NT) # Raccoon Stealer Mozilla/5.0 (Windows NT 6.0) AppleWebKit/537.36 # Empty or absent User-Agent # (tools sending raw HTTP without setting a UA)
Note: sophisticated operators change default C2 User-Agents — these are starting points for hunting, not definitive signatures.
Security Uses
Detection in logs (web server / proxy)
# Apache/Nginx — find tool signatures in access logs grep -iE "sqlmap|nikto|masscan|python-requests|curl|wget" /var/log/nginx/access.log # Find empty User-Agent (unusual for browsers) grep '"" ' /var/log/nginx/access.log # Find non-browser UAs with high request rates awk '{print $12}' access.log | sort | uniq -c | sort -rn | head -20
Detection in Splunk (SPL)
index=web | stats count by http_user_agent | where count > 100 | where NOT match(http_user_agent, "Mozilla|Chrome|Safari|Firefox|Edge") | sort -count
Detection in KQL (Microsoft Sentinel)
AzureDiagnostics | where Category == "ApplicationGatewayAccessLog" | where userAgent_s !startswith "Mozilla" | summarize count() by userAgent_s | where count_ > 10 | order by count_ desc
User-Agent Spoofing
Attackers change their UA to blend in or exploit parsing:
import requests # Impersonate a browser headers = { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) " "AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/127.0.0.0 Safari/537.36" } response = requests.get("https://target.com", headers=headers)
# curl with spoofed UA curl -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64)" https://target.com
See User-Agent Spoofing for full detail.
Reliability as an IOC
User-Agent strings are easily changed — they are:
- Useful for detecting unsophisticated tools and default framework configurations
- Unreliable for attribution — any tool or attacker who knows they are being monitored will change their UA
- Best combined with other indicators: source IP, request timing, request volume, URI patterns
On the Pyramid of Pain, User-Agent strings sit at the "Tools" level — changing them is trivial but does require effort, making UA-based detections useful for catching automated and commodity attacks.
Tips
- Log User-Agents at every layer that touches HTTP traffic — WAF, reverse proxy, web server, and application logs may each capture different traffic
- An absent or empty User-Agent is itself an indicator — virtually all real browsers send one
- Watch for UAs claiming to be Internet Explorer 6 on modern systems — IE6 is long dead and often used as a default C2 string or is a spoofing attempt
- User-Agent anomaly detection works best as a baseline-and- deviation approach: profile normal UAs for your environment, alert on new or rare ones rather than fixed blocklists