Skip to content

Reject an OAuth callback whose state does not match this browser (OCU-01-018) - #1820

Open
Dhirenderchoudhary wants to merge 3 commits into
OpenPrinting:masterfrom
Dhirenderchoudhary:fix-oauth-callback-state
Open

Dhirenderchoudhary wants to merge 3 commits into
OpenPrinting:masterfrom
Dhirenderchoudhary:fix-oauth-callback-state

Conversation

@Dhirenderchoudhary

@Dhirenderchoudhary Dhirenderchoudhary commented Nov 15, 2026 •

Copy link
Copy Markdown

What this fixes

7ASecurity audit of OpenPrinting, finding OCU-01-018, WP1, Medium.

The web login callback is a GET. finish_login took the authorization code and set CUPS_BEARER. cgiInitialize compares state only for POST, so this callback never hit that check. do_login already stores the state in CUPS_OAUTH_STATE. A browser that opens someone else's callback can be logged in as that other account.

The changes

finish_login rejects the callback when state is missing or does not match CUPS_OAUTH_STATE. That happens before the token request, so no bearer cookie is set.

cgi-bin already has tests, so I added testoauth.sh next to them. It runs home.cgi against a local token server. The cookie is CUPS_OAUTH_STATE=victim. State attacker, and a callback with no state, both say the login state does not match and do not set CUPS_BEARER. State victim sets CUPS_BEARER. I ran it and it passed.

I also ran the old home.cgi. That one set CUPS_BEARER for state attacker.

I left the shared PKCE verifier as it is. Issue 1556 and pull request 1741 are the device-grant replacement.

@michaelrsweet michaelrsweet self-assigned this Nov 15, 2026
@michaelrsweet

Copy link
Copy Markdown
Member

Thank you for the PR, appreciate the security eyes on unreleased software, will review when I have an opportunity. Also, much of this code is undergoing development/changes.

@michaelrsweet michaelrsweet added the investigating Investigating the issue label Nov 15, 2026
@tillkamppeter

Copy link
Copy Markdown
Member

@michaelrsweet This PR is the only still missing to complete the fixes of the bugs reported by the STA-sponsored security audit by 7A Security. Therefore it would be great if the PR could get merged (or the bug fixed in any form) soon, so that I can give them the final report that we have fixed all the bugs. could you review it in the next days? Thanks.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

investigating Investigating the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants