Skip to content
Access control Disclosed report Intermediate CVE-2022-22576

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.

monnerat Follow

Originally disclosed on HackerOne

Medium 5.1 View original
  • 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

The original report as published on HackerOne, by monnerat. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

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

  1. Send a first request to an IMAP URL using OAUTHBEARER login options with a valid bearer token.
  2. Send a second request to the same URL using OAUTHBEARER login options with an invalid bearer token.
  3. 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.

More by monnerat

View all

5 more disclosed reports, best first.

More from curl

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.