fix(auth): revoke web sessions on logout#2351
Open
jeanduplessis wants to merge 4 commits intomainfrom
Open
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (15 files)
Reviewed by gpt-5.4-20260305 · 368,075 tokens |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Code-related pentest findings [private access to Kilo team members only] are now addressed without broad product rewrites. Each fix focuses on closing the reported behavior while preserving existing auth, analytics, payments, and device-token flows.
M2: Web session revocation after logout
kilocode_users.web_session_version, stores that version in the NextAuth JWT/session at sign-in, and rejects requests ingetUserFromAuthwhen the session version no longer matches the database row.POST /api/auth/revoke-web-sessionand call it from normal sign-out, auto sign-out, and dev account nuke flows before client-side sign-out.webSessionVersion; those are treated as version0only while the database row is still0. After any revocation increments the row, legacy cookies fail like any other stale session.web_session_versionis not a secret. It is a revocation counter inside a signed/encrypted NextAuth JWT. Knowing the next number does not help unless an attacker can mint a valid NextAuth token.api_token_pepperon logout. That would have fixed stale web sessions, but it would also revoke CLI/device/API tokens unexpectedly. A separate web-only version keeps logout scoped to browser sessions.M2: Route-level admin API authorization
getUserFromAuth({ adminOnly: true })checks to the credit category admin API endpoints.getUserFromAuthandadminProcedureenforcesctx.user.is_admin./admin/api/**file to visibly call direct admin auth, the tRPC-backed enrichment route can be tightened separately for consistency.Verification
.plans/pentest-findings.mdfor code-related L1 scope./api/userreturning401after revocation with stale cookie, re-login after revocation, and stale admin route rejection for/admin/api/credit-categories.Visual Changes
N/A
Reviewer Notes
Code Reviewer Notes
kilocode_users.web_session_versioncolumn and stores the version in the NextAuth JWT/session at sign-in.0whileweb_session_versionremains0, avoiding a blanket logout on rollout.getUserFromAuthrejects stale web sessions when the session version no longer matches the database row.POST /api/auth/revoke-web-sessionbefore client-sidesignOut; the endpoint is intentionally idempotent and only increments web session state.adminProcedure.mainas0086_cool_night_thrasherafterorigin/mainadded its own 0085 migration.