# GHSA-pjx8-984p-7p3x: FOSUserBundle Entropy is lost in the TokenGenerator

> Weak token generation in FOSUserBundle allows attackers to predict email confirmation and password reset tokens, potentially leading to account takeover.

- **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:** 15 May 2024

## What is GHSA-pjx8-984p-7p3x?

GHSA-pjx8-984p-7p3x is a vulnerability in friendsofsymfony/user-bundle, published on 15 May 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Description
Because of the usage of base_convert which looses precision for large inputs, the entropy of tokens generated by FOSUserBundle for the email confirmation and password resetting is lost. This makes these tokens much less random than they are expected to be, and so not cryptographically safe.

### Resolution
The token generation logic used in the 2.0.x branch based on base64 encoding has been backported. This changes the range of characters used in the token. Any route placeholder expected to match a token generated by FOSUserBundle must be updated to allow dashes, which are not allowed by \w in regexes. A \w+ requirement should so become [\w\-]+.

## Which versions are affected by GHSA-pjx8-984p-7p3x?

2 open source packages ship an affected version, including friendsofsymfony/user-bundle.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `friendsofsymfony/user-bundle` | Packagist | From 1.0.0 | 1.3.5 |
| `friendsofsymfony/user-bundle` | Packagist | From 1.0.0 | 1.3.5 |

## How do I fix GHSA-pjx8-984p-7p3x?

Upgrade friendsofsymfony/user-bundle to 1.3.5 or later.

## Is GHSA-pjx8-984p-7p3x being exploited?

There is no known exploitation of GHSA-pjx8-984p-7p3x in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-pjx8-984p-7p3x and fix it if it is affected.

What it is: GHSA-pjx8-984p-7p3x is a vulnerability in friendsofsymfony/user-bundle, published on 15 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-pjx8-984p-7p3x in the wild and no public exploit code.

Affected packages and fixed versions:
- friendsofsymfony/user-bundle (Packagist): affected from 1.0.0; fixed in 1.3.5
- friendsofsymfony/user-bundle (Packagist): affected from 1.0.0; fixed in 1.3.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/GHSA-pjx8-984p-7p3x/ (Markdown: https://insights.sbomify.com/GHSA-pjx8-984p-7p3x/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-pjx8-984p-7p3x

---
From sbomify Insights: https://insights.sbomify.com/GHSA-pjx8-984p-7p3x/
Summaries are generated and may contain mistakes; the official description above is the record.
