fix(security): enforce session revocation on URL-token endpoints - #397
fix(security): enforce session revocation on URL-token endpoints#397seonghobae wants to merge 23 commits into
Conversation
The `/api/projects/:id/calendar.ics` and `/api/projects/:id/stream` endpoints accept auth tokens via query parameters. While they verified the JWT signature, they failed to query the database to ensure the user's `token_version` matched the token's payload. This allowed revoked tokens (e.g. after a user logged out everywhere, changed passwords, or deleted their account) to continue accessing project data via these specialized endpoints. This commit updates both endpoints to perform the same database verification against `users.token_version` as the primary middleware.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
Warning Review limit reached
Next review available in: 1 minute Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (4)
📝 WalkthroughWalkthroughChanges세션 폐기 인증
MS Project XML 파서
Node.js 및 패키지 설정
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant CalendarSSE
participant JWTVerifier
participant UsersDatabase
Client->>CalendarSSE: 쿼리 JWT 요청
CalendarSSE->>JWTVerifier: JWT 서명 검증
JWTVerifier-->>CalendarSSE: 사용자 ID와 tv 반환
CalendarSSE->>UsersDatabase: token_version 조회
UsersDatabase-->>CalendarSSE: 현재 token_version 반환
CalendarSSE-->>Client: 일치하면 200, 불일치하면 401
Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Comment |
…ent ReDoS The `parseMsProjectXml` function in `cloud-sync.js` previously constructed a dynamic regular expression using `new RegExp()` to extract XML tag values. If the `name` parameter were somehow derived from unvalidated input, this could expose the application to Regular Expression Denial of Service (ReDoS) attacks by executing complex, potentially backtracking expressions on the main thread. This commit replaces the non-literal `RegExp` with safe, exact string matching using `indexOf` and `slice`. This implementation avoids regular expressions entirely for this parsing step, mitigating the ReDoS vulnerability and resolving the related SAST scan warning.
This commit addresses two separate security findings: 1. Upgrades `@hono/node-server` to version 2.0.12 (via `pnpm update`) to resolve a moderate severity vulnerability (GHSA-frvp-7c67-39w9) flagged by trivy-fs and `pnpm audit`. 2. Refactors `parseMsProjectXml` in `cloud-sync.js` to avoid using a dynamic non-literal `RegExp` constructor. A SAST scan flagged this as a potential Regular Expression Denial of Service (ReDoS) vulnerability. We replace the regex with exact string matching using `indexOf` and `slice` to safely extract XML tag values without the risk of backtracking.
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Pull request was converted to draft
|
@coderabbitai review |
✅ Action performedReview finished.
|
Pull request was converted to draft
476cc9c to
f8ad361
Compare
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
|
@coderabbitai review |
✅ Action performedReview finished.
|
Pull request was converted to draft
eed71f5 to
5ed7fa1
Compare
|
Superseded by #414. This bot-owned branch was overwritten again after successful verification: commit |
Pull request was closed
Summary
Close a HIGH-severity session-revocation gap in every project endpoint that accepts a session JWT outside the normal bearer middleware:
/api/projects/:id/calendar.ics?token=.../api/projects/:id/stream?token=.../api/projects/:id/attachments/:attachment_id/view?token=...A shared
verifySessionJwtboundary verifies the JWT signature, loads the referenced user, and compares the tokentvclaim with the current databasetoken_version. Missing users, malformed tokens, expired tokens, and stale sessions fail closed with401 Unauthorized. PAT header paths remain available where supported.Security impact
Before this change, a query-transport session token could remain usable until expiration after password change or logout all devices incremented
token_version. A leaked token could therefore continue reading project data through URL-token endpoints.This PR establishes consistent revocation semantics on the existing authentication model. It is a prerequisite for issue #413, which will replace full session JWTs in URLs with narrowly scoped ephemeral grants and separately revocable calendar subscription secrets.
Regression coverage
tests/api/session-revocation.test.mjscreates two concurrent device sessions and proves:401on all three URL-token transports afterlogout-all;verifySessionJwtsecurity boundary.The attachment test uses a deliberately missing attachment: a valid session reaches tenant-scoped lookup and receives
404, while a stale session is rejected earlier with401.Included baseline synchronization
The branch carries the linear MS Project XML parser and current dependency/runtime lock synchronization required for clean security and CI evidence against the present
developbase. Overlapping changes collapse from the final diff after PR #386 merges.Verification
Current head
5ed7fa125bcf63df4bb548d8bc244ac4ddf0054ccompleted successfully:npm run test:unitnpm run test:apinpm run coverageThe completed one-shot repair workflow was removed before merge so no self-modifying write-token workflow can enter
develop. The security verification note now covers calendar, SSE, and attachment-view authentication, including valid-session404versus revoked-session401ordering.CHANGELOG.mdrecords both the centralized session-revocation invariant and the cross-device URL-transport regression evidence.Merge policy
Auto-merge is enabled. Merge only after exact-head checks remain successful and a non-author approval satisfies branch protection.