Skip to content

fix(oidc): reject backslash authority forms in relative redirects#1311

Open
lovasoa wants to merge 1 commit into
mainfrom
ophir.lojkine/fix-oidc-redirect-backslash
Open

fix(oidc): reject backslash authority forms in relative redirects#1311
lovasoa wants to merge 1 commit into
mainfrom
ophir.lojkine/fix-oidc-redirect-backslash

Conversation

@lovasoa

@lovasoa lovasoa commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

OIDC relative-redirect validation accepts /\evil.test

sqlpage.oidc_logout_url and the post-login redirect validated relative targets with starts_with('/') && !starts_with("//"), which accepted /\evil.test and /<TAB>/evil.test. The WHATWG URL parser used by the url crate treats \ as / and strips ASCII tab/newline/CR, so Url::join resolves both to the external authority evil.test when SQLPage builds post_logout_redirect_uri.

Proof (reproducible): rust-url and Node both turn /\evil.test into https://evil.test/; the same WHATWG rule is implemented by current browsers (new URL('/\\evil.test', location.origin).href). RFC-3986 parsers do not normalize it, so SQLPage cannot rely on the client either way.

One shared is_safe_relative_redirect now rejects any backslash or ASCII control character, used in verify_logout_params, validate_redirect_url, and sqlpage.oidc_logout_url. Normal paths like /foo/bar?x=1 keep working. Unit test covers /\evil.test, /\/evil.test, \evil.test, //evil.test, and the tab/newline/CR forms. clippy + tests pass.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ac23375837

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/webserver/oidc.rs
@lovasoa lovasoa force-pushed the ophir.lojkine/fix-oidc-redirect-backslash branch 2 times, most recently from 0c7a90e to 0915ce1 Compare June 10, 2026 15:02
…rgets

The relative-redirect check accepted /\evil.test (and /<TAB>/evil.test):
the WHATWG URL parser used by the url crate treats \ as / and strips ASCII
tab/newline/CR, so url::Url::join turned these into the external authority
evil.test when building post_logout_redirect_uri. is_safe_relative_redirect now
rejects any backslash or ASCII control character, applied via one shared helper
in verify_logout_params, validate_redirect_url, and sqlpage.oidc_logout_url.
@lovasoa lovasoa force-pushed the ophir.lojkine/fix-oidc-redirect-backslash branch from 0915ce1 to 66f47c8 Compare June 10, 2026 20:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant