Review redirect targets: app params and OAuth redirect_uri
One review covers post-login next/return_to helpers and OAuth redirect_uri matching at authorize and token steps. You map every user-influenced Location target and block merges that send codes, tokens, or sessions to unregistered origins.
Cursor, Claude Code · Coding · 45 min · Deep
Outcome
A redirect inventory table in the PR comment (app params + OAuth clients), negative test gaps called out, and no merge while absolute URLs, scheme-relative paths, or permissive redirect_uri matchers remain.
Steps
- 1
Grep parameters before reading handlers
List next, returnTo, redirect_uri, and mobile deep-link keys across server and client. Missing one entry point is how open redirects return after merge.
- 2
Trace authorize and token separately
OAuth bugs often validate redirect_uri only on /authorize. Require the agent to quote both handlers or Block.
- 3
Add negative URL fixtures to CI
Keep tests for //evil.tld, https://off-site.example, and nested redirect proxies on your domain. The PR comment should cite which fixtures ran.
Copy prompt
The prompt to paste
Review redirect surfaces in this PR: application redirect query params AND OAuth/OIDC redirect_uri validation. Repository facts: [framework redirect helpers — file paths] [query param names: next, returnTo, redirect, continue, etc. — from grep in paste] [OAuth: client registration source, authorize + token paths] [production vs dev client ids] PR context: [PR link or diff] Section A — Application redirects 1. Grep-backed list of parameters that influence Location headers or client router navigation. 2. For each builder: trace input → normalization → final URL. Block unvalidated absolute URLs, //scheme-relative hosts, javascript:/data: reachability, and chained open proxies on trusted domains. 3. Block post-auth URLs that append tokens or session material to user-chosen destinations. 4. Tests required: reject external https URL, reject //evil path, reject nested open redirect on allowed host. Section B — OAuth redirect_uri 1. Table each client: registered redirect_uris, match algorithm (exact vs prefix/wildcard), checked on authorize? on token? 2. Block: token endpoint accepts redirect_uri not validated on authorize; substring/host-only matching; production artifacts registering localhost/custom schemes without dev-only gate. 3. Confirm logout/error redirects do not reuse a wider allowlist than login. ## Findings + merge recommendation Rules: - Placeholder hosts only (app.example). - No phishing templates or live authorization codes. - Do not recommend removing redirects when signed-token or relative-path patterns exist.
Relative-path-only validators still accept //attacker.tld. Prefix matchers on redirect_uri still admit https://trusted.example.attacker.com. The review must reject those cases explicitly, not only bare https:// off-site URLs.
Sample case written by Hidden Logic Lab. Not affiliated with Cursor or Claude Code.
More in Coding
Get new cases in your inbox
Weekly notes on new use cases and agent workflows. No product pitches.