Skip to content

Enhance parsing of StatusCode in SAML Responses #38628

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 11, 2019

Conversation

jkakavas
Copy link
Member

@jkakavas jkakavas commented Feb 8, 2019

<Status> elements in a failed response might contain two nested
<StatusCode> elements. We currently only parse the first one in
order to create a message that we attach to the Exception we return
and log. However this is generic and only gives out information
about whether the SAML IDP believes it's an error with the
request or if it couldn't handle the request for other reasons. The
encapsulated <StatusCode> has a more interesting error message that
potentially gives out the actual error as in Invalid NameID policy,
authentication failure etc.

This change ensures that we print the nested information also, and
removes Message and Details fields from the message when these
are not part of the Status element (which quite often is the case)

<Status> elements in a failed response might contain two nested
<StatusCode> elements. We currently only parse the first one in
order to create a message that we attach to the Exception we return
and log. However this is generic and only gives out informarion
about whether the SAML IDP believes it's an error with the
request or if it couldn't handle the request for other reasons. The
encapsulated StatusCode has a more interesting error message that
potentially gives out the actual error as in Invalid nameid policy,
authentication failure etc.

This change ensures that we print that information also, and removes
Message and Details fields from the message when these are not
part of the Status element (which quite often is the case)
@jkakavas jkakavas added >enhancement v6.2.5 :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v6.3.3 v6.4.4 v6.5.5 v6.6.1 v8.0.0 v7.2.0 labels Feb 8, 2019
@jkakavas jkakavas requested a review from tvernum February 8, 2019 15:03
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-security

@tvernum
Copy link
Contributor

tvernum commented Feb 11, 2019

That list of version labels doesn't look right:

  1. we shouldn't be backporting this past 6.6.1 as 6.2-6.5 is out of maintenance.
  2. if this is in 6.6 then it should also go to 6.7 and 7.0

StatusCode subLevel = firstLevel.getStatusCode();
StringBuilder sb = new StringBuilder();
if (StatusCode.REQUESTER.equals(firstLevel.getValue())) {
sb.append("The request could not be granted due to an error in the Elastic Stack side (");
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think this gives an accurately picture. In reality it's the IdP thinks the Requester did something wrong.
The IdP's assessment might be true (or in the case of ADFS, it's probably not) but in either case if we say ther eis an error in the Elastic Stack side, it implies that we know about a problem, which we don't.
I fear it will lead to users hunting for error messages, or expecting us to explain the error, when we don't know what the problem is (if we did, we wouldn't have made the request).

Suggested change
sb.append("The request could not be granted due to an error in the Elastic Stack side (");
sb.append("The SAML IdP did not grant the request. It indicated that the Elastic Stack side sent something invalid (");

sb.append("The request could not be granted because the SAML IDP doesn't support SAML 2.0 (");
} else {
sb.append("The request could not be granted, the SAML IDP responded with a non-standard Status code (");

Copy link
Contributor

Choose a reason for hiding this comment

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

Nit:

unneccessary
new
line

@tvernum
Copy link
Contributor

tvernum commented Feb 11, 2019

This needs to be labelled for 6.7 as well.

@jkakavas jkakavas merged commit 418dede into elastic:master Feb 11, 2019
jkakavas added a commit that referenced this pull request Feb 11, 2019
* Enhance parsing of StatusCode in SAML Responses

<Status> elements in a failed response might contain two nested
<StatusCode> elements. We currently only parse the first one in
order to create a message that we attach to the Exception we return
and log. However this is generic and only gives out informarion
about whether the SAML IDP believes it's an error with the
request or if it couldn't handle the request for other reasons. The
encapsulated StatusCode has a more interesting error message that
potentially gives out the actual error as in Invalid nameid policy,
authentication failure etc.

This change ensures that we print that information also, and removes
Message and Details fields from the message when these are not
part of the Status element (which quite often is the case)
jkakavas added a commit that referenced this pull request Feb 12, 2019
* Enhance parsing of StatusCode in SAML Responses

<Status> elements in a failed response might contain two nested
<StatusCode> elements. We currently only parse the first one in
order to create a message that we attach to the Exception we return
and log. However this is generic and only gives out informarion
about whether the SAML IDP believes it's an error with the
request or if it couldn't handle the request for other reasons. The
encapsulated StatusCode has a more interesting error message that
potentially gives out the actual error as in Invalid nameid policy,
authentication failure etc.

This change ensures that we print that information also, and removes
Message and Details fields from the message when these are not
part of the Status element (which quite often is the case)
jkakavas added a commit that referenced this pull request Feb 12, 2019
* Enhance parsing of StatusCode in SAML Responses

<Status> elements in a failed response might contain two nested
<StatusCode> elements. We currently only parse the first one in
order to create a message that we attach to the Exception we return
and log. However this is generic and only gives out informarion
about whether the SAML IDP believes it's an error with the
request or if it couldn't handle the request for other reasons. The
encapsulated StatusCode has a more interesting error message that
potentially gives out the actual error as in Invalid nameid policy,
authentication failure etc.

This change ensures that we print that information also, and removes
Message and Details fields from the message when these are not
part of the Status element (which quite often is the case)
@jkakavas jkakavas deleted the handle-status-code branch February 12, 2019 06:57
jkakavas added a commit that referenced this pull request Feb 12, 2019
* Enhance parsing of StatusCode in SAML Responses

<Status> elements in a failed response might contain two nested
<StatusCode> elements. We currently only parse the first one in
order to create a message that we attach to the Exception we return
and log. However this is generic and only gives out informarion
about whether the SAML IDP believes it's an error with the
request or if it couldn't handle the request for other reasons. The
encapsulated StatusCode has a more interesting error message that
potentially gives out the actual error as in Invalid nameid policy,
authentication failure etc.

This change ensures that we print that information also, and removes
Message and Details fields from the message when these are not
part of the Status element (which quite often is the case)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>bug :Security/Authentication Logging in, Usernames/passwords, Realms (Native/LDAP/AD/SAML/PKI/etc) v6.6.1 v6.7.0 v7.0.0-beta1 v7.2.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants