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

OAUTH2 bearer not-checked for connection re-use

libcurl could reuse an OAUTH2-authenticated connection for a new transfer even when the new transfer used a different OAUTH2 bearer token, potentially allowing an authentication bypass. An attacker could gain unauthorised access to a service if a connection authenticated with a valid token was reused for a request with an invalid token.

monnerat Follow

Originally disclosed on HackerOne

  • Fixed in 26 hours
  • Paid in 26 hours
  • Disclosed after 43 hours

Summary by the program

OAUTH2 bearer bypass in connection re-use Project curl Security Advisory, April 27th 2022 - Permalink

VULNERABILITY libcurl might reuse OAUTH2-authenticated connections without properly making sure that the connection was authenticated with the same credentials as set for this transfer. This affects SASL-enabled protocols: SMPTP(S), IMAP(S), POP3(S) and LDAP(S) (openldap only).

libcurl maintains a pool of live connections after a transfer has completed (sometimes called the connection cache). This pool of connections is then gone through when a new transfer is requested and if there is a live connection available that can be reused, it is preferred instead of creating a new one.

Due to this security vulnerability, a connection that is successfully created and authenticated with a user name + OAUTH2 bearer could subsequently be erroneously reused even for user + [other OAUTH2 bearer], even though that might not even be a valid bearer. This could lead to an authentication bypass, either by mistake or by a malicious actor.

We are not aware of any exploit of this flaw.

INFO This flaw was introduced in curl in 2013 with the commit series that started with 19a05c908f7d8b.

The Common Vulnerabilities and Exposures (CVE) project has assigned the name CVE-2022-22576 to this issue. CWE-305: Authentication Bypass by Primary Weakness Severity: Medium

AFFECTED VERSIONS Affected versions: curl 7.33.0 to and including 7.82.0 Not affected versions: curl < 7.33.0 and curl >= 7.83.0 Note that libcurl is used by many applications, but not always advertised as such.

THE SOLUTION A fix for CVE-2022-22576

RECOMMENDATIONS We suggest you take one of the following actions immediately, in order of preference: A - Upgrade curl and libcurl to version 7.83.0 B - Apply the patch to your version and rebuild C - Set the bearer string as password as well when using OAUTH2 bearer authentication with these protocols.

TIME LINE It was first reported to the curl project on March 18 2022. We contacted distros@openwall on April 18. libcurl 7.83.0 was released on April 27 2022, coordinated with the publication of this advisory.

CREDITS Reported and patched by Patrick Monnerat. Thanks a lot!

https://curl.se/docs/CVE-2022-22576.html

The report

libcurl might reuse OAUTH2-authenticated connections without properly making sure that the connection was authenticated with the same credentials as set for this transfer. This affects SASL-enabled protcols: SMTP(S), IMAP(S), POP3(S) and LDAP(S) (openldap only).

libcurl maintains a pool of connections after a transfer has completed. The pool of connections is then gone through when a new transfer is requested and if there's a live connection available that can be reused, it is preferred instead of creating a new one.

A connection that is successfully created and authenticated with a user name + OAUTH2 bearer could subsequently be reused even for user + [other OAUTH2 bearer], even though that might not even be a valid bearer. This could lead to an authenticion bypass, either by mistake or by a malicious actor.

The problem can be demontrated using an imap server supporting OAUTH2 authentication using command:

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

Note: This vulnerability has been assigned CWE-305 "Authentication Bypass by Primary Weakness" that is not selectable on the current IBB form.

Impact

Unauthorized access.

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 reuse logic did not compare the OAUTH2 bearer token of the new transfer with the token used to authenticate the existing connection.

Impact

This could lead to an authentication bypass, either by mistake or by a malicious actor, though the text states that no exploit is known.

What the attacker needed

Libcurl 7.33.0 to 7.82.0; SASL-enabled protocol (SMTP, IMAP, POP3, LDAP); OAUTH2 bearer authentication; connection reuse

The fix

The issue was fixed in curl 7.83.0; alternatively, set the bearer string as the password as well when using OAUTH2 bearer authentication with these protocols.

How it was found

  1. Start a transfer to an OAUTH2-enabled server using a valid bearer token.
  2. Start a second transfer to the same server using a different, possibly invalid, bearer token.
  3. Observe that the second transfer reuses the existing authenticated connection instead of creating a new one.

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 server, it sometimes keeps the connection open to reuse later. This is like keeping a door propped open after you have unlocked it. The bug meant that if you later tried to use that same door with a different key, the program did not check the new key and just let you through, even if the new key was wrong.

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 Internet Bug Bounty

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.