It contains several security improvements. Update to this version if you using 4.X branch.
- Refactor Signature validation on Signed Responses with Encrypted Assertion
- Fix #661. Type comparaison error for proxy port
#667 HTTP-Redirect signature validation withretrieveParametersFromServer: SAMLRequest, SAMLResponse, RelayState, SigAlg and Signature are matched against the complete field names of the query string, instead of searched as substrings of it. A signed Logout Request/Response with one of those names inside a value or inside the name of another parameter (for exampleRelayState=Signature) is now validated; it was rejected with "Duplicate parameter in query string" or "Both SAMLRequest and SAMLResponse provided". A message signed with an empty RelayState (RelayState=&SigAlg=...) is now validated; its signature validation failed- Security: with
retrieveParametersFromServer, a field that PHP parses as one of those parameters (its name has leading spaces, percent-encoded characters, a NUL byte or array brackets) counts as that parameter, so a query string with a second SAMLRequest, SAMLResponse, RelayState, SigAlg or Signature sent that way is rejected with "Duplicate parameter in query string". The message is also rejected ("The SAMLRequest parameter does not match the one of the query string", same for SAMLResponse, RelayState and SigAlg) when the value that PHP parsed is not the value of the query string that the signature covers. Before, the signature of a message could be verified while a different message was processed - Compatibility notes for the two previous changes. They only affect the HTTP-Redirect binding when
retrieveParametersFromServeris true:Utils::extractOriginalQueryParamonly returns the value of the field with exactly that name, and an empty string when there is no such field (it returned an unrelated piece of the query string). A name that is part of another name or value, or that comes after a leading?at$_SERVER['QUERY_STRING'], is not found anymoreUtils::validateBinarySignrequires that its$getDataholds the values parsed from$_SERVER['QUERY_STRING']. If the application changes the SAMLRequest/SAMLResponse, RelayState or SigAlg values of$_GET(adds slashes, trims them...) or sets$_SERVER['QUERY_STRING']itself with other content, the message is rejected- A query string with an alias of a reserved parameter is rejected even if the alias has no effect (it comes before the signed parameter or repeats its value)
- Parameters that only have a reserved name inside their name (
SigAlgorithm,xSAMLRequest...) are ignored; they were a "Duplicate parameter in query string" - The messages returned by
getLastErrorReason()/getError()for those requests change accordingly
- Security: with
Utils::getSelfProtocolalways returns a string. When the protocol (the value of$_SERVER['HTTP_X_FORWARDED_PROTO']or the one set withsetSelfProtocol) is an array, the first value is used;trueis https and any other value that is not a string is http- When the protocol is a list of values separated by commas (the
X-Forwarded-Protoheader of a chain of proxies,https,http), the first value is used inUtils::getSelfProtocol, asX-Forwarded-Hostalready did - When X-Forwarded-Host or X-Forwarded-Port are lists of values separated by commas, the first value is used without the spaces around it
Utils::setBaseURLignores a booleantrue(it does not clear the base URL that was set)- Reject decrypted EncryptedID content that is not an element (a text node made
LogoutRequest::getNameIdDatafail with a PHP Error) - Load XML documents with LIBXML_NONET
- Add validateSignatureStructure check into Utils and use at ValidateSignature
- Add validation for Assertion Version
- #658
IdPMetadataParser::parseRemoteXMLaccepts extra curl options in a new optional$curlOptionsparameter. They are applied last, so they override the ones that the method sets (exceptCURLOPT_RETURNTRANSFER); options that are not valid raise an Exception. The request now has default timeouts: 10 seconds to connect and 120 seconds in total (it had none), use$curlOptionsto change them