# GHSA-9wrw-p9rm-r782: onelogin/php-saml Improper signature validation on LogoutRequest/LogoutResponse.

> An attacker can bypass SAML logout signature validation due to incorrect boolean conversion of error codes, allowing unauthorized session termination.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 May 2024

## What is GHSA-9wrw-p9rm-r782?

GHSA-9wrw-p9rm-r782 is a vulnerability in onelogin/php-saml, published on 17 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

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.

## Which versions are affected by GHSA-9wrw-p9rm-r782?

2 open source packages ship an affected version, including onelogin/php-saml.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `onelogin/php-saml` | Packagist | All versions | 2.10.4 |
| `onelogin/php-saml` | Packagist | All versions | 2.10.4 |

## How do I fix GHSA-9wrw-p9rm-r782?

Upgrade onelogin/php-saml to 2.10.4 or later.

## Is GHSA-9wrw-p9rm-r782 being exploited?

There is no known exploitation of GHSA-9wrw-p9rm-r782 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-9wrw-p9rm-r782 and fix it if it is affected.

What it is: GHSA-9wrw-p9rm-r782 is a vulnerability in onelogin/php-saml, published on 17 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-9wrw-p9rm-r782 in the wild and no public exploit code.

Affected packages and fixed versions:
- onelogin/php-saml (Packagist): affected all versions; fixed in 2.10.4
- onelogin/php-saml (Packagist): affected all versions; fixed in 2.10.4

Task:
1. Search the dependency manifests and lockfiles (for example package.json, package-lock.json, requirements.txt, poetry.lock, uv.lock, pom.xml, build.gradle, go.mod, Cargo.lock, Gemfile.lock) and any Dockerfiles for the affected packages, including transitive dependencies.
2. If an affected version is in use, upgrade it to the fixed version for its release line with the project's package manager, so the lockfile is regenerated. Prefer the smallest upgrade that fixes it.
3. If there is no fix, or the upgrade would break the build, do not guess: explain the risk and the safest workaround instead.
4. Run the tests and summarise what changed and why.
5. If nothing in the project is affected, say so and change nothing.

Reference: https://insights.sbomify.com/GHSA-9wrw-p9rm-r782/ (Markdown: https://insights.sbomify.com/GHSA-9wrw-p9rm-r782/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-9wrw-p9rm-r782

---
From sbomify Insights: https://insights.sbomify.com/GHSA-9wrw-p9rm-r782/
Summaries are generated and may contain mistakes; the official description above is the record.
