- Enforce (SWG): Cloudflare Gateway blocks direct LLM access on enrolled devices, forcing agents and users through the governed path.
- Observe (CASB): Cloudflare Logpush streams Gateway DNS logs into Inviolet, so bypass volume and per-user attribution show up in the product.
Everything below was validated live against a real Cloudflare Zero Trust
account. Where Cloudflare behaves differently than you’d expect (e.g. it can’t
match request headers), that’s called out — those are the lessons that shaped
this setup.
Prerequisites
- A Cloudflare Zero Trust account (one.dash.cloudflare.com) — the free plan (≤50 seats) is enough.
- The Cloudflare One / WARP client on the machines whose LLM traffic you want governed — agent hosts (for API bypass) and user endpoints (for the browser/UI case). Gateway only sees traffic from enrolled devices.
- For enrollment: a device-enrollment policy (Settings → WARP Client → Device enrollment permissions → add an Allow rule for your users/emails). A fresh org has none, and enrollment fails with “Enrollment request is invalid” until you add one.
Part A — Enforcement (Cloudflare Gateway)
Why DNS-layer, domain-based blocking
Two findings from live testing shaped this, and they’re worth knowing so the rules make sense:- Gateway can’t match a request header. The natural idea — “block LLM API
calls missing the
X-Inviolet-Fingerprintheader” — fails: Gateway’s filter engine has nohttp.request.headersfield (applyreturns “unknown field”). And without TLS inspection, HTTP policies don’t evaluate HTTPS at all. - LLM traffic sprawls across subdomains —
api./cdn./auth.openai.com,a-api.anthropic.com,oaistatic.com,oaistatsig.com, … An exact-hostname list misses most of it.
The two rules
- Block direct LLM API access — DNS-block the LLM API domains (
openai.com,anthropic.com, …). Because Gateway fronts the agent’s egress (not Inviolet’s), this stops agents from calling the API directly and forces them through Inviolet; Inviolet’s own mediated calls resolve from Inviolet’s infra and are unaffected. - Block consumer UIs — DNS-block
chatgpt.com,claude.ai,gemini.google.com,copilot.microsoft.com, so humans can’t use ungoverned web UIs.
Deploy — terraform (recommended)
Use theinviolet-swg-cloudflare module. Start in log-only mode so you can
confirm the rules fire before anything is blocked:
dash.cloudflare.com/<account-id>)
or the Account Home sidebar. You’ll need a Cloudflare API token in
CLOUDFLARE_API_TOKEN with Account → Zero Trust → Edit (create it at
My Profile → API Tokens → Create Custom Token).
Deploy — dashboard (alternative)
Zero Trust → Gateway → Firewall policies → create two DNS policies: Action Block (or Allow to log-only), matching the LLM domains and the consumer-UI domains respectively. Or match Cloudflare’s built-in “Artificial Intelligence” application category (auto-maintained).Verify
- Connect WARP on a test device.
- Generate traffic — open
chatgpt.com, orcurl https://api.openai.com. - Zero Trust → Logs → Gateway → DNS query logs, filter for
openai. - You should see the query with Policy =
Inviolet-block-direct-llm-apiand the user’s email. Inallowmode the query is matched but permitted (logged, not blocked) — proof the rule catches the right traffic before you enforce.
Part B — Observability (Cloudflare → Inviolet)
To make Inviolet see the traffic (bypass volume + attribution), get the Gateway DNS logs in. How depends on your Cloudflare plan:Enterprise — Logpush
Cloudflare pushes NDJSON log batches to an Inviolet endpoint (not a polling connector, since there’s no pull API).1. The Inviolet endpoint
Inviolet exposes an ingestion endpoint:org— your Inviolet organization id.<SECRET>— the shared value set asCLOUDFLARE_LOGPUSH_SECRETon the Inviolet side. Cloudflare Logpush stripsheader_*query params and re-sends them as HTTP headers, so this becomes the bearer auth the endpoint checks.
2. Create the Logpush job
Zero Trust → Logs → Logpush → Add a Logpush job:- Dataset: Gateway DNS
- Destination: HTTP → paste the endpoint URL above
- Cloudflare runs an ownership challenge against the endpoint — it validates automatically.
- Fields:
Datetime, QueryName, Email, DeviceName, DeviceID, SrcIP, ResolverDecision, MatchedPolicyName - Format: NDJSON · Enable
3. Verify
With WARP connected and the job enabled, generate LLM traffic. After a few minutes (Logpush batches + ~30–90s Gateway log lag), the queries appear in Inviolet ascasb-cloudflare-{openai,anthropic,google} events with the user’s
email — feeding the bypass-volume signal.
What you get
Notes
- WARP is the only client requirement — nothing Inviolet-specific is installed on the device beyond the standard Cloudflare One client (or a network-level tunnel). The Inviolet SDK lives in the agent app, not on the device.
- The fingerprint header proves org + agent mediation, not the end user — user attribution here comes from Cloudflare’s device identity, not the fingerprint.