
This project demonstrates the CVE-2022-21449 vulnerability, which affects Java's ECDSA signature verification. The vulnerability allows a malicious actor to bypass signature verification by using a signature with zero values (r=0 and s=0). The project uses real and fake JWT tokens with EC signatures to showcase the issue on Java 17 without the security patch.
r=0, s=0).JwtGenerator: Generates real and fake JWT tokens.JwtUtils: Validates JWT tokens using a public EC key.SecurityConfig: Configures Spring Security to demonstrate token-based authentication.ProtectedController: Provides endpoints to test token-based access control.JwtGenerator Console AppThe JwtGenerator class is a standalone console application that generates and prints both valid and fake JWT tokens.
Build the Project:
mvn clean install
Run the JwtGenerator Class:
mvn exec:java -Dexec.mainClass="com.symphony_solutions.demo.util.JwtGenerator"
Output: The application will print:
Example:
=== Valid JWT ===
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJhbGljZSIsInJvbGVzIjpbIkFETUlOIiwiVVNFUiJdLCJpYXQiOjE2NzAwMDAwMDAsImV4cCI6MTY3MDAzNjAwMH0.<signature>
=== Fake JWT with zero signature ===
eyJhbGciOiJFUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJib2IiLCJyb2xlcyI6WyJBRE1JTiIsIlVTRVIiXSwiaWF0IjoxNjcwMDAwMDAwLCJleHAiOjE2NzAwMzYwMDB9.<zeroed_signature>
Use the Tokens:
Start the Application:
mvn spring-boot:run
Access Protected Endpoints:
/protected/user or /protected/admin.Endpoints:
/protected/user: Requires USER or ADMIN role./protected/admin: Requires ADMIN role.This project is licensed under the MIT License.