Repository navigation
fix: leave query strings and user info out of SAML URL errors - #261
Open
aaron-congo wants to merge 2 commits into
Open
aaron-congo wants to merge 2 commits into
aaron-congo wants to merge 2 commits into
Conversation
sophia-bq
previously approved these changes
Dec 3, 2026
JuanLeee
reviewed
Dec 4, 2026
JuanLeee
reviewed
Dec 4, 2026
When an IdP URL or a redirect the IdP sends was rejected, the SamlAuthError message held the whole URL. Query strings, fragments, path parameters and user info can carry one-time tokens, session ids or credentials, and these messages can reach application logs and telemetry. The new SamlUtils.url_for_message keeps only the scheme, host, port and path. It is used for invalid IdP URLs and for malformed redirect locations, which previously raised URI::InvalidURIError with the whole location in its message and now raise SamlAuthError instead.
sophia-bq
force-pushed
the
fix/saml-url-error-message
branch
from
December 4, 2026 17:00
7a6df8d to
78c7def
Compare
sophia-bq
force-pushed
the
fix/saml-url-error-message
branch
from
December 4, 2026 17:15
78c7def to
085b3b8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Problem
When the SAML plugins (
federated_auth,okta) rejected an identity provider URL or a redirect sent by the identity provider, theSamlAuthErrormessage included the whole URL. Query strings, fragments, path parameters and user info in these URLs can carry values that should not be copied into error messages, which can end up in application logs and telemetry span attributes.A malformed redirect
Locationheader had the same result by another route:URI.joinraisedURI::InvalidURIErrorwith the whole location in its message, and the plugin wrapped that message in itsSamlAuthError.Description
Change
SamlUtils.url_for_message, which keeps the scheme, host, port and path of a URL and drops the query string, fragment, path parameters (;...) and user info. It does not parse the URL, so it also works on malformed URLs. It handles protocol-relative, backslash, single-slash and scheme-less forms, and passwords containing a raw?,#or;.SamlUtils.validate_url!uses it in its error messages.SamlUtils.absolute_redirectnow raisesSamlAuthErrorwith the cleaned URL when a redirect location cannot be resolved, instead ofURI::InvalidURIError.Behavior change
Invalid HTTPS URL: ...messages no longer include the query string, fragment, path parameters or user info.SamlAuthError(Invalid redirect URL: ...) instead ofURI::InvalidURIError.Testing
New
spec/unit/utils/saml_utils_spec.rb:url_for_messagewith each part that is dropped, user info in its various forms, an@in the path, and malformed URLs.validate_url!messages for http, malformed and credential-bearing URLs.http_requestwith a redirect to an http URL and with malformed redirects, and a valid relative redirect that is still followed.absolute_redirectresolving a relative location and raisingSamlAuthErrorfor a malformed one.Without the change, 12 of the 13 original specs in the file fail. The full unit test suite passes.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.