Summary
PolarLearn versions 0-PRERELEASE-15 and earlier contain an authentication logic flaw where the POST /api/v1/auth/sign-in endpoint creates a valid session for banned accounts before verifying the supplied password.
Because this prematurely issued session is trusted across authenticated /api routes, a banned account holder can regain access to their account data and perform authenticated actions despite the ban.
Affected context
This vulnerability affects PolarLearn deployments that expose the /api/v1/auth/sign-in endpoint and rely on it to enforce bans and authenticate users.
The issue occurs when the application creates a server-side session object for a banned account prior to fully validating credentials and ban status, and when downstream authenticated /api routes trust the existence of that session token as proof of legitimate, allowed access.
Exploit preconditions
- Attack surface: Public HTTP API, specifically POST /api/v1/auth/sign-in.
- Required access: Knowledge of a banned account identifier (e.g., email/username) and ability to send HTTP requests to the PolarLearn API.
- Trigger point: Initiating a sign-in attempt for a banned account, relying on the flawed order of operations that creates a session before verifying the password or enforcing the ban.
- Why exploitation is possible: The authentication flow incorrectly establishes a valid session for banned users early in the process, and downstream /api routes rely solely on the presence and validity of this session, not on re-checking ban status or credential verification state.
Why this happens
The root cause is an improper authentication sequence that violates the principle of "authenticate then authorize."
Within the sign-in handler, the application appears to:
- Look up the user record (including banned accounts),
- Create a session tied to that account,
- Only then verify the password and/or ban status.
Because the session is created before all checks pass, and because subsequent authenticated endpoints treat the session as fully trusted, a banned user can obtain and use a valid session token.
This maps to CWE-287: Improper Authentication, where authentication decisions are made incorrectly due to flawed logic or ordering, allowing unauthorized access despite intended restrictions such as account bans.
Potential impact
- Banned users may regain access to their accounts and associated personal data.
- Banned users could perform authenticated actions that the ban was supposed to prohibit (e.g., posting, submitting content, or modifying learning data).
- Application-level policy enforcement (such as moderation decisions) can be undermined.
- Audit trails and moderation workflows may be skewed by activity from accounts that should be inactive.
General mitigation guidance
Effective mitigation focuses on correcting the authentication flow and tightening session handling:
- Ensure that no session is created until all authentication checks have passed, including password validation and account status (banned, disabled, or locked).
- Centralize authentication and authorization logic so that ban and status checks are applied consistently before issuing tokens or sessions.
- Treat account bans and similar restrictions as hard authorization gates on every privileged action or at least on every authenticated request, not just at login.
- Normalize user state transitions (active, banned, locked) and enforce them in a single, well-reviewed component rather than ad-hoc checks scattered across handlers.
- Apply the principle of least privilege to sessions: encode only necessary claims and ensure that claims reflecting account status are validated server-side on each request.
How teams detect issues like this
Organizations can detect and prevent similar issues with:
- Code review practices that inspect authentication handlers for correct ordering: user lookup → credential verification → status checks → session/token issuance.
- Static analysis rules that flag session or token creation prior to password verification or status validation in authentication flows.
- Security-focused tests (unit, integration, and API tests) that explicitly cover edge cases: banned, disabled, expired, or locked accounts attempting to sign in.
- Runtime monitoring and logs that highlight anomalous activity from banned accounts, such as successful authenticated requests following failed login attempts.
- Use of automated security review tools that model authentication flows and detect inconsistent enforcement of account status checks across endpoints.

