# CVE-2023-31287: Insufficient token expiration in Serenity

> Attackers can reuse password reset tokens to take over user accounts if they access browser history, affecting Serenity Serene users.

- **Severity:** High 7.8 (`CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H`)
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Local or same network only
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 27 Apr 2023
- **Updated:** 13 Feb 2025
- **Also known as:** GHSA-2hp9-3xfr-r9w2

## What is CVE-2023-31287?

CVE-2023-31287 is a high-severity vulnerability in n/a, published on 27 Apr 2023. It can only be exploited from the same machine or local network, with no action from the victim.

### Official description

An issue was discovered in Serenity Serene (and StartSharp) before 6.7.0. Password reset links are sent by email. A link contains a token that is used to reset the password. This token remains valid even after the password reset and can be used a second time to change the password of the corresponding user. The token expires only 3 hours after issuance and is sent as a query parameter when resetting. An attacker with access to the browser history can thus use the token again to change the password in order to take over the account.

Weakness: CWE-640 (Weak Password Recovery Mechanism for Forgotten Password)

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

4 open source packages ship an affected version, including Serenity.Net.Core and Serenity.Net.Web. It affects 2 products.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `Serenity.Net.Core` | NuGet | All versions | 6.7.0 |
| `Serenity.Net.Core` | NuGet | All versions | 6.7.0 |
| `Serenity.Net.Web` | NuGet | All versions | 6.7.0 |
| `Serenity.Net.Web` | NuGet | All versions | 6.7.0 |

Products: Serenity Serene, Serenity Startsharp.

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

Upgrade Serenity.Net.Core to 6.7.0 or later.

## Is CVE-2023-31287 being exploited?

There is no known exploitation of CVE-2023-31287 in the wild and no public exploit code.

## Other vulnerabilities in n/a

- [CVE-2023-31285](https://insights.sbomify.com/CVE-2023-31285/): Cross Site Scripting (XSS) in Serenity (medium 6.1)
- [CVE-2023-31286](https://insights.sbomify.com/CVE-2023-31286/): User account enumeration in Serenity (medium 5.3)

## Fix prompt for AI coding agents

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

What it is: CVE-2023-31287 is a high-severity vulnerability in n/a, published on 27 Apr 2023. It can only be exploited from the same machine or local network, with no action from the victim.
Exploitation: There is no known exploitation of CVE-2023-31287 in the wild and no public exploit code.

Affected packages and fixed versions:
- Serenity.Net.Core (NuGet): affected all versions; fixed in 6.7.0
- Serenity.Net.Core (NuGet): affected all versions; fixed in 6.7.0
- Serenity.Net.Web (NuGet): affected all versions; fixed in 6.7.0
- Serenity.Net.Web (NuGet): affected all versions; fixed in 6.7.0

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

## Sources

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

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