# GHSA-7mx2-7q8p-pgmw: Symfony may allow a user to switch to using another user's identity

> Authenticated users can switch identities to other users by modifying their username in a form, leading to account takeover.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** A user has to click or open something
- **Fix available:** Yes
- **Published:** 30 May 2024

## What is GHSA-7mx2-7q8p-pgmw?

GHSA-7mx2-7q8p-pgmw is an authentication bypass vulnerability in symfony/symfony, published on 30 May 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.

### Official description

Symfony 2.0.6 has just been released. It addresses a security vulnerability in the EntityUserProvider as provided in the Doctrine bridge.

If you let your users update their login/username from a form, and if you are using Doctrine as a user provider, then you are vulnerable and you should upgrade as soon as possible.

The issue is that it is possible for a user to switch to another one. Here is how to reproduce it: The current user changes its username via a form to another existing username. When the form is submitted, he will have a validation error (as the username already exists) but the user object in the session will still be modified to the new username. This user from the session will be used for the next requests and so the user will be switched to this other user.

The fix is to always refresh the user via the primary key (which cannot be updated via a form) instead of the username.

If you cannot upgrade immediately, please apply the following patch: https://github.com/symfony/symfony/commit/9d2ab9ca9c1762

## Which versions are affected by GHSA-7mx2-7q8p-pgmw?

2 open source packages ship an affected version, including symfony/symfony.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `symfony/symfony` | Packagist | From 2.0.0 | 2.0.6 |
| `symfony/symfony` | Packagist | From 2.0.0 | 2.0.6 |

## How do I fix GHSA-7mx2-7q8p-pgmw?

Upgrade symfony/symfony to 2.0.6 or later.

## Is GHSA-7mx2-7q8p-pgmw being exploited?

There is no known exploitation of GHSA-7mx2-7q8p-pgmw in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-7mx2-7q8p-pgmw and fix it if it is affected.

What it is: GHSA-7mx2-7q8p-pgmw is an authentication bypass vulnerability in symfony/symfony, published on 30 May 2024. Any signed-in user can exploit it over the network, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-7mx2-7q8p-pgmw in the wild and no public exploit code.

Affected packages and fixed versions:
- symfony/symfony (Packagist): affected from 2.0.0; fixed in 2.0.6
- symfony/symfony (Packagist): affected from 2.0.0; fixed in 2.0.6

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-7mx2-7q8p-pgmw/ (Markdown: https://insights.sbomify.com/GHSA-7mx2-7q8p-pgmw/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-7mx2-7q8p-pgmw

---
From sbomify Insights: https://insights.sbomify.com/GHSA-7mx2-7q8p-pgmw/
Summaries are generated and may contain mistakes; the official description above is the record.
