Rules changelog
Last updated Apr 16, 2026
2026-10-14
Remove surrounding bytes with trim functions
Cloudflare Rules supports three new functions for removing surrounding bytes. Use them to remove whitespace before comparing request values. All HTTP products support these functions on all plans:
trim()removes bytes from both ends.trim_start()removes bytes from the start.trim_end()removes bytes from the end.
By default, these functions remove ASCII whitespace. An optional constant string specifies a custom set of bytes.
If the input value is nil, these functions return nil.
For example, this expression removes surrounding whitespace before comparing a header value:
trim(http.request.headers["x-label"][0]) eq "approved"
For details, refer to the trim(), trim_start(), and trim_end() function references.
2026-10-09
Failed detections field available in Rules
You can now use cf.appsec.request.failed_detections to control how your rules handle requests when a security detection reports a failure.
The field is an Array<String> of detection IDs that reports failures from content scanning, WAF attack score, attack signature detection, leaked credentials detection, and AI prompt detections for personally identifiable information (PII), prompt injection, custom topics, and unsafe topics.
The field does not alter the existing behavior of detections. Use it in rules to choose how to handle requests with reported failures.
When no failures are reported, the field returns []. You can use it on all plans, but your plan must still include the detections and rule features you want to use.
Supported rules:
- Custom rules at the zone and account levels
- Rate limiting rules at the zone and account levels
- Request Header Transform Rules at the zone level
Match any reported failure:
len(cf.appsec.request.failed_detections) gt 0
Match a reported leaked credentials detection failure:
any(cf.appsec.request.failed_detections[*] eq "waf_credential_check")
For more information, refer to the Failed detections field reference.
2026-10-02
hash_in_range() is globally available for HTTP products
hash_in_range() is globally available for HTTP products on all plans. It hashes fields into an integer within a specified range. Use this result to select a portion of requests.
Use cf.random_seed to select approximately 10% of requests at random:
hash_in_range(0, 100, cf.random_seed) < 10
With Cloudflare for SaaS, use custom metadata to control rollout progression. Define rollout_pct as a custom key for each hostname. Set its value to an integer from 0 to 100. The expression selects approximately that percentage of requests:
hash_in_range(0, 100, cf.random_seed) < coalesce(lookup_json_integer(cf.hostname.metadata, "rollout_pct"), 0)
If rollout_pct is missing, coalesce() supplies 0. The rule then matches no requests.
For details, refer to the hash_in_range() function reference.
2026-10-01
Handle missing values with coalesce()
The coalesce() function returns the first argument that is not nil. Use it to provide a fallback in rule expressions:
http.request.uri.path eq coalesce(http.request.uri.args["expected_path"][0], "/")
For details, refer to the coalesce() function reference.
2026-10-01
Compare dynamic values in Rules expressions
Cloudflare Rules expressions now support dynamic values on both sides of equality and ordering comparisons. You can compare request fields or function results with one another.
For example, compare the current request path with its original value:
http.request.uri.path ne raw.http.request.uri.path
For supported operators and examples, refer to Compare dynamic values.
2026-09-30
Longer rule descriptions in logs
Cloudflare logs now include up to 128 bytes of a rule description, increased from 80 bytes. Longer descriptions provide more context when investigating matched rules and make it easier to identify the relevant rule without referring back to its configuration.
Descriptions longer than 128 bytes are truncated without splitting a UTF-8 character. This change does not affect the Rulesets API, which continues to accept rule descriptions of up to 4,096 bytes.
For more information, refer to Rule object structure and properties.
2026-09-22
concat() now supports up to 32 arguments
The concat() function in Cloudflare Rules now accepts up to 32 arguments, increased from 16. This allows you to build richer dynamic values directly in Rules expressions and simplify configurations that combine request data.
A common use case is adding a request header that sends context to your origin. The following Rulesets API request adds a Request Header Transform Rule to an existing http_request_late_transform phase ruleset. Its 18-argument expression combines request and network information into one header value:
curl --request POST \
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets/$RULESET_ID/rules" \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"ref": "add_request_context_header",
"description": "Add request context for the origin",
"expression": "true",
"action": "rewrite",
"action_parameters": {
"headers": {
"X-Request-Context": {
"operation": "set",
"expression": "concat(\"ip=\", to_string(ip.src), \";country=\", ip.src.country, \";host=\", http.host, \";method=\", http.request.method, \";path=\", http.request.uri.path, \";query=\", http.request.uri.query, \";ray-id=\", cf.ray_id, \";asn=\", to_string(ip.src.asnum), \";user-agent=\", http.user_agent)"
}
}
}
}'
For more information, refer to the concat() function reference and HTTP request header modification.
2026-09-17
Validate Rulesets changes before deployment
Cloudflare Rules now validates ruleset changes before deployment, helping you catch invalid expressions, action parameters, permission issues, unavailable features, and quota limits without publishing the configuration.
The Cloudflare dashboard performs this validation automatically when you create or update rules from Security > Security rules or Rules > Overview.
Supported Rulesets API mutation endpoints now also accept the dry_run=true query parameter. A dry run performs the same authorization and server-side validation checks as the requested change, but does not persist or publish it. Successful operations that normally return a 200 response return result: null. Operations that normally return 204 continue to do so.
API example
Add dry_run=true to a Rulesets API request to validate it without creating the ruleset:
curl --request POST \
"https://api.cloudflare.com/client/v4/zones/$ZONE_ID/rulesets?dry_run=true" \
--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
--header "Content-Type: application/json" \
--data '{
"name": "Custom firewall rules",
"kind": "zone",
"phase": "http_request_firewall_custom",
"rules": [
{
"action": "block",
"expression": "ip.src.country eq \"GB\"",
"description": "Block requests from the United Kingdom",
"enabled": true
}
]
}'
For more information, refer to Validate rule changes before deployment.
2026-08-13
Oracle Cloud Infrastructure Object Storage support in Cloud Connector
Cloud Connector now supports public Oracle Cloud Infrastructure (OCI) Object Storage buckets. You can route matching requests to OCI without managing a separate origin-routing configuration.
OCI support uses the Amazon S3 Compatibility API. Both path-style and virtual-hosted endpoint formats are supported, including traditional oraclecloud.com and dedicated customer-oci.com path-style endpoints.
Public buckets only
Cloud Connector does not sign requests or provide OCI credentials. Your bucket must allow anonymous object reads. Private buckets and pre-authenticated request URLs are not supported.
API example
Set provider to oci_storage and provide a supported OCI hostname. The following rule uses a virtual-hosted endpoint:
{
"expression": "http.request.uri.path wildcard \"/assets/*\"",
"provider": "oci_storage",
"description": "Route assets to OCI Object Storage",
"enabled": true,
"parameters": {
"host": "<BUCKET_NAME>.vhcompat.objectstorage.<REGION>.oci.customer-oci.com"
}
}
For endpoint formats and bucket requirements, refer to Supported cloud providers in Cloud Connector.
2026-07-16
Bot management fields and ASN support in Cache Rules
Bot management fields and ASN support in Cache Rules
Cache Rules now supports bot management fields and the ip.src.asnum field in expression filters. You can now build cache policies that differentiate between automated and human traffic, or segment caching behavior by autonomous system number (ASN).
This allows you to apply different caching strategies for verified bots, high-risk traffic, or specific network operators without affecting legitimate user requests. For example, you can set shorter cache TTLs for suspected bot traffic or bypass cache entirely for requests from specific ASNs.
New fields
The following fields are now available in Cache Rules expressions:
| Field | Type | Description |
|---|---|---|
cf.bot_management.score |
Number | Bot score from 1 to 99, where a lower value indicates a higher likelihood that the request originates from a bot. |
cf.bot_management.ja3_hash |
String | JA3 fingerprint of the request, which helps identify the client making the connection. |
cf.bot_management.ja4 |
String | JA4 fingerprint of the request, which provides a more detailed client identification than JA3. |
cf.bot_management.verified_bot |
Boolean | Whether the request originates from a verified bot, such as a search engine crawler. |
cf.bot_management.static_resource |
Boolean | Whether the request is for a static resource and therefore exempt from bot detection. |
cf.bot_management.js_detection.passed |
Boolean | Whether the browser passed JavaScript detection when the feature is enabled. |
cf.bot_management.detection_ids |
Array\<Number> | List of IDs that correspond to Bot Management heuristic detections made on the request. |
cf.bot_management.tags |
Array\<String> | List of tags associated with the bot traffic, such as API, GOOGLE, or BING. Match a tag with an expression such as any(cf.bot_management.tags[*] eq "API"). |
cf.bot_management.signed_agent |
Boolean | Whether the request originates from a known agent that identifies itself with Web Bot Auth. |
cf.bot_management.corporate_proxy |
Boolean | Whether the request originates from a known corporate proxy. |
ip.src.asnum |
Number | The autonomous system number (ASN) of the incoming request's IP address. |
Note
Bot management fields require a Bot Management subscription. ip.src.asnum is available on all plans.
Example
Cache Rules expressions support combining these fields with other criteria. The following example sets a shorter cache TTL for API requests that originate from a high-risk bot or an unexpected ASN:
(http.request.uri.path contains "/api/" and cf.bot_management.score lt 30)
or
(http.request.uri.path contains "/api/" and not ip.src.asnum in {12345 67890})
To learn more, refer to the Cache Rules documentation and the Fields reference.
2026-04-01
New QUIC RTT and delivery rate fields
Two new fields are now available in rule expressions that surface Layer 4 transport telemetry from the client connection. Together with the existing cf.timings.client_tcp_rtt_msec field, these fields give you a complete picture of connection quality for both TCP and QUIC traffic — enabling transport-aware rules without requiring any client-side changes.
Previously, QUIC RTT and delivery rate data was only available via the Server-Timing: cfL4 response header. These new fields make the same data available directly in rule expressions, so you can use them in Transform Rules, WAF Custom Rules, and other phases that support dynamic fields.
New fields
| Field | Type | Description |
|---|---|---|
cf.timings.client_quic_rtt_msec |
Integer | The smoothed QUIC round-trip time (RTT) between Cloudflare and the client in milliseconds. Only populated for QUIC (HTTP/3) connections. Returns 0 for TCP connections. |
cf.edge.l4.delivery_rate |
Integer | The most recent data delivery rate estimate for the client connection, in bytes per second. Returns 0 when L4 statistics are not available for the request. |
Example: Route slow connections to a lightweight origin
Use a request header transform rule to tag requests from high-latency connections, so your origin can serve a lighter page variant:
Rule expression:
cf.timings.client_tcp_rtt_msec > 200 or cf.timings.client_quic_rtt_msec > 200
Header modifications:
| Operation | Header name | Value |
|---|---|---|
| Set | X-High-Latency |
true |
Example: Match low-bandwidth connections
cf.edge.l4.delivery_rate > 0 and cf.edge.l4.delivery_rate < 100000
For more information, refer to Request Header Transform Rules and the fields reference.
2026-03-25
New mTLS certificate fields for Transform Rules
Cloudflare now exposes four new fields in the Transform Rules phase that encode client certificate data in RFC 9440 ↗︎ format. Previously, forwarding client certificate information to your origin required custom parsing of PEM-encoded fields or non-standard HTTP header formats. These new fields produce output in the standardized Client-Cert and Client-Cert-Chain header format defined by RFC 9440, so your origin can consume them directly without any additional decoding logic.
Each certificate is DER-encoded, Base64-encoded, and wrapped in colons. For example, :MIIDsT...Vw==:. A chain of intermediates is expressed as a comma-separated list of such values.
New fields
| Field | Type | Description |
|---|---|---|
cf.tls_client_auth.cert_rfc9440 |
String | The client leaf certificate in RFC 9440 format. Empty if no client certificate was presented. |
cf.tls_client_auth.cert_rfc9440_too_large |
Boolean | true if the leaf certificate exceeded 10 KB and was omitted. In practice this will almost always be false. |
cf.tls_client_auth.cert_chain_rfc9440 |
String | The intermediate certificate chain in RFC 9440 format as a comma-separated list. Empty if no intermediate certificates were sent or if the chain exceeded 16 KB. |
cf.tls_client_auth.cert_chain_rfc9440_too_large |
Boolean | true if the intermediate chain exceeded 16 KB and was omitted. |
The chain encoding follows the same ordering as the TLS handshake: the certificate closest to the leaf appears first, working up toward the trust anchor. The root certificate is not included.
Example: Forwarding client certificate headers to your origin server
Add a request header transform rule to set the Client-Cert and Client-Cert-Chain headers on requests forwarded to your origin server. For example, to forward headers for verified, non-revoked certificates:
Rule expression:
cf.tls_client_auth.cert_verified and not cf.tls_client_auth.cert_revoked
Header modifications:
| Operation | Header name | Value |
|---|---|---|
| Set | Client-Cert |
cf.tls_client_auth.cert_rfc9440 |
| Set | Client-Cert-Chain |
cf.tls_client_auth.cert_chain_rfc9440 |
