Fix JWT Scope Security issue#182
Conversation
Resolves impact from CVE-2026-52855
📝 WalkthroughWalkthroughThis PR adds scope-based JWT authorization across file uploads/downloads, backup operations, server transfers, and websocket connections. It introduces scope infrastructure, embeds scopes into token payloads, enforces scope validation at handlers, and redacts tokens in debug logs. ChangesJWT scope-based authorization
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
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 |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
router/tokens/token.go (1)
21-23: ⚡ Quick winUse whitespace-tolerant scope parsing in
Scopes().
strings.Split(s.Scope, " ")only handles literal spaces and preserves empty tokens. In auth parsing, preferstrings.Fieldsso any whitespace delimiter is handled consistently and empty entries are dropped.Proposed patch
func (s Scoped) Scopes() []string { - return strings.Split(s.Scope, " ") + return strings.Fields(s.Scope) }🤖 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 `@router/tokens/token.go` around lines 21 - 23, The Scopes() method on type Scoped currently uses strings.Split(s.Scope, " ") which preserves empty tokens and only splits on literal spaces; change Scoped.Scopes() to use strings.Fields(s.Scope) so it splits on any Unicode whitespace and drops empty entries (update the function body in the Scopes method to return strings.Fields(s.Scope)).
🤖 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.
Nitpick comments:
In `@router/tokens/token.go`:
- Around line 21-23: The Scopes() method on type Scoped currently uses
strings.Split(s.Scope, " ") which preserves empty tokens and only splits on
literal spaces; change Scoped.Scopes() to use strings.Fields(s.Scope) so it
splits on any Unicode whitespace and drops empty entries (update the function
body in the Scopes method to return strings.Fields(s.Scope)).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: eb6b96a2-4f90-4780-a0b1-aff732a51588
📒 Files selected for processing (11)
router/router.gorouter/router_download.gorouter/router_server_files.gorouter/router_transfer.gorouter/tokens/backup.gorouter/tokens/file.gorouter/tokens/token.gorouter/tokens/transfer.gorouter/tokens/upload.gorouter/tokens/websocket.gorouter/websocket/websocket.go
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: Build and Test (ubuntu-22.04, 1.25.7, linux, amd64)
- GitHub Check: Build and Test (ubuntu-22.04, 1.26.0, linux, amd64)
- GitHub Check: Analyze (go)
🔇 Additional comments (16)
router/tokens/backup.go (1)
13-13: LGTM!router/tokens/file.go (1)
12-12: LGTM!router/tokens/transfer.go (1)
9-9: LGTM!router/tokens/upload.go (1)
13-13: LGTM!router/tokens/websocket.go (1)
55-55: LGTM!router/router_download.go (2)
31-36: LGTM!
84-90: LGTM!router/router_server_files.go (2)
243-244: LGTM!
601-607: LGTM!router/router_transfer.go (4)
35-36: LGTM!
46-50: LGTM!
153-159: LGTM!
213-250: LGTM!router/websocket/websocket.go (2)
77-79: LGTM!
216-218: LGTM!router/router.go (1)
4-4: LGTM!Also applies to: 15-16, 40-42
|
@parkervcp The Github security advisories linked there mentioned commit (eb65e27) what is not in this PR |
Resolves impact from pterodactyl/wings/security/advisories/GHSA-pfvc-3p5h-x7h6
This is a drop in change
Summary by CodeRabbit
Release Notes
Bug Fixes
Security Improvements