Skip to content

OAuth2 credentials exploit with permanent validity

High
phlax published GHSA-7mhv-gr67-hq55 Jul 25, 2023

Package

Envoy

Affected versions

< 1.27.0

Patched versions

1.26.4, 1.25.9, 1.24.10, 1.23.12

Description

Summary

Malicious clients can construct OAuth2 credentials with permanent validity.

Affected component

OAuth2 filter

Details

Malicious client is able to construct credentials with permanent validity in some specific scenario. This is caused by some rare scenarios in which HMAC payload can be always valid in OAuth2 filter's check.

PoC

If the virtual host is configured with domains: ["*"], a user can put anything in the HOST header while logging in and going through the OAuth2 flow.

If the client sets the host header with a port like 13518, it is still able to go through the OAuth2 login flow. Even though the client will be redirected to e.g. example.com:13518/ at the very end of the flow, Envoy will still issue the cookies and a valid signature to the client based on the given host header like example.com:13518.

At this point, the correct signature is computed like this:

signature = hmac("example.com:13518" + "1668386659" + "ya29.a0AeTM1icl..." + ...)

Now, the malicious client can change their HOST header override and remove numbers from the port section and instead add them at the start of the OauthExpires cookie.

When Envoy gets the request, it will compute a signature like:

signature = hmac("example.com:1" + "35181668386659" + "ya29.a0AeTM1icl..." + ...)

This leads to an identical signature to the signature considered valid.

Once the HMAC validation passes, Envoy will read the OauthExpires value as 35181668386659 which instead of seconds since epoch is interpreted as milliseconds since epoch.

For this example, the expiration time as interpreted by Envoy, will be in the year 3084.

Using this methodology, the attacker is able to gain permanent access until the HMAC secret in Envoy is rotated.

Attack Vectors

Malicious clients construct bad credentials.

Impact

Negative impacts on the security and integrity of the service.

Mitigation

Avoid wildcards/prefix domain wildcards in host's domain configuration.

Credits

Erik Engberg [email protected]

Severity

High

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
Low

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:L/A:L

CVE ID

CVE-2023-35941

Weaknesses

Credits