Skip to content

OneLogin's SAML PHP Toolkit v4.5.0

Latest

Choose a tag to compare

@pitbulk pitbulk released this 18 Nov 15:09
dd404f4

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 with retrieveParametersFromServer: 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 example RelayState=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 retrieveParametersFromServer is true:
      • Utils::extractOriginalQueryParam only 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 anymore
      • Utils::validateBinarySign requires that its $getData holds 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
  • Utils::getSelfProtocol always returns a string. When the protocol (the value of $_SERVER['HTTP_X_FORWARDED_PROTO'] or the one set with setSelfProtocol) is an array, the first value is used; true is 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-Proto header of a chain of proxies, https,http), the first value is used in Utils::getSelfProtocol, as X-Forwarded-Host already 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::setBaseURL ignores a boolean true (it does not clear the base URL that was set)
  • Reject decrypted EncryptedID content that is not an element (a text node made LogoutRequest::getNameIdData fail 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::parseRemoteXML accepts extra curl options in a new optional $curlOptions parameter. They are applied last, so they override the ones that the method sets (except CURLOPT_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 $curlOptions to change them