SAML Profile for the Metadata Query Protocol
Ian A. Young, Ed.
Independent
ian@iay.org.uk
metadata
SAML
This document profiles the Metadata Query Protocol for use with SAML metadata.
This document is a product of the Research and Education Federations (REFEDS) Working Group process.

Editorial Note (To be removed by RFC Editor before publication)
Discussion of this draft takes place on the MDX mailing list (mdx@lists.iay.org.uk), which is accessed from [MDX.list].
XML versions, latest edits and the issues list for this document are available from [md-query].
The changes in this draft are summarized in Appendix A.22.

Introduction
This document profiles the Metadata Query Protocol for use with SAML metadata.
The Research and Education Federations group ([REFEDS]) is the voice that articulates the mutual needs of research and education identity federations worldwide. It aims to represent the requirements of research and education in the ever-growing space of access and identity management.
From time to time REFEDS will wish to publish a document in the Internet RFC series. Such documents will be published as part of the RFC Independent Submission Stream [RFC4844]; however the REFEDS working group sign-off process will have been followed for these documents, as described in the REFEDS Participant's Agreement.
This document is a product of the REFEDS Working Group process.

Notation and Conventions
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here.
This document makes use of the Augmented BNF metalanguage defined in [STD68].

Request Profile

Content Type
Requests compliant with this profile MUST include the following HTTP header to indicate that the metadata returned should be SAML metadata (see Appendix A of [SAML2Meta]):
Accept: application/samlmetadata+xml

Identifiers

Unique Identifier
Each entity known to the responder MUST be associated with the unique identifier of the entity, corresponding to the entityID attribute of the entity's EntityDescriptor element in SAML metadata.

Transformed Identifier
SAML 2.0 includes profiles based on the transfer of an "artifact" containing the unique identifier of a SAML entity transformed by means of the SHA-1 hash algorithm (see [SAML2Bind] sections 3.6 and 3.6.4).
In order to support use cases in which clients may be in possession of only such a transformed representation of a SAML entity's unique identifier without any way to establish the original entity identifier, a responder compliant with this profile MUST associate each entity with an identifier matching the sha1id production in the following ABNF grammar, and treat such an identifier as equivalent to the corresponding untransformed identifier:

SHA1     = %x73 %x68 %x61 %x31 ; lower case "sha1"
DIGIT    = %x30-39
HEXDIGIT = DIGIT | %x61-66 ; lower case a-f
sha1id   = "{" SHA1 "}" sha1hex
sha1hex  = 40*HEXDIGIT

In the above, the sha1hex component encodes the 20-octet (160-bit) binary SHA-1 hash value as a sequence of 40 lower case hexadecimal digits.
For example, the identifier
http://example.org/service
transformed by means of SHA-1 hashing would become
{sha1}11d72e8cf351eb6c75c721e838f469677ab41bdb
Responder implementations MAY detect malformed SHA-1 transformed identifiers (for example where the string of characters following the "}" contains characters other than hexadecimal digits, or is other than exactly 40 characters in length) and return an HTTP status code of 400 ("bad request"). Alternatively, implementations MAY process these as normal identifiers and return an HTTP status code of 404 ("not found") if appropriate.

Additional Identifiers
Entities MAY also be associated with any number of additional responder-defined identifiers naming arbitrary groups of entities.

Response Profile

Response Cardinality
A request may return information for any number of entities, including none. Responses compliant with this profile MUST use the appropriate representation described below depending on the number of EntityDescriptor elements returned.

No Entity Descriptors Returned
A response which returns no EntityDescriptor elements MUST be represented by an HTTP status code of 404 ("not found").

One Entity Descriptor Returned
A response which returns a single EntityDescriptor element MUST use that element as its document element. The responder MUST NOT make use of a EntitiesDescriptor element in this situation (see [SAML2Meta] section 2.3).
Such a response MUST include the following HTTP header to indicate that the metadata returned is SAML metadata:
Content-Type: application/samlmetadata+xml

More Than One Entity Descriptor Returned
A response which returns more than one EntityDescriptor element MUST consist of a document element which is an EntitiesDescriptor element, containing the returned EntityDescriptor elements as children. Responses MUST NOT contain nested EntitiesDescriptor elements.
Such a response MUST include the following HTTP header to indicate that the metadata returned is SAML metadata:
Content-Type: application/samlmetadata+xml

Security Considerations

Integrity
As SAML metadata contains information necessary for the secure operation of interacting services it is strongly RECOMMENDED that a mechanism for integrity checking is provided to clients.
It is RECOMMENDED that the integrity checking mechanism provided by a responder is a digital signature embedded in the returned metadata document, as defined by [SAML2Meta] section 3.
Such digital signatures:
- SHOULD use an RSA keypair whose modulus is no less than 2048 bits in length.
- MUST NOT use the SHA-1 cryptographic hash algorithm as a digest algorithm.
- MUST NOT use the MD5 cryptographic hash algorithm as a digest algorithm.
- SHOULD otherwise follow current cryptographic best practices in algorithm selection.

Use of SHA-1 in Transformed Identifiers
This profile mandates the availability of an identifier synonym mechanism based on the SHA-1 cryptographic hash algorithm. Although SHA-1 is now regarded as weak enough to exclude it from use in new cryptographic systems, its use in this profile is necessary for full support of the SAML 2.0 standard.
The use of SHA-1 in section 3.6.4 of [SAML2Bind], and its resulting use in this protocol, would be vulnerable to an attack in which metadata was introduced into a system by an attacker capable of creating an entity identifier with the same SHA-1 hash as that of an existing entity's identifier.
Such an identifier is known as a second preimage of the original, and SHA-1's resistance to discovery of it is referred to as SHA-1's second-preimage resistance.
As demonstrated by the the [SHAttered] and [Shambles] attacks, the SHA-1 algorithm is known to have weak collision resistance. However, at the time of writing no attacks are known on SHA-1's second-preimage resistance; a result in this area would be required to provide the basis of an attack based on duplicating the SHA-1 hash of an existing identifier. As a result, the use of SHA-1 in SAML and in this protocol is not believed to introduce a security concern.
Implementations may guard against the possibility of a future practical attack on the second-preimage resistance of SHA-1 by treating two entities whose entityID values have the same SHA-1 equivalent as an indicator of malicious intent on the part of the owner of one of the entities.

IANA Considerations
This document has no actions for IANA.

Acknowledgements
The editor would like to acknowledge the following individuals for their contributions to this document:
Scott Cantor (The Ohio State University)
Leif Johansson (SUNET)
Joe St Sauver (University of Oregon)
Tom Scavo (Internet2)

Normative References
[I-D.young-md-query]

Metadata Query Protocol
Ian A. Young, Ed.
July 2024
Internet-Draft draft-young-md-query-20
[SAML2Bind]

Bindings for the Security Assertion Markup Language (SAML) V2.0
Scott Cantor
Frederick Hirsch
John Kemp
Rob Philpott
Eve Maler
March 2005
OASIS Standard saml-bindings-2.0-os
[SAML2Meta]

Metadata for the Security Assertion Markup Language (SAML) V2.0
Scott Cantor
Internet2
cantor.2@osu.edu
Jahan Moreh
Sigaba
jmoreh@sigaba.com
Rob Philpott
RSA Security
rphilpott@rsasecurity.com
Eve Maler
Sun Microsystems
eve.maler@sun.com
March 2005
OASIS Standard saml-metadata-2.0-os
[STD68]

Augmented BNF for Syntax Specifications: ABNF
D. Crocker, Ed.
P. Overell
January 2008
STD 68
RFC 5234
DOI 10.17487/RFC5234

Informative References
[REFEDS]

REFEDS Home Page
Research and Education Federations
[REFEDS.agreement]

REFEDS Participant's Agreement
Research and Education Federations
[SAML2Core]

Assertions and Protocol for the OASIS Security Assertion Markup Language (SAML) V2.0
Scott Cantor
Internet2
cantor.2@osu.edu
John Kemp
Nokia
John.Kemp@nokia.com
Rob Philpott
RSA Security
rphilpott@rsasecurity.com
Eve Maler
Sun Microsystems
eve.maler@sun.com
March 2005
OASIS Standard saml-core-2.0-os
[MDX.list]

MDX Mailing List
Ian A. Young, Ed.
[md-query]

md-query Project
Ian A. Young, Ed.
[SHAttered]

SHAttered
February 2017
[Shambles]

SHA-1 is a Shambles
January 2020
[RFC4844]
[RFC2119]
[RFC8174]

Change Log (to be removed by RFC Editor before publication)

draft-young-md-query-saml-00
Initial version.

Since draft-young-md-query-saml-00
Added REFEDS RFC stream boilerplate.

Since draft-young-md-query-saml-01
Bump reference to the Metadata Query Protocol.
Rework Section 2.2 to make the role of transformed identifiers clearer. This changes the semantics slightly (malformed transformed identifiers may now result in a 404 return rather than 400) but this gives implementers more latitude in the way that they handle the feature.

Since draft-young-md-query-saml-02
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-03
Bump reference to the Metadata Query Protocol.
Added an Editorial Note to help direct readers back to the discussion.

Since draft-young-md-query-saml-04
Fix reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-05
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-06
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-07
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-08
Bump reference to the Metadata Query Protocol.
Modernise normative language to include [RFC8174].
Improved references to RFCs.

Since draft-young-md-query-saml-09
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-10
Bump reference to the Metadata Query Protocol.
Replace citations in the abstract with straight textual mentions, as required by the ID-NITS checklist.

Since draft-young-md-query-saml-11
Bump reference to the Metadata Query Protocol.
Strengthen Section 4.1 so that SHA-1 now MUST NOT be used in the context of digital signatures. This brings the section in line with current best practice recommendations, particularly in light of the [SHAttered] and [Shambles] attacks.
Revised Section 4.2 on the use of SHA-1 in transformed identifiers to:
- Make clear that this is a SAML-level issue, not one introduced by the query protocol.
- Reference the attacks demonstrating SHA-1's weak collision resistance.
- Identify second-preimage resistance as the potential source of the attack we'd be concerned about for the query protocol.
- Note that SHA-1's second-preimage resistance is at present uncompromised.

Since draft-young-md-query-saml-12
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-13
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-14
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-15
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-16
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-saml-17
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-18
Formatting changes to allow rendering with xml2rfc version 3.
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-19
Bump reference to the Metadata Query Protocol.

Since draft-young-md-query-20
Bump reference to the Metadata Query Protocol.