Skip to main content

What is a User Agent?

The User-Agent string tells servers what software is making the request - browser, app, bot, or tool. It’s like an ID badge that describes the client’s identity.
MDN Web DocsRead more on User-Agent.

Anatomy of a User-Agent String

Breaking this down:
  • Mozilla/5.0 - Historical compatibility token
  • Windows NT 10.0; Win64; x64 - Operating system
  • AppleWebKit/537.36 - Rendering engine
  • Chrome/91.0.4472.124 - Browser and version
  • Safari/537.36 - Compatibility indicator

Common User-Agent Types

Legitimate Browsers

Mobile Apps

Bots & Crawlers

Automated Tools

Using User-Agent in Policies

Esper supports string matching on User-Agent values with:
  • equals
  • not equals
  • contains
  • starts with
  • ends with

Basic Examples

Block known bad bots:
Detect automated tools:

Advanced Patterns

Require modern browsers:
API client validation:
Traffic Protection TipMany malicious bots use fake or outdated User-Agent strings. Look for inconsistencies like Chrome version 40 (from 2015) or misspellings.

Security Patterns

Empty or Missing User-Agents

Suspicious Patterns

Known Attack Tools

Best Practices

DO:

  • Check for empty/null - Many attacks omit User-Agent
  • Validate format - Real browsers have consistent patterns
  • Monitor changes - Sudden User-Agent switches are suspicious
  • Allow legitimate bots - Google, Bing need access for SEO
  • Log everything - User-Agents help with forensics
  • Update patterns - Browsers release new versions monthly

DON’T:

  • Trust blindly - User-Agents are easily spoofed
  • Block all bots - Some are necessary (search engines)
  • Use exact matching - Versions change frequently
  • Ignore mobile - Different patterns than desktop
  • Forget about apps - Native apps have custom User-Agents

Bot Management

Good Bots to Allow

Bad Bot Indicators

  • Generic: Mozilla/5.0 only
  • Outdated: Browser versions from years ago
  • Malformed: Missing expected components
  • Tools: Development/testing tools
  • Suspicious: Known attack signatures

User-Agent Consistency Checks

Session Validation

Browser Feature Validation

Mobile Detection

Identifying Mobile Traffic

Tablet vs Phone

Common Attack Patterns

User-Agent Injection

Crawler Pretending to be Browser

Troubleshooting

“Blocking real users”
  • Check for browser updates
  • Mobile apps might have custom strings
  • Browser extensions can modify User-Agent
  • Privacy tools randomize User-Agents
“Bots bypassing detection”
  • They might rotate User-Agents
  • Using real browser automation
  • Copying legitimate User-Agents
  • Need additional signals beyond User-Agent

Advanced Detection

Browser Fingerprinting

Combine User-Agent with:
  • JavaScript capabilities
  • Screen resolution
  • Timezone
  • Installed plugins
  • Canvas fingerprint

Behavioral Analysis

  • Headers - Modern browsers send additional identity headers
  • Client IP - Combine for stronger traffic protection
  • Request Path - Bots often hit specific paths
  • Referrer - Bots often lack proper referrers