logo

Database

C Sharp Jwt Signed Without Verification

Description

Detects potentially insecure JWT token creation in C# code where proper signature verification is missing. This vulnerability could allow attackers to forge or tamper with JWT tokens if they're not properly verified, leading to authentication bypass or privilege escalation.

Weakness:

017 - Sensitive information sent insecurely

Category: Information Collection

Detection Strategy

    Identifies usage of JwtBuilder class in C# code

    Checks if the JWT token creation is missing signature verification by examining the code flow

    Reports a vulnerability when JwtBuilder is used without proper signature validation methods

    Specifically looks for JWT token creation patterns that don't include verification steps in the builder chain

Vulnerable code example

using System;

class JwtExample {
    public static void Main() {
        string secret = "mySecret";
        string token = "someToken";

        // Vulnerable: Decoding JWT without signature verification...

✅ Secure code example

using System;

class JwtExample {
    public static void Main() {
        string secret = "mySecret";
        string token = "someToken";

        // Secure: JWT decoding with mandatory signature verification...