Search K
Appearance
Appearance
Other ways to support HackTricks:
Security Assertion Markup Language (SAML) enables identity providers (IdP) to be utilized for sending authorization credentials to service providers (SP), facilitating single sign-on (SSO). This approach simplifies the management of multiple logins by allowing a single set of credentials to be used across multiple websites. It leverages XML for standardized communication between IdPs and SPs, linking the authentication of user identity with service authorization.
For further details check the full post from https://epi052.gitlab.io/notes-to-self/blog/2019-03-07-how-to-test-saml-a-methodology/. This is a summary:
The SAML authentication process involves several steps, as illustrated in the schema:
Consider the scenario where a user requests access to a secure resource at https://shibdemo-sp1.test.edu/secure/. The SP identifies the lack of authentication and generates a SAML Request:
GET /secure/ HTTP/1.1
Host: shibdemo-sp1.test.edu
...
The raw SAML Request looks like this:
<?xml version="1.0"?>
<samlp:AuthnRequest ...
</samlp:AuthnRequest>
Key elements of this request include:
Following the SAML Request generation, the SP responds with a 302 redirect, directing the browser to the IdP with the SAML Request encoded in the HTTP response's Location header. The RelayState parameter maintains the state information throughout the transaction, ensuring the SP recognizes the initial resource request upon receiving the SAML Response. The SAMLRequest parameter is a compressed and encoded version of the raw XML snippet, utilizing Deflate compression and base64 encoding.
You can find a full SAML response here. The key components of the response include:
ds:Signature
elements, one for the message and the other for the assertion.Following the SAML Response, the process includes a 302 redirect from the IdP. This leads to a POST request to the Service Provider's Assertion Consumer Service (ACS) URL. The POST request includes RelayState
and SAMLResponse
parameters. The ACS is responsible for processing and validating the SAML Response.
After the POST request is received and the SAML Response is validated, access is granted to the protected resource initially requested by the user. This is illustrated with a GET
request to the /secure/
endpoint and a 200 OK
response, indicating successful access to the resource.
XML Signatures are versatile, capable of signing an entire XML tree or specific elements within it. They can be applied to any XML Object, not just Response elements. Below are the key types of XML Signatures:
An XML Signature consists of essential elements as shown:
<Signature>
<SignedInfo>
<CanonicalizationMethod />
<SignatureMethod />
<Reference>
<Transforms />
<DigestMethod />
<DigestValue />
</Reference>
...
</SignedInfo>
<SignatureValue />
<KeyInfo />
<Object />
</Signature>
Each Reference
element signifies a specific resource being signed, identifiable by the URI attribute.
Enveloped Signature: This type of signature is a descendant of the resource it signs, meaning the signature is contained within the same XML structure as the signed content.
Example:
<samlp:Response ... ID="..." ... >
...
<ds:Signature>
<ds:SignedInfo>
...
<ds:Reference URI="#...">
...
</ds:Reference>
</ds:SignedInfo>
</ds:Signature>
...
</samlp:Response>
In an enveloped signature, the ds:Transform
element specifies that it's enveloped through the enveloped-signature
algorithm.
Enveloping Signature: Contrasting with enveloped signatures, enveloping signatures wrap the resource being signed.
Example:
<ds:Signature>
<ds:SignedInfo>
...
<ds:Reference URI="#...">
...
</ds:Reference>
</ds:SignedInfo>
<samlp:Response ... ID="..." ... >
...
</samlp:Response>
</ds:Signature>
Detached Signature: This type is separate from the content it signs. The signature and the content exist independently, but a link between the two is maintained.
Example:
<samlp:Response ... ID="..." ... >
...
</samlp:Response>
<ds:Signature>
<ds:SignedInfo>
...
<ds:Reference URI="#...">
...
</ds:Reference>
</ds:SignedInfo>
</ds:Signature>
In conclusion, XML Signatures provide flexible ways to secure XML documents, with each type serving different structural and security needs.
Other ways to support HackTricks: