Repository navigation
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (5)
WalkthroughAdds RFC 8252-compliant custom URI scheme support for native application OAuth redirects. Configuration introduces ChangesCustom URI Scheme Allowlist
Sequence DiagramsequenceDiagram
participant Client as Native App Client
participant Handler as OAuth2Handler
participant Validator as isAllowedClientRedirectURI
participant Checker as isAllowedScheme
participant Config as AllowedClientRedirectSchemes
Client->>Handler: HandleAuthorize(redirect_uri)
Handler->>Validator: isAllowedClientRedirectURI(redirect_uri)
Validator->>Validator: Parse URI (scheme, host)
Validator->>Checker: isAllowedScheme(scheme)
Checker->>Config: lookup scheme in allowlist
Config-->>Checker: true/false
Checker-->>Validator: allowed/rejected
alt allowed
Validator-->>Handler: accept
Handler-->>Client: proceed with auth
else rejected
Validator-->>Handler: reject
Handler-->>Client: error
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
f164a23 to
98f7c86
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
handlers.go (1)
925-938:⚠️ Potential issue | 🟠 Major | ⚡ Quick winLocalhost short-circuit bypasses custom-scheme allowlist.
isAllowedClientRedirectURIacceptscustom://localhost/...even when the scheme is not configured, because localhost is checked before scheme policy. This weakens the callback re-validation path.Proposed fix
func (h *OAuth2Handler) isAllowedClientRedirectURI(uri string) bool { - // Always allow localhost URIs for development tools - if isLocalhostURI(uri) { - return true - } - parsedURI, err := url.Parse(uri) if err != nil { return false } // Allow explicitly configured custom schemes (e.g. cursor://, vscode://) per RFC 8252 if h.isCustomScheme(parsedURI.Scheme) { return true } + + // Allow localhost only for standard loopback web redirects + if (parsedURI.Scheme == "http" || parsedURI.Scheme == "https") && isLocalhostURI(uri) { + return true + }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@handlers.go` around lines 925 - 938, The localhost short-circuit in isAllowedClientRedirectURI runs before scheme validation, allowing custom://localhost/... to bypass the custom-scheme allowlist; fix by parsing the URI first, then check h.isCustomScheme(parsedURI.Scheme) and return true if allowed, and only then apply isLocalhostURI for non-custom/standard schemes (e.g., restrict localhost allowance to http/https or when the scheme is explicitly allowed). Update the logic in isAllowedClientRedirectURI to call url.Parse(uri) first, use parsedURI.Scheme with h.isCustomScheme(...), and only treat isLocalhostURI(parsedURI) as a fallback for standard schemes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@docs/SECURITY.md`:
- Around line 403-408: The fenced code block containing the three lines
beginning with "ok: cursor://anysphere.cursor-mcp/oauth/callback" should
include a language tag to satisfy markdown lint (MD040); update the opening
fence from ``` to ```text so the block (the lines with "ok: cursor://..." and
"bad: cursor://...") is explicitly marked as plain text.
---
Outside diff comments:
In `@handlers.go`:
- Around line 925-938: The localhost short-circuit in isAllowedClientRedirectURI
runs before scheme validation, allowing custom://localhost/... to bypass the
custom-scheme allowlist; fix by parsing the URI first, then check
h.isCustomScheme(parsedURI.Scheme) and return true if allowed, and only then
apply isLocalhostURI for non-custom/standard schemes (e.g., restrict localhost
allowance to http/https or when the scheme is explicitly allowed). Update the
logic in isAllowedClientRedirectURI to call url.Parse(uri) first, use
parsedURI.Scheme with h.isCustomScheme(...), and only treat
isLocalhostURI(parsedURI) as a fallback for standard schemes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 9c05b4b6-42b9-42ff-a276-fae6f7202daa
📒 Files selected for processing (7)
config.goconfig_test.godocs/CONFIGURATION.mddocs/SECURITY.mdfixed_redirect_test.gohandlers.gosecurity_test.go
| ``` | ||
| ok: cursor://anysphere.cursor-mcp/oauth/callback (when "cursor" configured) | ||
| ok: vscode://vscode.github-authentication/callback (when "vscode" configured) | ||
| bad: cursor://anysphere.cursor-mcp/oauth/callback (when not configured) | ||
| ``` | ||
|
|
There was a problem hiding this comment.
Add a language tag to the fenced code block.
The block starting at Line 403 has no language identifier (MD040), which can break markdown lint checks.
Proposed fix
-```
+```text
ok: cursor://anysphere.cursor-mcp/oauth/callback (when "cursor" configured)
ok: vscode://vscode.github-authentication/callback (when "vscode" configured)
bad: cursor://anysphere.cursor-mcp/oauth/callback (when not configured)</details>
<!-- suggestion_start -->
<details>
<summary>📝 Committable suggestion</summary>
> ‼️ **IMPORTANT**
> Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
```suggestion
🧰 Tools
🪛 markdownlint-cli2 (0.22.1)
[warning] 403-403: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@docs/SECURITY.md` around lines 403 - 408, The fenced code block containing
the three lines beginning with "ok:
cursor://anysphere.cursor-mcp/oauth/callback" should include a language tag to
satisfy markdown lint (MD040); update the opening fence from ``` to ```text so
the block (the lines with "ok: cursor://..." and "bad: cursor://...") is
explicitly marked as plain text.
98f7c86 to
26ca745
Compare
|
Hi @tuannvm - just following up on this PR when you have time. I believe it’s ready for review, and I’d appreciate any feedback. Thanks! |
|
That would be very useful! |
Summary
The redirect URI validation rejects non-HTTP(S) schemes, which breaks native desktop OAuth clients like Cursor that use custom callback URIs (e.g. cursor://anysphere.cursor-mcp/oauth/callback). Custom URI schemes are standard for native applications per RFC 8252.
Changes
HandleAuthorize- replaced hard-coded http/https scheme check with isAllowedScheme() helper that also accepts configured custom schemes.Usage
Or via environment:
Testing
Related Issues
Fixes #30
Summary by CodeRabbit
New Features
Security / Bug Fixes
Documentation