test(supabase): avatar e2e clients refuse HTTP redirects
The suite's supabase-js clients followed redirects by default, so a 3xx from the sandbox gateway would have carried the apikey header to another origin. `noRedirectFetch` (`redirect: 'error'`) is passed as `global.fetch` of both client factories; a regression test with two loopback servers proves REST, auth and Storage calls stop at the 302. Live proof j and a second 5/5 run are in the audit log; no production client changes.
This commit is contained in:
1 parent
e8da0d96d9
commit
d3dfd03213
7 files changed
+147
-16
No files matched your search
@@ -32,7 +32,7 @@ stay in the session scratchpad (`…/scratchpad/proofs/`), not in the repository
|
||||
|---|---|---|
|
||||
| 1 | runner deleted, no line invokes it (the two "removed" mentions excluded) | `DEV_RUNNER_GONE` |
|
||||
| 2 | alias, `bash -n`, dispatcher line | `ALIAS_OK` |
|
||||
| 3 | suite `cmp`-identical to V1-2; db-sandbox.sh blocks 47-52, 58-61, 255, 270-332, 342-359 verbatim; no `cmd_verify_e2e` / `cmd_sheet_assets_e2e` | `BLOCKS_IDENTICAL` |
|
||||
| 3 | suite identical to V1-2 once the `noRedirectFetch` lines are dropped (owner-gated, see below); db-sandbox.sh blocks 47-52, 58-61, 255, 270-332, 342-359 verbatim; no `cmd_verify_e2e` / `cmd_sheet_assets_e2e` | `BLOCKS_IDENTICAL` |
|
||||
| 4 | no `supabase status`, `54321`, `supabase_kong`, `supabase_db_faunosteo`, `supabase_network_faunosteo` in the runner or the suite | `NO_DEV_IDS` |
|
||||
| 8 | `corepack pnpm -s typecheck && lint` in `$W` (after `pnpm wasm:build`, the git-ignored `packages/core-wasm/pkg` being absent in a fresh worktree) | `STATIC_GREEN` |
|
||||
|
||||
@@ -105,16 +105,34 @@ environment supplies. Nothing else is contacted.
|
||||
nothing in the runner or the suite reads it. `NET` is a plain bridge (it can route to the host):
|
||||
the proofs above show nothing uses that route.
|
||||
|
||||
## Residual LOW (owner brief §3; no code change here, to fix on V1-2 first then port)
|
||||
## Redirects refused (owner condition at the checkpoint, 2026-11-02)
|
||||
|
||||
- The suite's supabase-js clients use Node's global fetch: default `redirect: follow`; a proxy
|
||||
would be honoured only with `NODE_USE_ENV_PROXY=1` (unset here, unset by every proof). No
|
||||
endpoint of the gateway or its upstreams redirects today; a redirect to a foreign host would
|
||||
appear in strace as a connect outside 127.0.0.1:57800 (none). Security gate nuance: on a
|
||||
cross-origin redirect undici drops `Authorization` but keeps supabase-js's `apikey` header, so
|
||||
a redirecting sandbox upstream would carry the sandbox anon or service key to the target; that
|
||||
key opens nothing on DEV (different JWT secret). Hardening when ported from V1-2: a custom
|
||||
fetch with `redirect: 'error'` in the suite's two client factories.
|
||||
The former residual LOW is closed on this branch: `tests/e2e/noRedirectFetch.ts` wraps the
|
||||
global fetch with `redirect: 'error'` (set after the caller's init, so nothing restores
|
||||
`follow`); the suite's `anonClient()` and `serviceClient()` pass it through `global.fetch`,
|
||||
which supabase-js hands to its auth, REST and Storage calls (raw to auth-js, through
|
||||
`fetchWithAuth` for REST and Storage; neither layer sets `redirect`, retries reuse the wrapper). No production client changes (`packages/supabase/src`, `apps/app/src`
|
||||
untouched since 6287e5b). Security gate nuance that motivated it: on a cross-origin redirect
|
||||
undici drops `Authorization` but keeps supabase-js's `apikey` header.
|
||||
- Regression test `packages/supabase/tests/no-redirect-fetch.test.ts` (in `pnpm --filter
|
||||
@faunosteo/supabase test:run`, 12 files / 131 tests green): two `node:http` servers, the
|
||||
origin answers every request with 302 towards the target; REST, auth and Storage calls all
|
||||
error, the target receives nothing, every origin request carries `apikey: test-key`; the
|
||||
control (plain fetch, default `follow`) reaches the target at `/landed`. Negative control by
|
||||
the executor: with `follow` in the wrapper, 3 of the 4 cases fail.
|
||||
- Live proof j (strace, same harness as a-i): a Python 302 listener on 127.0.0.1:57800
|
||||
(`Location: http://127.0.0.1:57801/landed`) and a recording target on 57801. Control:
|
||||
`curl -L` lands on 57801 (1 hit). The suite with forged `iss: db-sandbox` keys: 1 connect to
|
||||
127.0.0.1:57800, 0 to 57801, 0 hit on the target, `createUser: fetch failed`, 5 tests skipped,
|
||||
rc 1 (fails closed).
|
||||
- Positive run 2, fresh sandbox from the branch, under strace, proxies unset: **5/5**, 4
|
||||
connects all to 127.0.0.1:57800, 0 key in the output, gateway and worker removed, final `down`.
|
||||
DEV `StartedAt` digest identical to the pre-flight.
|
||||
|
||||
## Residual LOW (owner brief §3; kept as is, V1-2 first then port)
|
||||
|
||||
- A proxy would be honoured by Node's fetch only with `NODE_USE_ENV_PROXY=1` (unset here,
|
||||
unset by every proof).
|
||||
- `worker_env` is read by the EXIT trap before `start_worker` assigns it (an inherited value
|
||||
would be `rm -f`'d on an early `die`).
|
||||
- Every docker call follows `DOCKER_HOST` / the current context (both local here).
|
||||
|
||||
Reference in new issue
Block a user