CVE-2022-22576: OAUTH2 bearer bypass in connection re-use
A cached connection authenticated with OAUTH2 can be reused by a later request even when the bearer token is incorrect. An attacker could gain unauthorised read or write access to data on SASL-enabled protocols such as IMAP, SMTP, POP3 and LDAP.
- Triaged in under an hour
- Fixed in 28 days
- Disclosed after 30 days
Summary:
A cached connection authenticated with the OAUTH2 mechanisms can be reused by a subsequent request even if the bearer is not correct. This affects SASL-enabled protcols: SMPTP(S), IMAP(S), POP3(S) and LDAP(S) (openldap only).
An application that can be accessed by more than one user (such as a webmail server) would be affected by this flaw.
Steps To Reproduce:
curl 'imap://server:port/path/;MAILINDEX=1' --login-options 'AUTH=OAUTHBEARER' -u user: --oauth2-bearer validbearer --next 'imap://server:port/path/;MAILINDEX=1' --login-options 'AUTH=OAUTHBEARER' -u user: --oauth2-bearer anything
Supporting Material/References:
- Patch 0001-url-check-sasl-additional-parameters-for-connection-.patch fixes this flaw.
As an alternative to apply the patch, use another (unused) password within each request: the second request in the command below will properly fail.
curl 'imap://server:port/path/;MAILINDEX=1' --login-options 'AUTH=OAUTHBEARER' -u user:dummy1 --oauth2-bearer validbearer --next 'imap://server:port/path/;MAILINDEX=1' --login-options 'AUTH=OAUTHBEARER' -u user:dummy2 --oauth2-bearer anything
Impact
Access (read/write) unauthorized data
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the connection cache key did not include the SASL additional parameters (such as the OAUTH2 bearer token), so a connection authenticated with one token was reused for a request with a different token.
Impact
An attacker could gain unauthorised read or write access to data on an application used by more than one user, such as a webmail server.
What the attacker needed
SASL-enabled protocol (IMAP, SMTP, POP3, LDAP); Application shared by multiple users; A valid bearer token for the first request
How it was found
- Send a first request to an IMAP URL using OAUTHBEARER login options with a valid bearer token.
- Send a second request to the same URL using OAUTHBEARER login options with an invalid bearer token.
- Observe that the second request succeeds because the cached connection is reused.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a program connects to a mail or directory server, it can keep the connection open and reuse it for later requests. This report says that if the first request logged in with a valid token, a second request on the same reused connection was accepted even though its token was wrong. That means someone could read or change data they should not be allowed to see.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.