dave.brock
← All writing

Where Did the 403 Come From?

How I built the Cloud Run and Cloud Storage lab, and what evidence will distinguish a rejected invocation from a rejected object read.

Cloud security labs / 2026-11-11

In Part 1, I laid out two separate decisions: who can call the API and which report the service can read. This installment covers the build and sets up the tests. If Cloud Run and Cloud Storage can both return a 403, what evidence would tell me which one said no?

I started with two files named report.txt. One sits in an approved bucket and one in a draft bucket. I gave them different contents. That gives me two useful controls: I can verify exactly which bytes came back, and I can test the same read operation against two different bucket policies.

1. Separate the deployer, the callers, and the workload

I created a dedicated GCP project, linked billing, and configured my local Google Cloud and Terraform tooling. I used my project owner account for the deployment. For the lab itself, Terraform defines three service accounts: a reviewer, an authenticated non-reviewer, and the Cloud Run runtime. Testing with my owner account would muddy the result because its project-wide permissions could mask a missing resource-level grant.

2. Put the Storage boundary in IAM

Terraform provisions the two private buckets and their synthetic objects. I enabled uniform bucket-level access and public access prevention. I granted the runtime account Object Viewer on the approved bucket only. I also enabled Cloud Storage Data Read audit logging so I can look for the principal that fetched the report. The draft bucket has no corresponding runtime grant.

3. Deploy the smallest service that exercises both controls

The Python handler has one report route and a fixed object name. Its bucket comes from deployment configuration. I built the image in Cloud Build, pushed it to Artifact Registry, and used its digest in the Terraform deployment so the revision points at a specific image.

Cloud Run attaches the runtime account to the revision and grants the reviewer Invoker on the service. The default service URL is reachable from the internet, and the Invoker IAM check is enabled. I configured zero minimum instances and a maximum of one instance per revision for this lab.

Swimlanes for the expected approved-report request
Expected allowed path. The handler log marks entry into the application, and the Storage audit entry can identify the workload principal.

4. Collect enough evidence to explain the outcome

Both Terraform applies succeeded. The container image is in Artifact Registry, and the Cloud Run service and reviewer grant are deployed. The first live request is still pending. An apply tells me that Google Cloud accepted the configuration. To make a claim about what a caller can do, I need to make the request and check the result.

RequestExpected outcomeEvidence I’ll capture
Reviewer requests /reportCloud Run allows invocation. The approved report comes back.HTTP status, fixture SHA-256 match, handler test ID, and a Storage audit entry naming the runtime principal
Request has no tokenCloud Run rejects it before the handler.Observed status and whether the handler logged the test ID
Non-reviewer presents a valid ID tokenCloud Run rejects invocation.Observed status and whether the handler logged the test ID
Reviewer requests the approved object directlyStorage denies the read.Storage API status and error reason
Runtime requests report.txt from each bucketApproved read succeeds. Draft read is denied.Paired API results, with the draft object's existence verified separately

The last pair is the cleanest Storage test. I’ll use the same short-lived runtime credential, the same GET operation, and the same object name against both buckets. The target bucket is the only thing I’ll change. The handler can keep its approved-report path throughout the test.

For the public repo, I’ll include the Terraform, handler, synthetic fixtures, test instructions, and a results table with observed outcomes. I’ll include a small set of sanitized log excerpts so a reader can follow the evidence without sorting through a console transcript. I’ll also document removal of temporary grants and verify teardown. That gives another engineer enough to rebuild the lab and challenge my conclusions.

Next I’ll call the live endpoint as the reviewer, then try to read the same report directly from Storage. I expect the first request to succeed and the second to fail. If the response matches the fixture, will the audit trail show that the runtime account fetched it, and will there be enough evidence to tell a Storage denial from a Cloud Run denial?

← More writing