Skip to content
Owais Khan Software Reviews
How-To Guides

what is jwt signature not verified mean and how to fix it

Learn what JWT signature not verified means, why cryptographic checks fail in APIs, common key or algorithm causes, and how to resolve token validation errors.

By Owais Khan

A JWT signature not verified condition means that a JSON Web Token could not be cryptographically validated against its header and payload data, or that a system completely omitted the required cryptographic verification step before accepting token claims. In runtime application environments, this indicates that the receiving server recalculated the expected signature using its cryptographic key and found a mismatch against the token signature, resulting in a rejected request and an authentication error. In security auditing and architecture contexts, it denotes an implementation flaw where a backend service processes client-supplied payload data without properly verifying the cryptographic signature that guarantees message integrity.

Verification Contexts: Operational Rejection Versus Implementation Flaws

The phrase takes on two distinct meanings depending on whether you are observing an active runtime error during token validation or evaluating application security architecture.

In the operational runtime context, the receiving application actively attempts to verify the incoming token as defined by the RFC 7519 standard. The server takes the base64url-encoded header and payload, runs them through the designated cryptographic algorithm alongside a secret key or public certificate, and compares the resulting digest against the signature attached to the token. When these two values do not match, the verification library raises an invalid or unverified signature error, and the server returns an HTTP 401 Unauthorized status. Here, verification failed because of a mismatch in data, keys, or encoding.

In the security architecture context, “JWT signature not verified” refers to a critical vulnerability where an application fails to enforce signature checking altogether. Because JSON Web Tokens are commonly used for stateless authentication and access control where user session state is stored client-side in the token itself, skipping or botching signature verification allows an attacker to alter the payload values—such as user identifiers or administrative roles—without being detected. Understanding which scenario applies to your environment determines whether you are resolving a cryptographic configuration bug or patching an application security vulnerability.

The Primary Runtime Context: Cryptographic Mismatch and Authentication Rejection

In standard API workflows, an application handles incoming requests statelessly. Rather than querying a server-side session store, the backend inspects the token provided in the HTTP request. A JSON Web Signature (JWS) consists of three parts separated by periods: the JOSE header, the payload, and the signature. Both the header and payload are base64url-encoded JSON objects. The header specifies metadata such as the signing algorithm (alg) and the token type (typ), while the payload carries identity and access claims.

The signature is generated by hashing the encoded header and payload combined with a secret key or private cryptographic key. When the server receives this token, it executes the identical cryptographic calculation. If a single byte of the header or payload has changed in transit, the calculated hash diverges entirely from the signature provided in the token, causing a signature verification failure.

In functional code, an unverified signature at runtime stems from one of four primary issues:

  1. Secret or Key Mismatch: The token issuer signed the token with one secret, but the verifying service attempted to validate it with a different secret or an environment-specific key (such as using a development secret against a production token).
  2. Secret Encoding Divergence: Cryptographic signing functions treat raw strings and encoded buffers differently. If a secret was generated as a base64-encoded string, but the verifying library evaluates it as a literal UTF-8 string without decoding it into its underlying byte buffer, the calculated signature will not match.
  3. Algorithm Mismatch: The token header specifies one cryptographic mechanism—such as asymmetric RSA (RS256) or ECDSA—while the verifying service expects a symmetric HMAC secret (HS256). Attempting to verify an asymmetric signature using a symmetric verification method causes the process to fail immediately.
  4. Key Formatting Flaws: Asymmetric algorithms like RS256 require keys to follow standardized formats. If a public key string lacks the necessary PEM header wrappers, or contains structural formatting errors, the cryptographic engine cannot read the key correctly, leading to signature rejection.

While you can inspect claims manually or inspect raw token segments using a JWT Decoder, cryptographic integrity cannot be assumed until the server mathematically proves the signature against its configured key.

The Security Flaw Context: Applications That Fail to Verify Signatures

When security professionals or vulnerability scanners report that a JWT signature is not verified, they are pointing to a design flaw where the server accepts and acts on token claims without verifying the cryptographic signature.

Because the header and payload of a standard JWS token are only base64url-encoded and not encrypted, any client can read and edit their contents. Under a secure implementation, tampering with the payload invalidates the signature, causing the server to reject the modified token. However, flawed application logic can undermine this protection in several ways:

  • Skipping the Verification Step Entirely: Developers may use convenience functions that only decode the payload without executing the cryptographic verification method. The server extracts claims like user IDs or role assignments directly from untrusted input, granting unauthorized access.
  • Accepting the None Algorithm: The token specification accommodates unsigned tokens via the none algorithm value in the alg header parameter. Vulnerable servers accept tokens where alg is set to none with an empty signature segment, allowing malicious actors to forge arbitrary identities and administrative privileges.
  • Algorithm Confusion: When an application supports both symmetric algorithms (like HS256) and asymmetric algorithms (like RS256), flawed implementations may allow an attacker to sign a token using HS256 with the server’s public key as the shared HMAC secret. If the server does not enforce allowed algorithm lists, it verifies the token using its public key as a symmetric secret, improperly authenticating the forged signature.

Worked Example: Diagnosing and Resolving a Verification Failure

To see how signature verification succeeds or fails mathematically, consider a scenario where a backend service validates incoming user tokens using symmetric HMAC-SHA256 (HS256).

Step 1: Token Creation

The authentication server constructs a JOSE header and a set of claims:

Header:

{
 "alg": "HS256",
 "typ": "JWT"
}

Base64url representation: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9

Payload:

{
 "sub": "usr_4492",
 "tenant": "retail_prod",
 "role": "staff"
}

Base64url representation: eyJzdWIiOiJ1c3JfNDQ5MiIsInRlbmFudCI6InJldGFpbF9wcm9kIiwicm9sZSI6InN0YWZmIn0

The server sets a 256-bit secret key: secret-audit-key-8812

The signature is calculated over the combined signing input: signingInput = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3JfNDQ5MiIsInRlbmFudCI6InJldGFpbF9wcm9kIiwicm9sZSI6InN0YWZmIn0"

The resulting HMAC-SHA256 signature produces a unique base64url string. The complete token transmitted to the client is: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3JfNDQ5MiIsInRlbmFudCI6InJldGFpbF9wcm9kIiwicm9sZSI6InN0YWZmIn0.gK-5t1N66q7Yl9eJ_u0E5n6f8-v_4b_example_sig

Step 2: The Failed Verification Attempt

A receiving API service attempts to verify this token, but the environment configuration contains an incorrect key (secret-audit-key-9999) or an altered payload where a user modified "role": "staff" to "role": "admin".

const jwt = require('jsonwebtoken');

const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3JfNDQ5MiIsInRlbmFudCI6InJldGFpbF9wcm9kIiwicm9sZSI6InN0YWZmIn0.gK-5t1N66q7Yl9eJ_u0E5n6f8-v_4b_example_sig';
const verificationKey = 'secret-audit-key-9999'; // Incorrect secret key

try {
 // Attempting verification with mismatched key
 const verifiedData = jwt.verify(token, verificationKey, { algorithms: ['HS256'] });
 console.log('Verification passed:', verifiedData);
} catch (error) {
 // Execution lands here
 console.error('Failure:', error.message); // Outputs: "invalid signature"
}

The server recomputes the HMAC hash of the signing input using secret-audit-key-9999. Because the key differs from secret-audit-key-8812, the newly computed digest does not match the token signature. The library throws an invalid signature exception, preventing unauthorized execution.

Step 3: Correcting the Implementation

To resolve the error, the verifying service must use the identical secret and explicitly restrict permitted algorithms to prevent substitution attacks:

const jwt = require('jsonwebtoken');

const token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ1c3JfNDQ5MiIsInRlbmFudCI6InJldGFpbF9wcm9kIiwicm9sZSI6InN0YWZmIn0.gK-5t1N66q7Yl9eJ_u0E5n6f8-v_4b_example_sig';
const correctKey = 'secret-audit-key-8812';

try {
 // Enforce correct secret and explicit algorithm allowlist
 const payload = jwt.verify(token, correctKey, {
 algorithms: ['HS256']
 });
 console.log('Verification successful. Subject:', payload.sub);
} catch (error) {
 console.error('Validation failed:', error.message);
}

Diagnostic Workflow: Determining Your Specific Verification Scenario

To identify whether your issue is a development configuration bug or an architectural vulnerability, follow this diagnostic path:

  1. Check the System Response: If an API call fails with an HTTP 401 response or your application logs display invalid signature, you are dealing with a runtime verification rejection. The security mechanism is functioning as intended by rejecting unverified data.
  2. Validate the Verification Key: Confirm that the secret or public certificate configured in the consuming service matches the exact key used by the issuing server. If using asymmetric algorithms (RS256, ES256, PS256), ensure the verifying service uses the public key, formatted with appropriate PEM headers, rather than a symmetric secret or private key.
  3. Inspect Secret Encoding: If using shared secrets, verify whether the signing service treated the key string as raw UTF-8 bytes, hex-encoded bytes, or a base64-encoded buffer. If the issuer encoded random bytes as base64, the verifier must decode that base64 string into a buffer before executing the signature verification function.
  4. Audit Token Parsing Logic for Vulnerabilities: If your application accepts tokens without raising errors even when claims are manually altered, your code has an implementation flaw. Search your codebase to ensure incoming tokens pass through a strict cryptographic verification routine that explicitly defines allowed algorithms and bans the none algorithm.

Open the JWT Decoder

Frequently asked questions

What is the difference between decoding a JWT and verifying its signature?
Decoding merely parses the base64url-encoded JSON header and payload into readable text without checking its authenticity. Verifying uses a secret or public key to recalculate the cryptographic hash and ensure the token has not been modified since issuance.
Why does changing a single claim cause an invalid signature error?
The signature is directly derived from a cryptographic hash of the combined header and payload. Changing even a single character in the claims alters the computed hash completely, creating an immediate mismatch with the attached signature.
What happens if a server accepts the none algorithm?
If a server accepts the none algorithm, it allows tokens that contain no signature at all. Attackers can forge arbitrary claims in the payload, such as elevating user privileges or spoofing identities, completely bypassing authentication controls.
How does an algorithm mismatch cause a signature verification error?
An algorithm mismatch occurs when a token signed with one method, such as asymmetric RS256, is verified using another, such as symmetric HS256. The cryptographic calculation cannot evaluate the signature correctly, prompting a verification failure.