Skip to content
Tech News
← Back to articles

Why Cloudflare rule order matters?

read original get Cloudflare Firewall Rules Kit → more articles
Why This Matters

This article highlights the critical importance of rule order in Cloudflare's security configurations, emphasizing how improper sequencing can lead to security bypasses. For both developers and security professionals, understanding the impact of terminating actions ensures more effective protection against threats and unauthorized access. Proper rule ordering is essential for maintaining the integrity and security of web applications in the cloud environment.

Key Takeaways

Before jumping into this article please take a look at the following Cloudflare ruleset and think for a while what is wrong with it?

I set up above rules and thought they would work like the following:

From the first glance it seems perfectly fine. Website administrator wants to challenge users opening the website to prevent bot traffic. Additionally he specifies a rule that blocks access to /metrics endpoint to prevent unauthorized access to Prometheus metrics. I was surprised when I enabled both rules and the this happened:

What is going on here?! The Block rule was never executed and anyone could access my precious /metrics endpoint! Let me explain what is going on. Cloudflare rules language consists of several Actions. Action is a result of a matching rule. As for now, for custom security rules the following actions are allowed:

Interactive Challenge

JS Challenge

Managed Challenge

Block

Skip

Log

... continue reading