-
Notifications
You must be signed in to change notification settings - Fork 404
Fix open redirect in legacy SSO flow (idp)
#18909
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
idp)
| # Validate the `idp` query parameter | ||
| providers = self._sso_handler.get_identity_providers() | ||
| auth_provider = providers.get(idp) | ||
| if not auth_provider: | ||
| logger.info("Unknown idp %r", idp) | ||
| self._sso_handler.render_error( | ||
| request, "unknown_idp", "Unknown identity provider ID" | ||
| ) | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restoring this since it was removed in #17972
With hindsight, I'm not sure why it was removed although perhaps I just thought it was a bit superfluous as we would end up at a 404 anyway.
We could technically still do away with this and rely on the URL encoded value fix above to fix the open redirect problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be worth calling out that this code prevents Synapse from reaching out to arbitrary URLs (along with the URL-encoding later). Mostly to prevent it being arbitrarily removed by a future code change (even though the tests help with that as well).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was a bit tricky to word but I've added something 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking this on!
| # Validate the `idp` query parameter | ||
| providers = self._sso_handler.get_identity_providers() | ||
| auth_provider = providers.get(idp) | ||
| if not auth_provider: | ||
| logger.info("Unknown idp %r", idp) | ||
| self._sso_handler.render_error( | ||
| request, "unknown_idp", "Unknown identity provider ID" | ||
| ) | ||
| return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be worth calling out that this code prevents Synapse from reaching out to arbitrary URLs (along with the URL-encoding later). Mostly to prevent it being arbitrarily removed by a future code change (even though the tests help with that as well).
|
Thanks for the review @anoadragon453 🦐 |
Fix open redirect in legacy SSO flow:
idpparameter to only accept the ones that are known in the config fileidpparameter for safety's sake (this is the main fix)Fix https://github.com/matrix-org/internal-config/issues/1651 (internal link)
Regressed in #17972
Dev notes
Pull Request Checklist
EventStoretoEventWorkerStore.".code blocks.