CVE-2020-7787 in react-adalinfo

Summary

by MITRE • 12/09/2020

This affects all versions of package react-adal. It is possible for a specially crafted JWT token and request URL can cause the nonce, session and refresh values to be incorrectly validated, causing the application to treat an attacker-generated JWT token as authentic. The logical defect is caused by how the nonce, session and refresh values are stored in the browser local storage or session storage. Each key is automatically appended by ||. When the received nonce and session keys are generated, the list of values is stored in the browser storage, separated by ||, with || always appended to the end of the list. Since || will always be the last 2 characters of the stored values, an empty string ("") will always be in the list of the valid values. Therefore, if an empty session parameter is provided in the callback URL, and a specially-crafted JWT token contains an nonce value of "" (empty string), then adal.js will consider the JWT token as authentic.

If you want to get the best quality for vulnerability data then you always have to consider VulDB.

Analysis

by VulDB Data Team • 12/15/2020

The vulnerability described in CVE-2020-7787 represents a critical authentication bypass flaw within the react-adal package, a widely used authentication library for azure active directory integration in react applications. This issue stems from improper handling of nonce, session, and refresh token validation mechanisms that are fundamental to preventing replay attacks and ensuring token authenticity. The vulnerability affects all versions of the package and creates a scenario where malicious actors can craft specific JWT tokens that bypass the authentication checks due to flawed storage and validation logic.

The technical root cause of this vulnerability lies in how the library stores and validates authentication parameters within browser storage mechanisms. Specifically, the implementation stores nonce, session, and refresh values in localStorage or sessionStorage using a delimiter pattern where each key is automatically appended with the double pipe character "||". When values are stored, they are separated by "||" and always have "||" appended to the end of the list. This design creates a logical flaw where an empty string value is always present in the valid values list due to the trailing delimiter. The implementation treats this empty string as a legitimate validation parameter, creating a security loophole that can be exploited by attackers.

The operational impact of this vulnerability is severe and directly affects the integrity of authentication systems relying on react-adal. An attacker can craft a malicious callback URL with an empty session parameter and a specially crafted JWT token containing an empty string nonce value. When the authentication flow processes this malicious request, the library incorrectly validates the token as authentic because it accepts the empty string as a valid nonce value. This allows unauthorized users to bypass authentication mechanisms and gain access to protected resources that should only be available to legitimate authenticated users.

This vulnerability maps directly to CWE-347, which addresses improper certificate validation and authentication bypass issues in security systems. The flaw demonstrates poor input validation and storage handling practices that violate fundamental security principles. From an ATT&CK framework perspective, this represents a privilege escalation technique through authentication bypass, specifically targeting the credential validation process and potentially enabling lateral movement within affected systems. The vulnerability also relates to T1566, which covers credential harvesting and manipulation techniques that exploit authentication system weaknesses.

Mitigation strategies should focus on immediate code-level fixes to address the storage and validation logic. Developers must ensure that empty string values are properly rejected during validation and that the delimiter-based storage mechanism does not inadvertently include empty values in the valid parameter list. Organizations should update to patched versions of react-adal or migrate to more secure authentication libraries such as msal.js or azure-activedirectory-library-for-js. Additionally, implementing proper input sanitization, validating all authentication parameters against expected formats, and monitoring for unusual authentication patterns can help detect exploitation attempts. Regular security audits of authentication libraries and components should be conducted to identify similar vulnerabilities in other third-party dependencies.

Responsible

Snyk

Reservation

01/21/2020

Disclosure

12/09/2020

Moderation

accepted

CPE

ready

EPSS

0.00267

KEV

no

Activities

very low

Sources

Are you interested in using VulDB?

Download the whitepaper to learn more about our service!