Acme Corp Cloudflare Cloud Workload Security demo

Demo library › Chapter 4

Guardrails for the Cloudflare API

ReadyCI pipeline~6 minCloud Workload SecurityR2DNSCloudflare API

The same proxy and policy model, protecting changes to Cloudflare itself - a public R2 bucket and an unproxied DNS record that would expose an origin - from the pipeline and from the exfiltration test.

The problem

Cloudflare is infrastructure too, and most customers change it from a pipeline with an API token. That token can turn on public access to an R2 bucket, or publish a DNS record that sends traffic straight to the origin - around the WAF, the DDoS protection and everything else in front of it.

Cloud Workload Security protects the Cloudflare API exactly as it protects AWS: same proxy, same policies, same evidence.

Lands with: anyone who manages Cloudflare as code - and every Cloudflare customer with a Terraform pipeline

Before you start

Run it

A public R2 bucket

DoSay
Edit infrastructure.json: set cloudflare.assets_bucket.public to true. Commit as Public assets bucket on r2.dev.The same kind of change as the S3 bucket, against Cloudflare: turn on public r2.dev access to the assets bucket.
Open the new pipeline's deploy-cloudflare job.Blocked, by a guardrail on the Cloudflare API. Same banner, same proxy, same identity as the AWS job.
Whybackground, if you are asked

cf-r2-no-public-access is the guardrail from the CWS get-started guide. Its filter selects exactly one Cloudflare API operation - application.service r2, operation r2-put-bucket-public-policy - so the Rego only has to read the body: valid if enabled is false.

An exposed origin

DoSay
Set public back to false, and set cloudflare.origin_record.proxied to false. Commit as DNS only for the origin.Now someone makes the origin record DNS-only - grey cloud. That publishes the origin's real address to anyone who looks it up.
Open deploy-cloudflare.The R2 change went through, and the unproxied record was blocked.
Set proxied back to true and commit.And proxied records are fine.
Whybackground, if you are asked

cf-dns-proxied-only is written the other way: its filter is plain HTTP - host api.cloudflare.com, a write method - and the Rego matches the dns_records path and reads type and proxied from the body. Two styles, both supported: a precise operation filter when the Action Mapper knows the operation, HTTP when you want to write the rule yourself.

The same, outside the pipeline

DoSay
Open the exfiltration test, choose Straight to AWS and run it.The test also tries both Cloudflare changes against this lab's account - and without CWS, both go through. It undoes them straight away.
Click Run it through Cloudflare CWS → and scroll to Cloudflare API.Through CWS, both blocked.

What the audience should see

Where the evidence is

Proxy decisions: denied requests to api.cloudflare.com, from ci-pipeline and from workstation. And Cloudflare's own audit log - Manage Account → Audit Log - which shows the changes that the bypass run made, and none of the blocked ones.

Known limitations

These run against this lab's real Cloudflare account. The pipeline leaves the bucket and the record as infrastructure.json says; the exfiltration test always reverts its own changes. Both need R2 enabled on the account.

Part of: Cloud Workload Security in 20 minutes · Guardrails for every pipeline