Skip to content

Commit 287540a

Browse files
committed
Add warning about the use of IdpMetadataParser class. If Metadata URLs are provided by 3rd parties, the URL inputs MUST be validated to avoid issues like SSRF
1 parent 58a63f5 commit 287540a

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,6 +1390,9 @@ Auxiliary class that contains several methods to retrieve and process IdP metada
13901390
* `parseXML` - Get IdP Metadata Info from XML.
13911391
* `injectIntoSettings` - Inject metadata info into php-saml settings array.
13921392

1393+
The class does not validate in any way the URL that is introduced on methods like parseRemoteXML in order to retrieve the remove XML. Usually is the same administrator that handles the Service Provider the ones that set the URL that should belong to a trusted third-party IdP.
1394+
But there are other scenarios, like a SAAS app where the administrator of the app delegates on other administrators. In such case, extra protection should be taken in order to validate such URL inputs and avoid attacks like SSRF.
1395+
13931396

13941397
For more info, look at the source code; each method is documented and details
13951398
about what it does and how to use it are provided. Make sure to also check the doc folder where

src/Saml2/IdPMetadataParser.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ class IdPMetadataParser
2626
/**
2727
* Get IdP Metadata Info from URL
2828
*
29+
* This class does not validate in any way the URL that is introduced,
30+
* make sure to validate it properly before use it in the parseRemoteXML
31+
* method in order to avoid security issues like SSRF attacks.
32+
*
2933
* @param string $url URL where the IdP metadata is published
3034
* @param string $entityId Entity Id of the desired IdP, if no
3135
* entity Id is provided and the XML
@@ -43,6 +47,9 @@ public static function parseRemoteXML($url, $entityId = null, $desiredNameIdForm
4347

4448
try {
4549
$ch = curl_init($url);
50+
curl_setopt($ch, CURLOPT_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP);
51+
curl_setopt($ch, CURLOPT_REDIR_PROTOCOLS, CURLPROTO_HTTPS | CURLPROTO_HTTP);
52+
curl_setopt($ch, CURLOPT_MAXREDIRS, 5);
4653
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
4754
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
4855
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

0 commit comments

Comments
 (0)