Fix: Authentication Bypass via predictable JWT secret and empty token validation #7998
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.
Description
There's a critical authentication bypass vulnerability that allows remote attackers to gain unauthorized access to user accounts without any credentials. The vulnerability stems from two security flaws: (1) the application uses a predictable
SECRET_KEY
that defaults to the current date, and (2) the authentication mechanism fails to properly validate empty access tokens left by logged-out users. When combined, these flaws allow attackers to forge valid JWT tokens and authenticate as any user who has previously logged out of the system.The authentication flow relies on JWT tokens signed with a
SECRET_KEY
that, in default configurations, is set tostr(date.today())
(e.g., "2025-05-30"). When users log out, theiraccess_token
field in the database is set to an empty string but their account records remain active. An attacker can exploit this by generating a JWT token that represents an empty access_token using the predictable daily secret, effectively bypassing all authentication controls.Source - Sink Analysis
Source (User Input): HTTP Authorization header containing attacker-controlled JWT token
Flow Path:
load_user()
function inapi/apps/__init__.py
(Line 142)api/settings.py
(Line 123)UserService.query()
called with decoded empty access_tokenProof of Concept
Exploitation Steps:
Version: 0.19.0
@KevinHuSh @asiroliu @cike8899