OAuth2 "authorization_code" is valid indefinetly
The OAuth2 authorisation endpoint stored issued authorisation codes without any expiry, contrary to the recommended ten-minute lifetime. An attacker who obtained a code could redeem it much later, or could keep guessing codes indefinitely.
Originally disclosed on HackerOne
- Triaged in under an hour
- Fixed in 12 months
- Paid in 12 months
- Disclosed after 15 months
Summary by the program
Security advisory at https://github.com/nextcloud/security-advisories/security/advisories/GHSA-wppc-f5g8-vx36
The report
Your OAuth2 endpoint is not at all following best practices. When the authorization_code is generated it is stored without a timeout. Now according to https://www.rfc-editor.org/rfc/rfc6749#section-4.1.2 10 minutes is recommended. As the goal is that is gets used almost directly or not at all.
Now there is a debate maybe to have on the 10 minutes. But there is kind of a big difference between 10 minutes and no timeout at all.
Impact
An attacker that obtains this code could possibly easily redeem it in the future. Or an attacker could just keep trying codes.
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 authorisation codes were persisted without an expiry timestamp or cleanup, so they remained valid until redeemed.
Impact
An attacker holding a code could possibly redeem it later, and could keep trying codes.
What the attacker needed
Attacker obtains a valid authorisation code
The fix
Authorisation codes should be given a short lifetime, such as the recommended ten minutes, and rejected once expired.
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 you log in to a site using another service, the service hands back a short-lived ticket called an authorisation code that the site swaps for access. These tickets are meant to expire quickly so a stolen one is useless. Here they never expired, so a leaked ticket stayed usable.
What is OAuth / SSO?
Mistakes in OAuth, OpenID Connect, SAML or token handling that leak codes and tokens or link an attacker's identity to a victim's account.