Skip to content

Browser flow security

The caller is responsible for deciding when to run a proposed app. Use a Linux Docker runner with no production access. Do not run fork code with App, model, or storage credentials. Apply the opt-in label only to a change trusted enough to run in that test environment.

  • The action starts the app from your trusted digest-pinned image and drives it from a pinned Playwright container, both on host networking. Each runs in its own secret-free container with a private PID namespace and receives no inference document, credential slots, App token, or S3 keys. The coordinator on the host keeps those. See application isolation.
  • Install dependencies and build the image without credentials, in a separate job or a throwaway container. Never leave a repository-controlled process running on the host when the flows step starts.
  • Use a fresh local database with seeded users that exist nowhere else. Use a test-only password and authenticator seed. The driver fills them and computes the one-time code locally. Use a seeded UI that presents no personal data or real secrets in snapshots, video, or screenshots.
  • Textual browser evidence and application output are redacted for configured secret values and bounded before diagnosis or reporting. Application and setup values shorter than eight characters and bare HTTP or HTTPS origins without credentials stay visible. The configured application base URL, host, and port also stay visible. Other configured URLs with credentials, a path, or a query are redacted.
  • The flows file is refused if a test user name, setup step name, or setup parameter name contains a configured secret value.
  • Media cannot be text-filtered. Screenshots and video still require test-only seeded data, private storage, deletion after 30 days, and expiring read links.
  • Keep media in a private bucket with narrowly scoped keys and a deletion policy. Presigned links are bearer links: anyone with one can read that artifact until it expires. Avoid copying them into public reports.
  • Use job permissions to keep App access narrow and pass only the required settings to the action.

With target: preview, the PR code runs on the preview host and the browser runs in its secret-free container. The caller must trust that host and use test users and credentials that exist only in the preview's own seeded data. Application logs are not provided, so diagnosis uses browser evidence only.

Code Hawk accepts an address only from environment_url on a deployment status. Both the deployment and the status must have a creator in preview-creators, the deployment environment must match preview-environments, and the hostname must match preview-hosts. Confirm environment names and creator logins on your own repository's Deployments page. There are no host-specific defaults. Production deployments, IP addresses, trailing-dot hosts and addresses outside the allowlist are refused. Code Hawk never uses build log URLs as application addresses.

The bypass secret is sent only to the preview origin and never forwarded on redirects. The readiness probe and browser fetches disable automatic redirects when sending it. Other origins receive no bypass headers, and a failed protected fetch is aborted. The Vercel bypass uses a header, never a query parameter or a bypass cookie. The bypass and test credentials reach the secret-free browser container through its RPC, like test passwords in container mode. It receives no App token, inference credentials or storage keys. Text evidence redacts both bypass values regardless of length, but screenshots and video still need seeded data and private, expiring storage.

The reusable preview workflow keeps App tokens and OIDC access in preparation and report jobs that never check out PR-head code or install caller dependencies. Preparation passes validated settings and preview metadata as JSON to the browser job. That job receives no App token or OIDC access, and returns only report data for trusted posting.

Preview callers run only on pull_request, and Code Hawk refuses forks. The caller and reusable workflow gate the job holding secrets on the head repository matching the base repository, before checkout or token creation. The coordinator repeats the fork check. GitHub withholds repository secrets from fork pull request runs. The repository controls its caller workflow and decides which code it executes, so keep write access limited and review caller changes. Do not add deployment event triggers, since a deployed fork commit could supply workflow code that runs with repository secrets before the coordinator can refuse it.

If a flow needs a state change, define a named setup in the flow library that points to an npm script in the caller's package.json. For example, add these setups and flows fields to the library file once the e2e:setup:remove-member script exists:

{
"setups": {
"remove-member": {
"script": "e2e:setup:remove-member",
"about": "Remove the seeded member from the local fixture",
"params": { "user": ["owner"] }
}
},
"flows": [
{
"name": "Open Overview without a membership",
"user": "owner",
"start": "/app",
"steps": ["Check that the app shows the missing-membership message."],
"setup": [{ "step": "remove-member", "with": { "user": "owner" } }]
}
]
}

Run setups only by opting in with allow-setup: "true" (--allow-setup locally). At most three setups run per flow, after sign-in and before the first model turn, each in a separate secret-free container with a private PID namespace that mounts the caller's checkout. Each receives only PATH, HOME, CI, and explicitly named setup-env values. Reserved bot and workflow names, credential slots, and conventional provider key names are refused even if listed. The script and its parameters must match the declared allowlist. The command receives arguments without shell interpolation and has a 120-second limit. A setup failure blocks that flow. Coordinator logs record only the setup step, timeout, and exit status, not command output.

The PR checkout can define setup scripts, and container isolation does not make them trustworthy. They receive only throwaway database access and the safe variables listed in setup-env. Use a hard guard in the script that refuses any database other than the disposable local instance. Do not list CI in setup-env, and do not treat the CI flag as a database guard.