Skip to content
CSRF Disclosed report Intermediate CVE-2023-28848

CSRF protection on OIDC login is broken

The OIDC login flow's CSRF protection was broken because when the state parameter did not match the session, the server returned a JSON error that included the expected state value. An attacker could use this to obtain the correct state and bypass CSRF protection.

mikaelgundersen Follow

Originally disclosed on HackerOne

Bounty$500 Medium 4.8 View original
  • Triaged in 47 hours
  • Fixed in 37 days
  • Paid in 55 days
  • Disclosed after 45 days

Summary by the program

SA: https://github.com/nextcloud/security-advisories/security/advisories/GHSA-52hv-xw32-wf7f

The report

To protect against CSRF the "state" is used in the OIDC flow. On callback this code is verified against the code stored in the session for that user. However in case the token does not match a JSON response is provided that includes the expected state. Thus making it trivial for the attacker to obtain the correct state.

Judging from the code it clearly seem to be debug leftovers https://github.com/nextcloud/user_oidc/blob/main/lib/Controller/LoginController.php#L336-L344

Fixing the todo there should mitigate the issue and ensure the OIDC flow is more secure.

I didn't test ID4ME. But the code is almost identical. So I assume the bug is also the same https://github.com/nextcloud/user_oidc/blob/main/lib/Controller/Id4meController.php#L175-L181

Impact

The CSRF protection provided with the state is practically useless now.

The original report as published on HackerOne, by mikaelgundersen. 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 a debug leftover caused the error response to include the expected state value instead of only reporting a mismatch.

Impact

The CSRF protection provided by the state parameter was practically useless, allowing an attacker to bypass it.

What the attacker needed

Attacker can trigger OIDC callback; attacker can read JSON error response

The fix

The debug leftover should be removed so the error response no longer includes the expected state.

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 with an external identity provider, the site uses a random 'state' value to make sure the login response really belongs to your session. Here, if the state was wrong, the site's error message told the attacker what the correct state should have been, so the protection was useless.

What is CSRF?

Another site makes a signed-in user's browser perform an action they did not intend.

More by mikaelgundersen

View all

6 more disclosed reports, best first.

More from Nextcloud

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Cross-site request forgery (CSRF)

The lesson behind this report.

Another site makes a signed-in user's browser perform an action they did not intend.