fix: Endpoint /sessions/me bypasses _Session protectedFields (GHSA-g4v2-qx3q-4p64)#10406
Conversation
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. Our CI and AI review are safeguards, not development tools. If many issues are flagged, rethink your development approach. Invest more effort in planning and design rather than using review cycles to fix low-quality code. |
📝 WalkthroughWalkthroughA security fix implements a two-step session lookup in Changes
Sequence DiagramsequenceDiagram
actor Client
participant SessionsRouter
participant Auth
participant REST as REST Layer
participant DB as Database
Client->>SessionsRouter: GET /sessions/me (with sessionToken)
SessionsRouter->>Auth: Create master Auth context
Auth-->>SessionsRouter: Master Auth
SessionsRouter->>REST: find(_Session) with master Auth (by sessionToken)
REST->>DB: Query _Session
DB-->>REST: _Session record
REST-->>SessionsRouter: results[0]
alt Session exists and has user
SessionsRouter->>SessionsRouter: Extract session objectId & user objectId
SessionsRouter->>Auth: Create non-master Auth for user
Auth-->>SessionsRouter: User Auth context
SessionsRouter->>REST: get(session objectId) with User Auth
REST->>DB: Query _Session (apply protectedFields/CLP)
DB-->>REST: Sanitized _Session
REST-->>SessionsRouter: Sanitized response
SessionsRouter-->>Client: {response: sanitized session}
else Session missing or user missing
SessionsRouter-->>Client: Parse.Error(INVALID_SESSION_TOKEN)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (3 warnings)
✅ Passed checks (2 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 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## alpha #10406 +/- ##
==========================================
- Coverage 92.50% 92.49% -0.01%
==========================================
Files 192 192
Lines 16725 16732 +7
Branches 229 229
==========================================
+ Hits 15471 15477 +6
- Misses 1232 1233 +1
Partials 22 22 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/Routers/SessionsRouter.js`:
- Around line 35-46: The second fetch for the _Session currently constructs a
new regular-user Auth (userAuth) which can downgrade any elevated privileges;
instead reuse the incoming request auth (req.auth) when calling rest.get for the
session (or if rebuilding Auth, copy all auth flags from req.auth such as
isMaster, installationId, and any other role/session context) so the call that
uses userId maintains the original caller's auth context; update the call site
that currently passes userAuth to pass req.auth (or a cloned Auth built from
req.auth) and remove the hardcoded new Auth instantiation around userId.
🪄 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: 81ebe326-ea32-4a90-a16f-57a6222e3621
📒 Files selected for processing (2)
spec/vulnerabilities.spec.jssrc/Routers/SessionsRouter.js
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
/sessions/me bypasses _Session protectedFields (GHSA-g4v2-qx3q-4p64)
/sessions/me bypasses _Session protectedFields (GHSA-g4v2-qx3q-4p64)/sessions/me bypasses _Session protectedFields (GHSA-g4v2-qx3q-4p64)
|
@coderabbitai resolve |
✅ Actions performedComments resolved and changes approved. |
# [9.8.0-alpha.7](9.8.0-alpha.6...9.8.0-alpha.7) (2026-04-06) ### Bug Fixes * Endpoint `/sessions/me` bypasses `_Session` `protectedFields` ([GHSA-g4v2-qx3q-4p64](GHSA-g4v2-qx3q-4p64)) ([#10406](#10406)) ([d507575](d507575))
|
🎉 This change has been released in version 9.8.0-alpha.7 |
Issue
/sessions/mebypasses_SessionprotectedFields(GHSA-g4v2-qx3q-4p64)Tasks