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 ejohansson@spotify.com

Severity

High
8.6
/ 10

CVSS base metrics

Attack vector
Network
Attack complexity
Low
Privileges required
None
User interaction
None
Scope
Unchanged
Confidentiality
High
Integrity
Low
Availability
Low
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