Client-Side Script Monitoring, Malicious Detection, Alerts, and Rules
How third-party script monitoring works, what plans include, how to read alerts and malicious scores, and how to verify scripts on your site.
This page summarizes Cloudflare client-side security documentation (formerly Page Shield): visibility into scripts, outbound connections, and cookies in visitors’ browsers, detection of supply-chain and Magecart-style threats, and optional enforcement through content security rules.
What client-side security monitors and why sites use it
Section titled “What client-side security monitors and why sites use it”Client-side security exists because pages load third-party JavaScript for analytics, ads, chat, and payments. If one of those dependencies is compromised, attackers can steal data in the browser—a client-side supply chain attack.
Ensures the safety and privacy of your website visitors’ browsing environment.
— Cloudflare, Client-side security
It monitors scripts, connections, and cookies, sends alerts when resources change or look malicious, and lets you define content security rules to allow only approved resources. HTTPS protects data in transit, but injected or compromised scripts can still exfiltrate data from the browser; monitoring addresses that gap (encrypt-all use case).
Architecture documentation describes the same problem in terms of Magecart-style skimming: compromised libraries or site code sending sensitive data to attacker-controlled endpoints. Client-side security uses Cloudflare’s reverse-proxy position to learn from the browser what JavaScript loads, which connections are made, and which cookies the application uses (security architecture).
How resource monitoring works: CSP report-only headers
Section titled “How resource monitoring works: CSP report-only headers”Client-side security works by adding Content Security Policy (CSP) HTTP headers to site responses. CSP is a browser mechanism that controls what a page may load and where violation reports go.
Client-side security works by adding Content Security Policy (CSP) HTTP headers to your site’s responses.
— Cloudflare, How client-side security works
For resource monitoring, Cloudflare adds a content-security-policy-report-only header to a sample of HTML responses. That header does not block anything; it causes browsers to report scripts and connections. From those reports, Cloudflare builds inventories of scripts, third-party connections, and cookies (including cookies seen in HTTP traffic). You cannot disable the monitoring header while monitoring is on, and there may be a short delay before new scripts or cookies appear in the dashboard (how it works).
A separate CSP path supports content security rules (enforcement or logging violations). Reports from browser extensions are filtered out so dashboards focus on application dependencies (release notes).
Plan availability: monitoring, detection, alerts, and rules
Section titled “Plan availability: monitoring, detection, alerts, and rules”Core script monitoring is available on all plans (availability). Higher tiers add connection and cookie monitoring, page attribution, new-resource alerts, and Advanced-only capabilities.
| Capability | Free / Pro | Business / Enterprise | Client-Side Security Advanced |
|---|---|---|---|
| Script monitoring | Yes | Yes | Yes |
| Connection & cookie monitoring | No | Yes | Yes |
| New resource / new domain alerts | No | Yes (Business+) | Yes |
| Malicious script, code-change, malicious connection alerts | No | No | Yes |
| Malicious script detection (ML + threat feeds) | No | No | Yes |
| Content security rules (positive blocking) | 0 rules | 0 rules | 5 rules |
Domain-based threat intelligence is available to all customers. Malicious script detection and malicious URL checks require Client-Side Security Advanced.
— Cloudflare, Malicious script and connection detection
The Page Shield add-on is now named Client-Side Security Advanced; entitlements are unchanged (client-side security overview). API routes still use the page_shield path segment; script_monitor was replaced by page_shield in API routes (API deprecations).
Turn on Continuous script monitoring in the dashboard
Section titled “Turn on Continuous script monitoring in the dashboard”To start collecting script (and plan-dependent connection/cookie) data:
- In the Cloudflare dashboard, open the Security settings page and filter by Client-side abuse if needed.
- Under Continuous script monitoring, turn monitoring On (get started).
- Open Web assets → Client-side resources and review scripts; unknown entries warrant investigation (troubleshooting).
- Optionally configure Data processing to log only the connection host or the full URI (configuration settings)—full URI enables malicious URL checks on connections but may log sensitive query data in clear text.
Roles that can access the product in the dashboard include Administrator, Page Shield, and Domain Page Shield variants (roles and permissions).
Turning monitoring off removes visibility into scripts, connections, and cookies; content security rules stay enabled until you disable each rule separately (configuration settings).
Malicious script and connection detection: three mechanisms
Section titled “Malicious script and connection detection: three mechanisms”Cloudflare uses complementary checks at code, URL, and domain levels (malicious script and connection detection):
Malicious code analysis and JS integrity score
Section titled “Malicious code analysis and JS integrity score”For Advanced customers, Cloudflare downloads JavaScript and scores it with machine learning (including an LLM step on Workers AI to reduce false positives). Scores run from 1 (definitely malicious) to 99 (definitely not). Scripts scoring below 10 are classified as malicious in the dashboard. Separate scores cover Magecart, crypto mining, and malware patterns. The classifier currently runs only on scripts up to 300 KB—threat-intelligence signals remain important for larger files.
Malicious URL and malicious domain checks
Section titled “Malicious URL and malicious domain checks”Script URLs and domains are checked against threat intelligence feeds. Connection targets use domain checks by default; malicious URL checks on outbound connections require configuring monitoring to use the full URI (malicious script and connection detection).
Threat categories include Malware, Phishing, Spyware, crypto mining, C2 and botnet, DGA domains, and typosquatting. A resource can have multiple categories. Feed updates re-check previously seen scripts and connections.
The API does not return a literal “malicious” flag; compare js_integrity_score to the same 10 threshold (client-side security API).
Script and connection statuses: Active, Infrequent, and Inactive
Section titled “Script and connection statuses: Active, Infrequent, and Inactive”Statuses depend on report volume and malice flags (script and connection statuses):
- Active: more than three reports; shown on main monitoring views.
- Infrequent: fewer than three reports; only on “All Reported” views; deleted after five days with no reports.
- Inactive: no reports for seven days while previously active; deleted after 30 days without reports.
Malicious resources still appear on monitoring dashboards regardless of status. Default API list endpoints return active resources unless you pass a status filter (for example status=infrequent) (client-side security API). Malicious resource alerts include only resources with Active status (alert types).
Alerts: unscoped vs scoped and malicious resource types
Section titled “Alerts: unscoped vs scoped and malicious resource types”After resource monitoring is active, you can configure one or more alerts (Alerts):
| Alert style | Scope | Timing |
|---|---|---|
| Unscoped | All zones in the account | Daily, hourly, or immediate (by alert type) |
| Scoped | Selected zones with content security rules | Immediate; only resources covered by rules (rule violations do not fire these) |
New resource alerts need a Business plan or higher. Code change and malicious resource alerts need Client-Side Security Advanced (Alerts).
Malicious domain, URL, and script alerts
Section titled “Malicious domain, URL, and script alerts”Advanced malicious resource alerts cover:
- New Malicious Domain Alert — script from a known malicious domain.
- New Malicious URL Alert — script from a known malicious URL.
- New Malicious Script Alert — JavaScript classified as malicious by Cloudflare.
Recommended response: review the client-side security dashboard entry, then update pages where the resource was detected (alert types). For interval-based alerts, expect delay between deploying a script and receiving notification.
Code change detection (Advanced) hashes each script’s AST structure; formatting-only edits may not alert. Notifications can be daily (review changed scripts).
Best-practice flows: handle a client-side resource alert and deploy content security rules in production (best practices).
Investigate a malicious script alert without false assumptions
Section titled “Investigate a malicious script alert without false assumptions”When an alert fires, use the linked dashboard resource or search Web assets → Scripts or Connections (handle an alert).
Confirm the resource on a real page load
Section titled “Confirm the resource on a real page load”Open a URL from Page URLs in the resource details, then use browser developer tools Network to confirm the script or connection. If nothing appears, the load may be conditional, geo-specific, extension-injected, or served to only some visitors—still investigate via codebase search and safe external lookups (handle an alert).
Read Malicious code, Malicious URL, and Malicious domain fields
Section titled “Read Malicious code, Malicious URL, and Malicious domain fields”Multiple mechanisms flagging the same script increases confidence it is not a false positive. Domain and URL hits align with threat feeds; malicious code may not be reproducible in third-party scanners because the ML model is Cloudflare-specific (handle an alert).
If the script is present, served from a bad host, or contains suspicious obfuscated destinations, treat it as a possible active compromise (handle an alert). For dashboard review steps, see review resources considered malicious.
Client-side security API: settings, inventories, and policies
Section titled “Client-side security API: settings, inventories, and policies”The client-side security API attaches to https://api.cloudflare.com/client/v4 with zone, script, connection, and cookie IDs from list operations. It can enable monitoring, read settings, list scripts/connections/cookies, and manage content security rules at zones/{zone_id}/page_shield/....
Example: read whether monitoring is enabled:
curl "https://api.cloudflare.com/client/v4/zones/$ZONE_ID/page_shield" \ --request GET \ --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"Enable monitoring with PUT and "enabled": true. Tokens need Client-side security or legacy Page Shield permissions (roles and permissions).
PCI DSS v4 client-side requirements
Section titled “PCI DSS v4 client-side requirements”PCI DSS v4 adds browser-side obligations on payment pages: inventory authorized scripts with integrity checks (6.4.3) and detect unauthorized changes to headers and payment content (11.6.1). Cloudflare maps these to client-side security; meeting them requires Client-Side Security Advanced (PCI DSS reference, compliance table).
Common mistakes when reading monitoring data
Section titled “Common mistakes when reading monitoring data”- Assuming every unfamiliar script is an attack—libraries often pull in other scripts, but unexpected domains still need review (troubleshooting).
- Treating dashboard Hash as Subresource Integrity (SRI); content security rules use SRI content hashes, not the internal version hash (monitor resources and cookies).
- Enabling Log full URI without understanding that session IDs or tokens in connection URLs may appear in logs visible to dashboard users (configuration settings).
- Relying only on the ML classifier for files over 300 KB (malicious script and connection detection).
- Expecting instant inventory after enablement or after each deploy—sampling and report cadence introduce delay (how client-side security works).
How to check this on your site
Section titled “How to check this on your site”- Confirm Continuous script monitoring is on under Security settings → Client-side abuse and matches your plan entitlements.
- On Web assets → Client-side resources, filter by Status and review Active scripts; open Details for page URLs and (on Business+) attribution fields.
- If you use Advanced, sort malicious scripts and connections via review resources considered malicious and compare
js_integrity_scoreto threshold 10 when using the API. - After an alert, follow handle a client-side resource alert and verify loads in browser Network tools on the listed page URLs.
- You can check automatically in Answerwell (our tool): https://answerwell.org/workspace
Report an error or ask a question
Section titled “Report an error or ask a question”If something on this page does not match your dashboard or API responses, email yimasynthetic@gmail.com with the page URL and the exact statement you think is wrong so it can be corrected.