Repository navigation
build(deploy): forward only the API's paths through the cloud's sign-in relay - #2914
Conversation
…in relay The relay under /cloud/zitadel forwarded any plain path to the server's origin, which every other service shares: the docs, the website, the functions themselves (one more invocation per nested /cloud/zitadel), each call with a preview's protection-bypass secret. It now forwards /api/v1/... alone, which is all the sign-in widget calls, and answers 404 to the rest. apps/cloud/README.md names the seventh service (go-import) and the server service's root. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
There was a problem hiding this comment.
Note
Copilot was unable to complete this review at the selected tier due to model policy or plan restrictions.
🟡 Changes recommended
Approval is blocked because isApiPath can be bypassed via dot-segment paths that normalize outside the /api/v1/ prefix, and there is no regression test covering this escape vector, with a related ADR needing an update to match the new forwarding behavior.
3 open issues
What changed in this PR
Tightens the hosted cloud’s sign-in relay so /cloud/zitadel/... only forwards Resource API traffic (/api/v1/...), reducing exposure of non-API paths on the shared Vercel origin.
Changes:
- Restrict relay forwarding to
/api/v1/...and return404 req.not_foundfor all other paths before bot-check/fetch. - Update and extend unit tests to reflect the API-only relay contract and rejection behavior.
- Align ADR 084 and cloud deployment documentation with the updated relay behavior and current service layout.
| File | Description |
|---|---|
| docs/adrs/084-hosted-cloud-business-systems.md | Updates ADR 084 documentation around hosted cloud systems, including the sign-in relay/BotID behavior and referenced request paths. |
| apps/cloud/README.md | Refreshes the hosted cloud deployment/service documentation, including the service list and corrected service roots. |
| apps/cloud-functions/src/sign-in.ts | Implements API-only gating for the sign-in relay so only /api/v1/... paths are forwarded and all others are rejected with a 404 envelope. |
| apps/cloud-functions/src/sign-in.spec.ts | Adjusts and extends relay tests to validate API-only forwarding and expected 404 behavior for disallowed paths. |
Review effort: Balanced
A request's own URL arrives with its dot segments resolved, so /cloud/zitadel/api/v1/../../docs already reached the relay as /cloud/zitadel/docs and was refused. isApiPath now refuses "." and ".." itself, for any caller that hands it an unresolved path, and ADR 084 names the prefixed flow writes. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>


Context
Summary
/cloud/zitadel/<plain path>went to the server's origin, which on the cloud is every other service's too:/cloud/zitadel/docsfetched the docs,/cloud/zitadel/cron/events-retentionthe cron trigger, and/cloud/zitadel/cloud/zitadel/…the relay again, one more function invocation per nested prefix. On a preview each of those calls carried the protection-bypass secret. Production deploys the route too, although its console does not use it./api/v1/…alone and answers404 req.not_foundto everything else, before the bot check and before any fetch. The sign-in widget calls nothing else: it has put the prefix after its base since feat!: call the API under /api/v1 #2359.apps/cloud/README.mdlists the seventh service,go-import, and roots theserverservice atapps/api, asvercel.jsondoes.Validation
turbo run test typecheck lint --filter=@zitadel/cloud-functions(6 tasks, all pass;src/sign-in.spec.ts21 tests)node scripts/check-adrs-index.mjsnode scripts/check-pr-title.mjs --title "…"isApiPathalso refuses.and..segments (a request's URL arrives with them resolved, so the relay already refused/api/v1/../../docs), with tests.Release notes / changeset
@zitadel/cloud-functionsis the hosted cloud's backend and is in the changesetsignorelist.Notes
/cloud/zitadel/flow). Nothing calls them: the console and the functions deploy together.apps/cloud-console/src/bot-check.tsstill protects/cloud/zitadel/flowand/cloud/zitadel/flow/*/submit, without the prefix the widget has sent since feat!: call the API under /api/v1 #2359, so BotID's client marks none of the widget's calls. A barecurl -X POSTto a preview's/cloud/zitadel/api/v1/flowpasses the bot check and reaches the server's validation (400req.invalid). feat!: protect password signup with built-in proof of work #2626 corrects those paths; BotID itself is parked while the server's own abuse protection lands (feat!: protect password signup with built-in proof of work #2626, docs: propose configuring abuse protection per operation #2835, feat!: protect passkey sign-up with the built-in proof of work #2866), so nothing follows from this here.vercel.jsonheaders reach a service's 404s as well: a missing/schemas/v1/*.jsonanswers 404 withmax-age=3600. Animmutablerule for/console/assets/*would cache a missing chunk's 404 for a year, so it needs deployment-pinned asset URLs first.🤖 Generated with Claude Code