mech.app

The mech.app newsletter

Agentic AI, minus the noise.

Get practical field notes on AI agents, automation, developer tools and security delivered to your inbox.

No spam. Unsubscribe anytime.

AI Agents

Cloudflare Precursor: Continuous Behavioral Validation for Agentic Detection

How Cloudflare's Precursor uses session-level client signals to distinguish human users from AI agents without breaking user flows or adding latency.

Source: blog.cloudflare.com
Cloudflare Precursor: Continuous Behavioral Validation for Agentic Detection

Cloudflare just shipped Precursor, a session-based behavioral validation engine that runs continuously across user journeys instead of relying on discrete challenge gates. The system injects JavaScript to collect client-side signals, processes them in real time, and feeds the results into Cloudflare’s bot scoring pipeline. The goal is to detect advanced automation and agentic workflows that can pass individual CAPTCHAs but betray themselves through session-level behavior patterns.

This matters because modern agents can execute JavaScript, use real browser environments, and mimic human interaction in short bursts. Traditional bot detection relies on point-in-time challenges at login or checkout. Precursor extends detection across the entire application flow, turning every page view and interaction into a signal.

How Precursor Collects Signals

Precursor uses dynamically injected JavaScript that runs in the background as users navigate your application. The script collects behavioral telemetry without requiring user interaction or adding visible friction. Signals include:

  • Mouse movement patterns and timing
  • Keyboard interaction cadence
  • Scroll behavior and viewport changes
  • Navigation flow and page transition timing
  • JavaScript execution environment characteristics

These signals are batched and sent to Cloudflare’s edge network, where they’re processed and incorporated into the bot score in real time. The system is designed to operate with minimal latency impact. Signal collection happens asynchronously, and the JavaScript payload is optimized to avoid blocking page rendering or user interactions.

Cloudflare runs this on top of their existing network visibility layer, which processes over 1 trillion requests per day. Precursor adds the client-side dimension to complement network-level reputation and anomaly detection.

State Management Across Sessions

Precursor tracks behavioral patterns across multi-step interactions using a session identifier that persists for the duration of the user journey. The system maintains state at the edge, allowing it to correlate signals from multiple page views and interactions without requiring server-side session storage on your origin.

State is keyed to the session token and includes:

  • Cumulative behavioral metrics (mouse entropy, interaction timing)
  • Sequence of pages visited and actions taken
  • Anomaly flags triggered during the session
  • Historical bot score trajectory

Session boundaries are defined by standard web session expiration rules (typically 30 minutes of inactivity) or explicit logout events. When a session expires, the accumulated state is archived for training and analysis but no longer affects real-time scoring.

The edge-based state model means Precursor can operate without adding database load to your origin servers. All signal aggregation and scoring happens in Cloudflare’s infrastructure.

Distinguishing Legitimate Automation

The hardest problem in behavioral detection is avoiding false positives for legitimate automation like accessibility tools, browser extensions, and power users with unusual interaction patterns. Precursor addresses this through a combination of allowlisting and behavioral profiling.

Cloudflare maintains a library of known accessibility tools and browser extensions that modify interaction patterns. These are fingerprinted and allowlisted at the detection layer. The system also learns normal variation in human behavior through continuous training on real traffic patterns.

For edge cases, Precursor provides tunable sensitivity controls:

  • Strict mode: Flags any deviation from typical human patterns
  • Balanced mode: Allows for accessibility tools and power users
  • Permissive mode: Focuses on obvious automation signatures

You can also define custom allowlists based on user agent, IP range, or authenticated user identity. This is critical for internal tools, QA automation, and partner integrations that need to bypass behavioral checks.

Architecture and Integration Points

Precursor sits between your application and Cloudflare’s existing bot management pipeline. The integration flow looks like this:

  1. User requests a page from your application
  2. Cloudflare injects Precursor JavaScript into the response
  3. Script collects behavioral signals as user interacts
  4. Signals are sent to Cloudflare edge for processing
  5. Bot score is updated in real time and made available to WAF rules
  6. Subsequent requests from the same session carry the updated score

The bot score is exposed as a standard Cloudflare field that you can use in WAF rules, rate limiting policies, or custom logic. You can block, challenge, or log requests based on score thresholds.

Precursor is an optional add-on to Cloudflare’s Enterprise Bot Management. It complements Turnstile (their managed challenge system) but operates independently. You can run Precursor across your entire application while reserving Turnstile for high-value endpoints like login and checkout.

Deployment Trade-offs

ConsiderationPrecursor ApproachTrade-off
LatencyAsynchronous signal collectionMinimal impact on page load, but requires JavaScript execution
PrivacyClient-side telemetry without PIIBehavioral fingerprinting may trigger privacy concerns in some jurisdictions
False positivesTunable sensitivity with allowlistsRequires ongoing tuning for edge cases and legitimate automation
CoverageEntire user journeyMore visibility but also more data to process and store
IntegrationJavaScript injection at edgeWorks with any web application but requires Cloudflare proxy

The biggest operational risk is false positives for power users and accessibility tools. You need to monitor flagged sessions and adjust sensitivity settings based on your traffic patterns. Cloudflare provides dashboards for this, but it still requires active management.

The second risk is privacy compliance. Behavioral telemetry falls into a gray area in some jurisdictions. You need to evaluate whether continuous behavioral tracking fits your privacy policy and consent model.

Example: WAF Rule Using Precursor Score

(cf.bot_management.score < 30) and 
(not cf.bot_management.verified_bot) and
(not http.cookie contains "auth_token")

This rule blocks traffic with a bot score below 30 unless the request comes from a verified bot (like Googlebot) or an authenticated user. You can layer additional logic based on request path, rate limiting, or geographic origin.

The bot score updates continuously as Precursor collects signals, so a session that starts with a neutral score can be downgraded if behavioral anomalies emerge during the user journey.

Observability and Debugging

Precursor exposes session-level telemetry through Cloudflare’s analytics dashboard. You can view:

  • Bot score distribution across sessions
  • Behavioral anomaly flags triggered during each session
  • Session duration and page view count
  • Comparison of human vs. bot interaction patterns

For debugging, Cloudflare provides a test mode that logs all signal collection and scoring decisions without taking enforcement action. This lets you validate detection accuracy before enabling blocking or challenging.

You can also export raw telemetry to your own logging pipeline using Cloudflare Logpush. This is useful for training custom models or correlating behavioral signals with application-level events.

Likely Failure Modes

JavaScript disabled or blocked: Precursor requires JavaScript execution. If users disable JavaScript or run aggressive content blockers, signal collection fails and the session falls back to network-level detection only.

Session hijacking: If an attacker steals a session token after the legitimate user has built up a good behavioral score, the attacker inherits that score. Precursor doesn’t protect against session hijacking; you still need secure session management.

Adversarial adaptation: Sophisticated attackers can profile Precursor’s signal collection and train agents to mimic human behavioral patterns. This is an ongoing arms race. Cloudflare updates detection models continuously, but there’s no permanent solution.

Performance impact on low-end devices: Continuous signal collection adds CPU and memory overhead. On low-end mobile devices or slow connections, this can degrade user experience. You need to test on representative devices.

Technical Verdict

Use Precursor when:

  • You’re already on Cloudflare Enterprise Bot Management
  • You have high-value workflows (account creation, payments, content scraping) that attract sophisticated automation
  • You can tolerate some false positives and have resources to tune sensitivity settings
  • You need visibility into full user journeys, not just login or checkout

Avoid Precursor when:

  • You have strict privacy constraints that prohibit behavioral telemetry
  • Your user base includes a high percentage of accessibility tool users or power users with unusual interaction patterns
  • You’re not prepared to actively monitor and tune detection settings
  • Your application doesn’t require JavaScript (static sites, APIs, mobile apps)

Precursor is a detection primitive, not a complete solution. It gives you session-level behavioral signals that you can use in WAF rules, rate limiting, and custom logic. The value depends on how well you integrate it into your broader security posture and how much effort you invest in tuning.