Skip to content

Commit 949359f

Browse files
committed
Security update for signature validation on LogoutRequest/LogoutResponse.
In order to verify Signatures on Logoutrequests and LogoutResponses we use the verifySignature of the class XMLSecurityKey from the xmlseclibs library. That method end up calling openssl_verify() depending on the signature algorithm used. The openssl_verify() function returns 1 when the signature was successfully verified, 0 if it failed to verify with the given key, and -1 in case an error occurs. PHP allows translating numerical values to boolean implicitly, with the following correspondences: - 0 equals false. - Non-zero equals true. This means that an implicit conversion to boolean of the values returned by openssl_verify() will convert an error state, signaled by the value -1, to a successful verification of the signature (represented by the boolean true). The LogoutRequest/LogoutResponse signature validator was performing an implicit conversion to boolean of the values returned by the verify() method, which subsequently will return the same output as openssl_verify() under most circumstances. This means an error during signature verification is treated as a successful verification by the method. Since the signature validation of SAMLResponses were not affected, the impact of this security vulnerability is lower, but an update of the php-saml toolkit is recommended.
1 parent 595eeba commit 949359f

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

lib/Saml2/LogoutRequest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ public function isValid($retrieveParametersFromServer=false)
402402
}
403403
}
404404

405-
if (!$objKey->verifySignature($signedQuery, base64_decode($_GET['Signature']))) {
405+
if ($objKey->verifySignature($signedQuery, base64_decode($_GET['Signature'])) !== 1) {
406406
throw new OneLogin_Saml2_ValidationError(
407407
"Signature validation failed. Logout Request rejected",
408408
OneLogin_Saml2_ValidationError::INVALID_SIGNATURE

lib/Saml2/LogoutResponse.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ public function isValid($requestId = null, $retrieveParametersFromServer=false)
209209
}
210210
}
211211

212-
if (!$objKey->verifySignature($signedQuery, base64_decode($_GET['Signature']))) {
212+
if ($objKey->verifySignature($signedQuery, base64_decode($_GET['Signature'])) !== 1) {
213213
throw new OneLogin_Saml2_ValidationError(
214214
"Signature validation failed. Logout Response rejected",
215215
OneLogin_Saml2_ValidationError::INVALID_SIGNATURE

0 commit comments

Comments
 (0)