feat: bind free sessions to accounts to prevent multi-account abuse - #1171
Open
AbhijitK20 wants to merge 2 commits into
Open
feat: bind free sessions to accounts to prevent multi-account abuse#1171AbhijitK20 wants to merge 2 commits into
AbhijitK20 wants to merge 2 commits into
Conversation
added 2 commits
September 1, 2026 04:37
Prevent users from switching accounts mid-session to abuse free-tier limits. When a freebuff session becomes active, it is now bound to the authenticating user's ID. Multiple guard rails enforce this: - /logout blocked during active session (use /end-session or --force) - Login rejected if new user differs from session-bound user - Startup guard ends session if credentials changed externally - Session binding cleared on ended/none/superseded transitions The server already enforces one free session per account; this adds client-side enforcement so the same machine can't cycle through multiple accounts to farm free sessions.
…d tests - Login modal now shows clear error message when rejected due to account mismatch instead of silently reverting to the login screen - /logout --force now releases the server-side session slot and clears the binding before clearing credentials - Added ACCOUNT_SWITCH_BLOCKED analytics event to track abuse attempts - Added unit tests for session binding store and helper functions Addresses review feedback on PR CodebuffAI#1171 for tighter abuse prevention.
AbhijitK20
force-pushed
the
feat/session-account-binding
branch
from
August 31, 2026 23:12
d8e4630 to
792fcc1
Compare
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
Prevents users from switching accounts mid-session to abuse free-tier limits. When a freebuff session becomes active, it is now bound to the authenticating user's ID. Multiple guard rails enforce this:
Changes
cli/src/state/freebuff-session-store.tssessionBoundUserIdstate + settercli/src/hooks/use-freebuff-session.tsactive, clear onended/none/superseded, startup guard for mismatched userscli/src/commands/command-registry.ts/logoutblocked during active session (requires--end-sessionor--force)cli/src/hooks/use-auth-state.tscli/src/data/slash-commands.ts/logouthelp text to document--forceHow it works
Session binds on activation — When the poll loop receives an
activestatus,sessionBoundUserIdis set to the current user's ID fromcredentials.json./logoutblocked — If a session is bound,/logoutshows a warning and suggests/end-sessionfirst. Use/logout --forceto override.Login rejected on mismatch — If someone logs in as a different user while a session is bound to another account, the login is rejected and credentials are cleared.
Startup guard — On mount, if
sessionBoundUserIdexists but doesn't match the current credentials (e.g., credentials were swapped externally), the session is ended immediately.Binding cleared on session end — When the session transitions to
ended,none, orsuperseded, the binding is cleared.Abuse scenario prevented
Notes
--forceflag on/logoutprovides an escape hatch for edge cases