An HR portal behind Cloudflare Access trusted every request that reached it, and an audit found requests that never passed Access; how did they arrive, and what closes each path?
answer
- the origin is the last check
- direct IP and DNS-only records
- hostnames and paths no application covers
- unsigned identity headers
- verify the JWT, or Protect with Access
basics
~20 sThey reached the origin directly by IP, or through a hostname, path or Bypass policy no Access application enforced, and the origin trusted headers instead of the JWT. Verify Cf-Access-Jwt-Assertion against the HR AUD tag, then close each route.
solid answer
~50 sThe origin treated "it reached me" as "Access approved it", so any route around the Access application worked. Typical routes: the origin's IP answering the internet directly, found through a DNS-only record or old DNS history; a new hostname, such as a staging copy, with no Access application; a more specific path application or a Bypass policy that switched enforcement off for part of the portal; a tunnel route published before its Access application existed. The fix starts at the origin: reject any request whose `Cf-Access-Jwt-Assertion` does not verify against the team domain's keys and the HR application's AUD tag, in code or with cloudflared's Protect with Access. Then close the routes: lock the origin down, review every Bypass policy, and turn on Block traffic to all domains in this account so an uncovered hostname gets Error 1050.
code
yaml · 10 linesingress:
- hostname: hr.example.com
service: http://localhost:8080
originRequest:
access:
required: true
teamName: example-team
audTag:
- <hr-application-aud-tag>
- service: http_status:404go deeper
Remember that Access protects only requests that go through it to a covered hostname and path, so the origin must check the JWT itself.
List the routes around Access: direct IP, uncovered hostnames, path carve-outs, early tunnel routes and trusted headers, and the setting or check that closes each.
Diagnose from logs which route was used, explain why an IP allowlist does not prove the request passed the HR application, and fix it with a JWT check carrying the AUD tag.
Make account-wide deny-by-default, reviewed Bypass policies and mandatory origin verification the standard, so a new hostname or path cannot quietly go public.
## Why the origin is the last check Access can refuse only the requests that pass through Cloudflare **and** match an Access application's hostname and path. Everything else, whether a request to the origin's IP or to a hostname nobody protected, never meets a policy. An origin that serves whatever reaches it has made its security depend on every one of those routes being closed, forever. Cloudflare's guidance is that the origin validates the application token so that requests that bypass Access, for example through a network misconfiguration, are rejected. ## The routes around Access | Route | How it shows up | What closes it | |---|---|---| | Direct to the origin's IP | Origin logs show requests with no `Cf-Access-Jwt-Assertion`, from addresses outside Cloudflare | JWT check at the origin; lock the origin down or publish it only through a tunnel | | Through Cloudflare, but not through the HR application | Requests come from Cloudflare addresses yet carry no valid HR token | JWT check with the HR AUD tag; a Cloudflare IP allowlist alone cannot tell these apart | | A hostname with no Access application, such as `hr-staging.example.com` | Nothing in Access logs for that hostname | Block traffic to all domains in this account; an application per hostname | | A path carve-out | A more specific path application, or a Bypass policy, governs part of the portal | Review path applications and Bypass policies; use Service Auth for machines | | A tunnel route published before its Access application | The hostname answered anyone until the application was created | Create the Access application first; Protect with Access on the route | | Trusted identity headers | The origin read `Cf-Access-Authenticated-User-Email` without verifying the JWT | Take identity only from verified token claims | Two of these deserve a closer look. **Path precedence.** When applications exist for `hr.example.com` and `hr.example.com/api/*`, the more specific one decides requests under `/api/`, and it inherits nothing from the parent. A team that added a path application with a Bypass policy for a quick integration test has made that whole path public, and Bypass does not log, so the Access logs show nothing. **Allowlists prove the network, not the application.** Cloudflare's IP ranges, like the global Authenticated Origin Pulls certificate, which Cloudflare shares across all accounts, prove only that a request came from Cloudflare's network. They do not prove it passed your Access application. The JWT does, because it is signed with your account's key and names the HR application in `aud`. ## Confirming it in the logs 1. Make the origin log, for every request, whether `Cf-Access-Jwt-Assertion` was present and whether it verified, with the rejection reason. 2. Compare that with Access authentication logs for the HR application: requests the origin served that Access never saw are the leak. 3. List every application on the zone with its paths, and every Bypass policy, because a Bypass leaves no Access log entry to find. 4. Check the DNS records for the HR hostnames and for any DNS-only record that names the origin's address. ## Closing the routes - **Verify the token at the origin**: signature against the keys at the team domain's `/cdn-cgi/access/certs`, `iss` equal to the team domain, `aud` containing the HR AUD tag, `exp` in the future. Answer 403 otherwise. - **Or let cloudflared verify it**: on a tunnel route, Protect with Access, or an `access` block with `required: true`, `teamName` and `audTag` under `originRequest`, refuses requests without a valid token before they reach the portal. It covers only tunnel traffic, so close any other listener. - **Lock the origin down**: no public listener, or one reachable only from Cloudflare. That is the origin lockdown material; it narrows the routes but does not replace the JWT check. - **Turn on Block traffic to all domains in this account**: any hostname without an Access application gets a block page with `Error 1050: This resource is blocked by this account's Default-Deny policy.` Keep a short, owned **Hostnames to Exempt** list for public sites, and give each of those sites an application with an Allow or Bypass policy before turning the setting on. - **Treat Bypass as a reviewed change** and replace machine Bypasses with Service Auth. - **Create the Access application before publishing a tunnel route**, never after.
- Is allowlisting Cloudflare's IP ranges at the origin enough?No. It stops requests straight to the origin's IP, but it proves only that a request came through Cloudflare's network, not that it passed the HR Access application. Only the JWT, signed with your account's key and carrying the HR AUD tag, proves that, so the allowlist narrows the routes while the token check closes them.
- How do you find which requests skipped Access?Log at the origin whether each request carried a `Cf-Access-Jwt-Assertion` that verified, then compare with Access authentication logs for the HR application. Because Bypass requests are not logged by Access, also list every Bypass policy and every path-specific application on the HR hostnames.
- What does Block traffic to all domains in this account change?It makes Access deny by default across the account: a hostname with no Access application gets Error 1050 from the Default-Deny policy. Public sites need an application with an Allow or Bypass policy, or a place on Hostnames to Exempt, before the setting goes on, or they go dark.
A staffed front gate means little if the loading dock is unlocked and the office trusts anyone wearing a lanyard. Checking the lanyard's hologram at the office door, the JWT check, catches people whichever door they used.
- If DNS points at Cloudflare, nothing can reach the origin except through Access.
- Allowlisting Cloudflare's IP ranges proves a request passed our Access application.
- Cf-Access-Authenticated-User-Email is safe to trust on its own because Access sets it.
- A path-specific Access application inherits the parent application's policies.
- Publishing the tunnel route first and adding Access a day later is harmless.