Skip to content

Deal with cases where there is no SubjectConfirmationData. - #530

Closed
jeremyfrench wants to merge 2 commits into
simplesamlphp:simplesamlphp-1.14from
jeremyfrench:empty_SubjectConfirmation
Closed

jeremyfrench wants to merge 2 commits into
simplesamlphp:simplesamlphp-1.14from
jeremyfrench:empty_SubjectConfirmation

Conversation

@jeremyfrench

Copy link
Copy Markdown

I had a case where a saml packet contained this

<SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer" />

This caused SSP to fail. As subject confirmation data is not defined.

I have looked at the spec (well the xml schema) and it seems to be valid.

<element ref="saml:SubjectConfirmationData" minOccurs="0"/>

I'll agree that it doesn't make any sense to have such a element but if it is not invalid we should not be having a fatal error.

@longwave

longwave commented Dec 7, 2016

Copy link
Copy Markdown

The SAML errata documentation at http://docs.oasis-open.org/security/saml/v2.0/errata05/os/saml-v2.0-errata05-os.pdf seems to clarify this:

At least one bearer <SubjectConfirmation> element MUST contain a <SubjectConfirmationData> element that itself MUST contain a Recipient attribute containing the service provider's assertion consumer service URL and a NotOnOrAfter attribute that limits the window during which the assertion can be confirmed by the relying party.

Note that while multiple bearer <SubjectConfirmation> elements may be present, the successful evaluation of a single such element in accordance with this profile is sufficient to confirm an assertion. However, each assertion, if more than one is present, MUST be evaluated independently.

To me, it looks like the proposed fix covers this as there still must be a valid <SubjectConfirmation> and they are still evaluated, this PR simply skips the case where an empty one is encountered.

@jaimeperez jaimeperez closed this in 980b34c Dec 9, 2016
jaimeperez added a commit that referenced this pull request Dec 9, 2016
…ate error must be thrown.

This resolves #530. There are two problems here:

- When only one SubjectConfirmation is received and it is empty, an error should be thrown. However, the error would be a not very descriptive message warning about access to a non-property in a null object. Something more descriptive should be in place.
- Additionally, in PHP 7.0 this is an error and not an exception, and then the code continues to execute, effectively allowing assertions without a proper SubjectConfirmation element. This is wrong according to the standard.

We take the chance also to fix indentation in the whole file, as there were a few spaces mixed with tabs.
@jaimeperez

Copy link
Copy Markdown
Member

Hi guys!

@longwave is right. The fix is needed not only to avoid failures when an IdP sends an empty SubjectConfirmation alongside a valid one (which is a really stupid behaviour, but spec-compliant anyway), but also to ensure SSP behaves correctly when run under PHP 7. Otherwise, in PHP 7 it will log the errors and continue, effectively validating the assertion (even when it shouldn't).

I've committed fixes for this both in master and in the 1.14 branch (with a slight difference between them and your PR, that being explicit checking of the SubjectConfirmationData being null).

Thanks for your help!

@jaimeperez jaimeperez added the bug label Dec 9, 2016
tvdijen pushed a commit to tvdijen/simplesamlphp that referenced this pull request Aug 7, 2017
…ate error must be thrown.

This resolves simplesamlphp#530. There are two problems here:

- When only one SubjectConfirmation is received and it is empty, an error should be thrown. However, the error would be a not very descriptive message warning about access to a non-property in a null object. Something more descriptive should be in place.
- Additionally, in PHP 7.0 this is an error and not an exception, and then the code continues to execute, effectively allowing assertions without a proper SubjectConfirmation element. This is wrong according to the standard.
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Mar 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants