Skip to content

fix saml IdP service provider validation#36057

Merged
rosstimothy merged 1 commit intomasterfrom
fspmarshall/fix-saml-validation
Jan 9, 2024
Merged

fix saml IdP service provider validation#36057
rosstimothy merged 1 commit intomasterfrom
fspmarshall/fix-saml-validation

Conversation

@fspmarshall
Copy link
Copy Markdown
Contributor

@fspmarshall fspmarshall commented Dec 26, 2023

Some recent SAML IdP validation changes started rejecting insecure SAML service provider descriptors. This ended up causing issues for two reasons:

  1. Validation was run during cache init, meaning that teleport could go into an infinite loop of failed cache initialization attempts if an existing SAML IdP configuration didn't meet the new requirements.
  2. The validation would incorrectly reject configurations that were secure if they also supported insecure options (i.e. if a service provider supported both http and https the configuration would be rejected, instead of simply ignoring the http option always using the https option).

This PR is the first of two that will move us over to ignoring and warning about insecure IDP descriptors (a followup PR in e is needed to fully switch over to the new behavior).

These changes were manually tested against samltest.id.

changelog: fixed an issue where valid saml entity descriptors could be rejected.

@github-actions github-actions Bot added size/sm tctl tctl - Teleport admin tool labels Dec 26, 2023
@github-actions
Copy link
Copy Markdown
Contributor

The PR changelog entry failed validation: Changelog entry not found in the PR body. Please add a "no-changelog" label to the PR, or changelog lines starting with changelog: followed by the changelog entries for the PR.

Comment thread lib/services/saml_idp_service_provider.go Outdated
Comment on lines 127 to 131
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.

nit: change tt.ok from a bool to a require.ErrorAssertionFunc and these 5 lines can collapse to a single line.

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.

For tests that care about the output of the fallible operation switching to AssertionFunc doesn't really save loc, since you have additional checks that are only run for the happy variants (meaning u still need all the same control-flow). I don't mind switching to AssertionFunc if thats something we'd like to standardize on, but IMO for a test like this that isn't worried about the specific error kinds of failures, it's just more visual noise without a meaningful upside.

@fspmarshall fspmarshall force-pushed the fspmarshall/fix-saml-validation branch from 0b8310b to ccd7ace Compare January 3, 2024 16:43
Comment on lines +977 to +986
ed, err := samlsp.ParseMetadata([]byte(sp.GetEntityDescriptor()))
if err != nil {
return trace.BadParameter("invalid entity descriptor for SAML IdP Service provider %q: %v", sp.GetEntityID(), err)
}

// try filtering the entity descriptor. if it can't be filtered down to a useable looking state, reject
// the creation attempt.
if err := services.FilterSAMLEntityDescriptor(ed); err != nil {
return trace.Wrap(err)
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need this logic client side? Aren't Create/UpdateSAMLIdPServiceProvider performing the same checks?

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.

FilterSAMLEntityDescriptor generates detailed warn logs, which I think are good to have client-side for this type.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oops! This actually broke the new feature where we now allow service provider creation without upfront entity descriptor (that will be generated later in CreateSAMLIdPServiceProvider) - #34661

@public-teleport-github-review-bot public-teleport-github-review-bot Bot removed the request for review from ryanclark January 3, 2024 20:16
@fspmarshall fspmarshall added this pull request to the merge queue Jan 9, 2024
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Jan 9, 2024
@rosstimothy rosstimothy added this pull request to the merge queue Jan 9, 2024
Merged via the queue into master with commit 6442058 Jan 9, 2024
@rosstimothy rosstimothy deleted the fspmarshall/fix-saml-validation branch January 9, 2024 20:57
@public-teleport-github-review-bot
Copy link
Copy Markdown

@fspmarshall See the table below for backport results.

Branch Result
branch/v13 Failed
branch/v14 Create PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/sm tctl tctl - Teleport admin tool

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants