The problem: rules pass review and still regress
Unit tests for authorization logic almost always mock the enforcement layer. A Firestore rules file that compiles cleanly can still widen access: a refactored match block, a renamed field that turns a resource.data check into a no-op, an IAM condition dropped during a Terraform refactor. None of these fail your build. All of them fail your users.
Reviews catch intent; they do not catch state. What you need is a measurement of the deployed deny surface, taken continuously, where the only accepted inputs are the same ones an anonymous internet client would send.
Deny-by-default as a state machine
Define a finite set of probes P. Each probe is an unauthenticated HTTP request against a deployed resource, with a declared expected class:
| Class | Meaning | Verdict contribution |
|---|---|---|
| DENY_AUTH | 401, no/invalid credentials presented | Pass |
| DENY_RULES | 403, authenticated-or-not, policy denies | Pass |
| LEAK | 2xx, or any response whose body contains protected bytes | Fail (critical) |
| TRANSIENT | 5xx, 429, timeouts | Retry, then inconclusive |
The invariant is on transitions between consecutive deploys, not on absolute values. A probe moving DENY_AUTH → DENY_RULES is fine (tightening). A probe moving any deny class → LEAK is a regression. A probe moving LEAK → deny is a fix; record it, alert softly, move on. This transition framing matters because expected classes differ per probe and per surface, the manifest declares them, the executor only enforces monotonicity of denial.
What each surface actually returns
The expected class is empirical, not aspirational. Current deployed behavior, verified 2026-11:
| Surface | Anonymous request | Observable signal |
|---|---|---|
| Firestore (REST v1) | 403 with PERMISSION_DENIED status in the JSON body when rules deny; 401 UNAUTHENTICATED when a token is required and absent | error.status in body distinguishes the two deny classes |
Realtime Database (REST /.json) | 401 with a permission-denied payload string | Status line plus body text |
| Object storage (XML/API GET on private object) | 403 Forbidden; some providers 404 when existence is hidden | Neither may ever carry object bytes; both are acceptable deny classes, declared per probe |
| Callable / RPC endpoint | Explicit guard returns 401/403; a missing guard returns 200 with data | 2xx on an anonymous callable is the single most common leak shape |
Deny-class variation (401 vs 403 vs 404) is why the manifest is declarative. Hard-coding "must be 401" produces false alarms the moment a provider tightens semantics.
A probe manifest
probes:
- id: firestore-userdoc-unauth
request:
method: GET
url: https://firestore.googleapis.com/v1/projects/${PROJECT}/databases/(default)/documents/users/alpha
expect_class: DENY_RULES # or DENY_AUTH, declared, not assumed
body_must_not_contain: ["@gmail", "phoneNumber", "displayName"]
- id: rtdb-root-unauth
request:
method: GET
url: https://${PROJECT}-rtdb.firebaseio.com/.json
expect_class: DENY_AUTH
- id: bucket-object-unauth
request:
method: GET
url: https://storage.googleapis.com/${BUCKET}/exports/2026-11.csv
expect_class: DENY_RULES
body_must_not_contain: ["BEGIN PRIVATE KEY"]
- id: callable-adminExport-unauth
request:
method: POST
url: https://us-central1-${PROJECT}.cloudfunctions.net/adminExport
json: {}
expect_class: DENY_AUTH # 200 here means the guard is missing
The body_must_not_contain list is the second, independent invariant: even a response the classifier calls a deny must not echo protected bytes (some providers return partial context in error envelopes).
The executor, and why transients cannot cause false LEAKs
Classification is conservative by construction: only a 2xx status (or a body invariant hit) can ever be a LEAK. A 500 storm, a 429 from quota, a TLS timeout, none of them are leaks, so the worst a transient can do is leave a probe inconclusive. That yields a three-valued gate:
def classify(resp, probe):
if resp is None: # timeout / connect error
return "TRANSIENT"
if 200 <= resp.status < 300:
return "LEAK"
if any(s in resp.text for s in probe.body_must_not_contain):
return "LEAK" # bytes leaked inside an error envelope
if resp.status == 401:
return "DENY_AUTH"
if resp.status == 403 or resp.status == 404:
return "DENY_RULES" # 404 existence-hiding is declared per probe
if resp.status >= 500 or resp.status == 429:
return "TRANSIENT"
return "UNEXPECTED" # 3xx/4xx oddities surface as review items
def gate(probes, prev_state, new_state, budget_s=25):
for p in probes: # concurrency 8, jittered start
cls = retry_until(p, klass="stable", budget=budget_s)
if cls == "LEAK" and prev_state[p.id] != "LEAK":
return exit(10) # regression: deny -> allow
if cls == "LEAK" and prev_state[p.id] == "LEAK":
continue # known hole, tracked elsewhere
if cls == "TRANSIENT":
return exit(20) # inconclusive: hold, do not pass
return exit(0)
Exit-code semantics keep CI honest: 0 pass, 10 regression (page, block promotion), 20 inconclusive (a hold, never a pass, silence must not be interpreted as safety).
The 60-second budget
| Phase | Budget | Notes |
|---|---|---|
| Deploy webhook → probe job start | ≤ 3 s | Post-deploy hook, not a cron poll |
| DNS + TLS warm (connection reuse) | ≤ 5 s | One session per host, keep-alive |
| Probe execution (120 probes, concurrency 8) | ≤ 25 s | Per-probe timeout 3 s, jittered start ±100 ms |
| Retry envelope (transients only) | inside the 25 s | Backoff 250 ms → 1 s → 4 s, capped at 3 attempts |
| Verdict + status report | ≤ 5 s | SARIF for the run; single summary row per probe |
Rewriting it as one probability: with per-attempt transient probability q, three attempts leave an unresolved-transient probability of q3. At q = 0.05 that is 1.25 × 10-4 per probe, the hold path exists for exactly this residue, and it holds rather than passes.
What this does not do
Unauthenticated probing does not replace authenticated abuse testing, business-logic review, or load-shaping tests. It answers one question with high sensitivity: did the anonymous deny surface just shrink? In practice that is the question your users' regulators, and your incident reviewers, ask first.
Status
The manifest format, classifier, and transition-state store described here are being packaged as Silvauren/cloud-unauth-probe a dependency-light runner suitable for a CI post-deploy hook. We publish the technique now because every team running rules-as-code deserves a deny-surface regression alarm that is cheaper than their incident review.