Update php-saml library to 2.10.5
The php-saml library's signature validation for LogoutRequest and LogoutResponse treated an error state (-1) from openssl_verify() as a successful verification due to implicit boolean conversion. An attacker could potentially bypass signature checks on logout messages, though the impact is lower because SAMLResponse validation was unaffected.
Originally disclosed on HackerOne
- Triaged in under an hour
- Fixed in 13 days
- Disclosed after 43 days
The php-saml library as used by our SSO implementation had a minor security patch in 2.10.4 as per https://github.com/onelogin/php-saml/commit/949359f5cad5e1d085c4e5447d9aa8f49a6e82a1. So we should update this in our next minor releases.
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.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the code implicitly converted the integer return value of openssl_verify() to a boolean, so the error value -1 became true.
Impact
An attacker could potentially bypass signature validation on SAML logout requests and responses, but the impact is lower because SAMLResponse validation was not affected.
What the attacker needed
Attacker can send crafted SAML logout messages
The fix
The library should be updated to include the 2.10.4 security patch for proper signature validation.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a computer checks a digital signature, it gets a number back: 1 means valid, 0 means invalid, and -1 means an error occurred. The library mistakenly treated -1 as 'true' (valid) because in many programming languages any non-zero number is considered true. This meant that if an error happened during the check, the logout message was accepted as if the signature were correct.
What is Crypto?
Encryption, signatures, randomness or certificate checks that do not protect what they claim to.