CVE-2020-28042 Overview
CVE-2020-28042 is an authentication bypass vulnerability in ServiceStack before version 5.9.2 that mishandles JWT signature verification. The flaw allows attackers to bypass signature validation unless an application implements a custom ValidateToken function that enforces a minimum length requirement for signatures. This vulnerability enables attackers to forge authentication tokens and potentially gain unauthorized access to protected resources.
Critical Impact
Attackers can bypass JWT signature verification to forge authentication tokens, potentially gaining unauthorized access to protected endpoints and sensitive data within ServiceStack-based applications.
Affected Products
- ServiceStack versions prior to 5.9.2
- Applications using ServiceStack JWT authentication without custom ValidateToken implementations
- ServiceStack-based web services and APIs relying on default JWT verification
Discovery Timeline
- 2020-11-02 - CVE CVE-2020-28042 published to NVD
- 2024-11-21 - Last updated in NVD database
Technical Details for CVE-2020-28042
Vulnerability Analysis
This vulnerability falls under CWE-347 (Improper Verification of Cryptographic Signature). The root issue lies in the EquivalentTo function within ServiceStack's EnumerableExtensions.cs file, which performs byte array comparisons for JWT signature verification. The original implementation failed to properly validate null values and length mismatches before performing the comparison operation.
The vulnerable code would iterate through the other byte array without first verifying that both arrays are non-null and of equal length. This creates a scenario where an attacker could supply a signature of any length (including an empty signature), and the comparison logic would not properly reject it. The comparison loop used XOR operations to compare bytes, but without length validation, this approach is fundamentally flawed.
Root Cause
The vulnerability stems from missing null checks and length validation in the EquivalentTo byte array comparison function. Before the patch, the function would begin XOR comparisons immediately without verifying that both byte arrays exist and have matching lengths. This oversight allowed malformed JWT signatures to potentially pass verification.
Attack Vector
The attack exploits the network-accessible JWT authentication mechanism. An attacker can craft a JWT token with a manipulated or empty signature and submit it to a ServiceStack application. Due to the improper signature verification logic, tokens that should be rejected may be accepted as valid, allowing unauthorized access without requiring any user interaction or special privileges.
The vulnerability is exploitable over the network with low attack complexity, requiring no privileges or user interaction to execute.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool EquivalentTo(this byte[] bytes, byte[] other)
{
+ if (bytes == null || other == null)
+ return bytes == other;
+
+ if (bytes.Length != other.Length)
+ return false;
+
var compare = 0;
for (var i = 0; i < other.Length; i++)
compare |= other[i] ^ bytes[i];
Source: ServiceStack Commit Update
Detection Methods for CVE-2020-28042
Indicators of Compromise
- Authentication events with abnormally short or empty JWT signatures in request logs
- Successful authentication for tokens that contain malformed or missing signature components
- Unexpected access patterns to protected resources without valid credentials
- JWT tokens with signature lengths that deviate from expected cryptographic output sizes
Detection Strategies
- Implement logging and alerting on JWT validation events, specifically monitoring for tokens with zero-length or unusually short signatures
- Review authentication logs for successful logins that bypass normal JWT signature validation paths
- Deploy application-level monitoring to detect authentication anomalies and unusual access patterns
- Audit ServiceStack version deployments across your infrastructure to identify vulnerable instances
Monitoring Recommendations
- Enable verbose logging for JWT authentication events in ServiceStack applications
- Monitor for authentication attempts with malformed JWT structures using web application firewalls
- Set up alerts for successful authentication events that originate from unusual sources or patterns
- Track and baseline normal JWT token sizes to identify statistical anomalies
How to Mitigate CVE-2020-28042
Immediate Actions Required
- Upgrade ServiceStack to version 5.9.2 or later immediately to receive the security fix
- Audit all applications using ServiceStack JWT authentication for potential exploitation
- Review authentication logs for any evidence of signature bypass attempts
- Implement additional authentication controls as a defense-in-depth measure while patching
Patch Information
The vulnerability has been addressed in ServiceStack version 5.9.2. The fix adds proper null checks and length validation to the EquivalentTo function before performing byte array comparisons. The security patch is available through the ServiceStack Release Announcement and the ServiceStack Commit Update can be reviewed for technical details.
For additional security context and advisory information, refer to the Shielder Security Advisory and Shielder Blog on JWT Bypass.
Workarounds
- Implement a custom ValidateToken function that enforces minimum signature length requirements
- Add application-layer validation to reject JWT tokens with signatures shorter than expected cryptographic output
- Deploy a reverse proxy or web application firewall rule to inspect and reject malformed JWT tokens
- Consider implementing additional authentication mechanisms as a temporary secondary validation layer
# Update ServiceStack to patched version
dotnet add package ServiceStack --version 5.9.2
# Verify installed version
dotnet list package | grep ServiceStack
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.


