Skip to content

require https authorization endpoint in cupsOAuthMakeAuthorizationURL - #193

Open
tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:oauth-authorization-endpoint-https
Open

tanjiroK-coder wants to merge 1 commit into
OpenPrinting:masterfrom
tanjiroK-coder:oauth-authorization-endpoint-https

Conversation

@tanjiroK-coder

Copy link
Copy Markdown
Contributor

cupsOAuthGetAuthorizationCode opens the URL from cupsOAuthMakeAuthorizationURL with LSOpenCFURLRef, xdg-open or start, and that URL is built from the authorization_endpoint value in the server's metadata without any check on its scheme. The metadata comes from whatever server auth_uri names, which for IPP OAuth is the printer's oauth-authorization-server-uri, so a malicious printer or authorization server can return file:///Applications/Calculator.app, smb://host/share/x.app or any registered custom scheme and libcups will hand it to the desktop's URL handler instead of a browser. A plain http:// endpoint is also accepted, which sends the client_id, state and PKCE challenge in cleartext. I confirmed it with a small program linked against libcups3.a: those four endpoints all came back as launchable URLs before the change and are rejected after it, while https endpoints produce the same URL as before. RFC 6749 section 3.1 requires TLS for the authorization endpoint, so the check rejects anything that isn't https:// and lives in cupsOAuthMakeAuthorizationURL, which covers cupsOAuthGetAuthorizationCode and any application that opens the returned URL itself. testoauth needs a live authorization server and isn't part of make test, so I didn't add a test there; the cups unit tests still pass.

@michaelrsweet michaelrsweet left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor feedback; you can probably just add the https check to line 1651...

Comment thread CHANGES.md
- Fixed a memory leak in `httpGetSecurity` when using GNU TLS.
- Fixed a memory leak in `cupsJWTImportString`.
- Fixed a bug in `cupsJWTExportString` with JSON output.
- Fixed `cupsOAuthMakeAuthorizationURL` to only accept HTTPS authorization

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remember to just put the changelog in the description. We'll add it after merging with a reference to the PR...

Comment thread cups/oauth.c
// allow HTTPS URLs (RFC 6749 section 3.1)...
if (strncmp(authorization_ep, "https://", 8))
{
_cupsSetError(IPP_STATUS_ERROR_INTERNAL, _("Authorization endpoint is not an HTTPS URL."), true);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we aren't setting the last error for the initial range checking, I don't think we want to do so here either.

@michaelrsweet michaelrsweet self-assigned this Oct 23, 2026
@michaelrsweet michaelrsweet added the bug Something isn't working label Oct 23, 2026
@michaelrsweet michaelrsweet added this to the Stable milestone Oct 23, 2026

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

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants