Reject discovered IdP endpoints with a non-HTTP scheme - #2427
Reject discovered IdP endpoints with a non-HTTP scheme#2427theredspoon wants to merge 2 commits into
Conversation
OIDC discovery metadata is parsed by `openidconnect` as generic URLs with no constraint on the scheme, so a compromised or maliciously configured provider can advertise e.g. `javascript:...` as its authorization_endpoint or end_session_endpoint. Both of those are returned to the browser by `GET /sso/providers/:name/start` and `GET /sso/logout` and assigned to `location.href`, which would run script on the gateway's own origin. Validate in `discover_metadata`, the single point every consumer of discovery metadata goes through, and before the document is cached. Anything other than http/https is a hard `SsoError`, matching how the surrounding code already treats other discovery and SSO config problems. Also route the two frontend call sites through a `navigateToExternalUrl` helper that re-checks the scheme, as defence in depth.
|
Is there an actual case where this can happen? A hostile OIDC provider is not really a part of the threat model - it doesn't need to bother with running javascript when it can just issues an admin login. (no LLM replies please) |
|
Hey @Eugeny, human here. What happened here is that once a security finding came up in one of my LLM reviews on #2397, I figured I would point a security sweep at the codebase and share whatever came up, however minimal in it. Better disclose than not. And to be honest, I wasn't investigating deeply, just leaning on quantity as its own quality. Of course on the face of it if an OIDC provider is compromised, they can do a lot worse than a javascript injection. I would consider this PR more hygiene than a gap-closer. I've updated the PR body accordingly. Related to that, would you be open to me opening a PR to add more context to SECURITY.md to better assist LLMs? I wouldn't want anyone's time wasted with findings you wouldn't advance due to them falling outside of the declared scope. I think the following could help: |
…heme-validation # Conflicts: # warpgate-web/src/common/helpers.ts
What
Reject any OIDC-discovered endpoint whose scheme isn't
httporhttps.Why
openidconnectparses discovery endpoints as generic URLs with no scheme constraint, and two of them end up in a client-side navigation (Login.svelte/AuthBar.svelte:location.href = ...). A provider advertising"authorization_endpoint": "javascript:..."gets that assigned tolocation.hrefon the gateway's own origin.This is input hygiene, not a closed vulnerability:
javascript:/data:are never legitimate values here, so rejecting anything outsidehttp/httpsis a three-line check with no behavior change for any real deployment.Where
Checked once in
discover_metadata()(warpgate-sso/src/metadata.rs), the single choke point every consumer of discovery metadata goes through, before the document is cached. A rejected endpoint is a hard error (SsoError::UnsupportedEndpointScheme), matching how other discovery/config problems already fail in this code.Login.svelte/AuthBar.sveltealso get anavigateToExternalUrl()helper as a second line of defense.Tests
New unit tests in
warpgate-sso/src/metadata.rscover validhttp/httpsdocuments and rejection ofjavascript:/data:/file:on each affected endpoint.cargo test -p warpgate-sso,clippy, andbiome checkall pass.