# CVE-2023-40178: @node-saml/node-saml's validatePostRequestAsync does not include checkTimestampsValidityError

> Attackers can reuse expired SAML LogoutRequests to forcibly log out users, bypassing timestamp validation checks in the node-saml library.

- **Severity:** Medium 5.3 (`CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L`)
- **Exploited in the wild:** Not known
- **Login needed:** Not needed
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 23 Aug 2023
- **Updated:** 2 Oct 2024
- **Also known as:** GHSA-vx8m-6fhw-pccw

## What is CVE-2023-40178?

CVE-2023-40178 is a medium-severity vulnerability in node-saml, published on 23 Aug 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

Node-SAML is a SAML library not dependent on any frameworks that runs in Node. The lack of checking of current timestamp allows a LogoutRequest XML to be reused multiple times even when the current time is past the NotOnOrAfter. This could impact the user where they would be logged out from an expired LogoutRequest. In bigger contexts, if LogoutRequests are sent out in mass to different SPs, this could impact many users on a large scale. This issue was patched in version 4.0.5.

Weakness: CWE-613 (DEPRECATED: Insufficient Session Expiration), CWE-347 (Improper Verification of Cryptographic Signature)

## Which versions are affected by CVE-2023-40178?

2 open source packages ship an affected version, including @node-saml/node-saml. It affects 1 product.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@node-saml/node-saml` | npm | All versions | 4.0.5 |
| `@node-saml/node-saml` | npm | All versions | 4.0.5 |

Products: Node Saml Project Node Saml.

## How do I fix CVE-2023-40178?

Upgrade @node-saml/node-saml to 4.0.5 or later.

## Is CVE-2023-40178 being exploited?

It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-40178 exists.

## Other vulnerabilities in node-saml

- [CVE-2022-39300](https://insights.sbomify.com/CVE-2022-39300/): Signature bypass via multiple root elements in node-SAML (high 7.7)

## Fix prompt for AI coding agents

```text
Check this codebase for CVE-2023-40178 and fix it if it is affected.

What it is: CVE-2023-40178 is a medium-severity vulnerability in node-saml, published on 23 Aug 2023. An attacker can exploit it over the internet without logging in, with no action from the victim.
Exploitation: It is not confirmed as exploited in the wild, but public exploit code for CVE-2023-40178 exists.

Affected packages and fixed versions:
- @node-saml/node-saml (npm): affected all versions; fixed in 4.0.5
- @node-saml/node-saml (npm): affected all versions; fixed in 4.0.5

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/CVE-2023-40178/ (Markdown: https://insights.sbomify.com/CVE-2023-40178/index.md)
```

## Sources

- CVE record: https://www.cve.org/CVERecord?id=CVE-2023-40178
- NVD: https://nvd.nist.gov/vuln/detail/CVE-2023-40178
- OSV: https://osv.dev/vulnerability/CVE-2023-40178

---
From sbomify Insights: https://insights.sbomify.com/CVE-2023-40178/
Summaries are generated and may contain mistakes; the official description above is the record.
