Skip to content

Validate that the "/web/sso_confirm" redirect URL is only used for MFA ceremonies#56006

Merged
Joerger merged 6 commits intomasterfrom
joerger/allow-sso-mfa-redirect
Jul 1, 2025
Merged

Validate that the "/web/sso_confirm" redirect URL is only used for MFA ceremonies#56006
Joerger merged 6 commits intomasterfrom
joerger/allow-sso-mfa-redirect

Conversation

@Joerger
Copy link
Copy Markdown
Contributor

@Joerger Joerger commented Jun 23, 2025

Follow up to #55398

This change does not have any known security impact, but it adds some better partitioning between SSO ceremony types to ensure that using the Web MFA specific redirect URL "/web/sso_confirm" can not even be attempted outside of MFA flows.

I also moved the function out of lib/auth/github.go to lib/client/sso/redirector.go since it is not github specific, and updated the comment for readability.

…so/redirector.go

* Replace binary ssoTestFlow boolean with ceremony type to incorporate MFA ceremonies

* Validate that "/web/sso_confirm" is only used for MFA ceremonies
@Joerger Joerger requested a review from rosstimothy June 23, 2025 18:29
@Joerger Joerger added the no-changelog Indicates that a PR does not require a changelog entry label Jun 23, 2025
@github-actions github-actions Bot requested review from hugoShaka and vapopov June 23, 2025 18:29
Copy link
Copy Markdown
Collaborator

@zmb3 zmb3 left a comment

Choose a reason for hiding this comment

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

Should we also move the tests to redirector_test.go?

Comment thread lib/client/sso/redirector.go Outdated
Comment thread lib/client/sso/redirector.go Outdated
Comment thread lib/client/sso/redirector.go Outdated
@Joerger Joerger requested a review from zmb3 June 23, 2025 19:03
Comment thread lib/client/sso/redirector.go
}
if q, err := url.ParseQuery(u.RawQuery); err != nil {
return trace.Wrap(err, "parsing query in client redirect URL")
} else if len(q) != 1 || len(q["secret_key"]) != 1 {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is it correct that the secret_key query parameter doesn't need to be validated for SSO MFA?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, the secret_key is not used for the web SSO MFA flow. For non web SSO flows, the secret_key is required on the server side to encode the response:

teleport/lib/web/apiserver.go

Lines 2333 to 2348 in e71690a

if u.Path == sso.WebMFARedirect {
// Transform the web sso mfa redirectURL into a relative redirect, preserving
// query parameters while ignoring scheme, hostname, and other url parts.
q := u.Query()
q.Add("response", string(out))
return &url.URL{
Path: sso.WebMFARedirect,
RawQuery: q.Encode(),
}, nil
}
// Extract secret out of the request.
secretKey := u.Query().Get("secret_key")
if secretKey == "" {
return nil, trace.BadParameter("missing secret_key")
}

If a non-web client tried to abuse this by setting the path to /web/sso_confirm and not setting a secret_key, it would fail thanks to the previous fix enforcing the use of a relative URL on the server side.

Comment thread lib/client/sso/redirector.go Outdated
@Joerger Joerger requested a review from zmb3 June 24, 2025 23:32
Comment thread lib/client/sso/redirector.go Outdated
Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
@Joerger
Copy link
Copy Markdown
Contributor Author

Joerger commented Jul 1, 2025

@hugoShaka @vapopov Friendly ping to review

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from hugoShaka July 1, 2025 19:07
@Joerger Joerger added this pull request to the merge queue Jul 1, 2025
Merged via the queue into master with commit 88473c4 Jul 1, 2025
39 checks passed
@Joerger Joerger deleted the joerger/allow-sso-mfa-redirect branch July 1, 2025 23:09
Joerger added a commit that referenced this pull request Jul 10, 2025
…A ceremonies (#56006)

* * Move ValidateClientRedirect from lib/auth/github.go to lib/client/sso/redirector.go

* Replace binary ssoTestFlow boolean with ceremony type to incorporate MFA ceremonies

* Validate that "/web/sso_confirm" is only used for MFA ceremonies

* Address comments.

* Add warning comment; Update error message.

* Update/Add tests.

* Require channel_id as exclusive query parameter for sso mfa web redirect.

* Update lib/client/sso/redirector.go

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>

---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
github-merge-queue Bot pushed a commit that referenced this pull request Jul 14, 2025
…A ceremonies (#56006) (#56648)

* * Move ValidateClientRedirect from lib/auth/github.go to lib/client/sso/redirector.go

* Replace binary ssoTestFlow boolean with ceremony type to incorporate MFA ceremonies

* Validate that "/web/sso_confirm" is only used for MFA ceremonies

* Address comments.

* Add warning comment; Update error message.

* Update/Add tests.

* Require channel_id as exclusive query parameter for sso mfa web redirect.

* Update lib/client/sso/redirector.go



---------

Co-authored-by: rosstimothy <39066650+rosstimothy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport/branch/v17 backport/branch/v18 no-changelog Indicates that a PR does not require a changelog entry size/sm

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants