# GHSA-p9fg-j6ww-953m: FOSRestBundle issue with broken validation of JSONP callbacks

> Improper validation of JSONP callbacks in FOSRestBundle allows attackers to execute arbitrary JavaScript in victim browsers.

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

## What is GHSA-p9fg-j6ww-953m?

GHSA-p9fg-j6ww-953m is a cross-site scripting vulnerability in friendsofsymfony/rest-bundle, published on 15 May 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.

### Official description

Starting with FOSRestBundle 1.2 we [switched](https://github.com/FriendsOfSymfony/FOSRestBundle/pull/642/files#diff-431bc57ca9ca16332c0cff43ad45263cR37) to using [willdurand/jsonp-callback-validator](https://github.com/willdurand/JsonpCallbackValidator) for validation of JSONP callbacks. However [the change was implemented](https://github.com/FriendsOfSymfony/FOSRestBundle/pull/665) incorrectly validating the callback query param name, rather than its value. Anyone using the JSONP handler (which is off by default) together with FOSRestBundle 1.2.0 or 1.2.1 should update to FOSRestBundle [1.2.2](https://github.com/FriendsOfSymfony/FOSRestBundle/releases/tag/1.2.2).

## Which versions are affected by GHSA-p9fg-j6ww-953m?

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


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `friendsofsymfony/rest-bundle` | Packagist | From 1.2.0 | 1.2.2 |
| `friendsofsymfony/rest-bundle` | Packagist | From 1.2.0 | 1.2.2 |

## How do I fix GHSA-p9fg-j6ww-953m?

Upgrade friendsofsymfony/rest-bundle to 1.2.2 or later.

## Is GHSA-p9fg-j6ww-953m being exploited?

There is no known exploitation of GHSA-p9fg-j6ww-953m in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-p9fg-j6ww-953m and fix it if it is affected.

What it is: GHSA-p9fg-j6ww-953m is a cross-site scripting vulnerability in friendsofsymfony/rest-bundle, published on 15 May 2024. An attacker can exploit it over the internet without logging in, and only if a user opens a file or follows a link.
Exploitation: There is no known exploitation of GHSA-p9fg-j6ww-953m in the wild and no public exploit code.

Affected packages and fixed versions:
- friendsofsymfony/rest-bundle (Packagist): affected from 1.2.0; fixed in 1.2.2
- friendsofsymfony/rest-bundle (Packagist): affected from 1.2.0; fixed in 1.2.2

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-p9fg-j6ww-953m/ (Markdown: https://insights.sbomify.com/GHSA-p9fg-j6ww-953m/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-p9fg-j6ww-953m

---
From sbomify Insights: https://insights.sbomify.com/GHSA-p9fg-j6ww-953m/
Summaries are generated and may contain mistakes; the official description above is the record.
