Summary
NPM’s package @evershop/evershop prior to 1.0.0-rc.8 has the HMAC secret used for generating tokens hardcoded as “secret”. A weak HMAC secret poses a risk because attackers can use the predictable secret to create valid JSON Web Tokens (JWTs), allowing them access to important information and actions within the application. This vulnerability has been fixed by implementing session authentication.
Product
This vulnerability affects NPM’s package @evershop/evershop in versions prior to 1.0.0-rc.8.
Impact
This vulnerability allows for easy forging of valid JWTs, enabling unauthorized access to sensitive information, such as obtaining Admin IDs and performing potentially harmful actions within the application.
Steps to reproduce
- Install the
@evershop/evershoppackage dependency for any version prior to 1.0.0-rc.8 - Run the EverShop Web Application on localhost
- Craft a malicious JWT token with the forged HMAC secret (the token should contain the key
"user":{"isAdmin": true}) - Make a
POSTrequest to GraphQL API (ensure that the request includes the Cookie header with a cookie named ‘admin_token’ and set its value to the forged JWT) with the following query to obtain a list of Admin IDs and retrieve detailed information about a specific admin user:{"query": "query {ntadminUsers(filters:[]) {nttcurrentFilters {ntttoperationntt}ntttotalnnttitems {ntttadminUserIdntt}nt}n}"} - Once the Admin ID is obtained make a
POSTrequest to GraphQL API with the following query (in this example Admin ID: 1) to obtain full information about the user, including its UUID:{"query": "query {ntadminUser(id:1) {nttadminUserIdnttfullNamenttuuidnttemailnttstatusnt}n}"} - Utilize the obtained administrator information to construct a valid JWT to perform more sensitive actions within the application.
Expected result:
Complete exploitation of the application, by extracting detailed information about a specific admin user which can be used to build a perfectly valid JWT.
Remediation
A fix was released in commit 187260b, where Express session authentication was implemented. Users are recommended to upgrade to version 1.0.0-rc.8, which includes this fix.
Credit
This issue was discovered and reported by Checkmarx SCA Security Analyst Bruno Dias.