# GHSA-jjmg-x456-w976: Incorrect default cookie name and recommendation

> Incorrect default cookie prefix allows bypassing __Host- security protections, potentially enabling cross-site request forgery or cookie manipulation.

- **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:** 10 Oct 2022

## What is GHSA-jjmg-x456-w976?

GHSA-jjmg-x456-w976 is a vulnerability in csrf-csrf, published on 10 Oct 2022. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

### Impact
_What kind of vulnerability is it? Who is impacted?_

The default cookie name (and documentation recommendation) was prefixed with `Host__` instead of `__Host-`. The point of this prefix is for additional security, to ensure that, when no domain option is provided in the cookie options, we can guarantee the cookie came from the correct domain.

### Patches
_Has the problem been patched? What versions should users upgrade to?_

Yes, the problem is patched from version 2.2.1, this will not be back ported, but you can use the workaround described below.

### Workarounds
_Is there a way for users to fix or remediate the vulnerability without upgrading?_

You can work around this by providing a custom `cookieName` as part of the options, which is correctly prefixed with `__Host-`.

### References
_Are there any links users can visit to find out more?_

https://cheatsheetseries.owasp.org/cheatsheets/Cross-Site_Request_Forgery_Prevention_Cheat_Sheet.html#cookie-with-__host-prefix

### For more information
If you have any questions or comments about this advisory:
* Reach out on the [Psifi Solutions Discord](https://psifisolutions.com/discord) in the `#psifi-support` channel

## Which versions are affected by GHSA-jjmg-x456-w976?

2 open source packages ship an affected version, including csrf-csrf.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `csrf-csrf` | npm | All versions | 2.2.1 |
| `csrf-csrf` | npm | All versions | 2.2.1 |

## How do I fix GHSA-jjmg-x456-w976?

Upgrade csrf-csrf to 2.2.1 or later.

## Is GHSA-jjmg-x456-w976 being exploited?

There is no known exploitation of GHSA-jjmg-x456-w976 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-jjmg-x456-w976 and fix it if it is affected.

What it is: GHSA-jjmg-x456-w976 is a vulnerability in csrf-csrf, published on 10 Oct 2022. 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-jjmg-x456-w976 in the wild and no public exploit code.

Affected packages and fixed versions:
- csrf-csrf (npm): affected all versions; fixed in 2.2.1
- csrf-csrf (npm): affected all versions; fixed in 2.2.1

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-jjmg-x456-w976/ (Markdown: https://insights.sbomify.com/GHSA-jjmg-x456-w976/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-jjmg-x456-w976

---
From sbomify Insights: https://insights.sbomify.com/GHSA-jjmg-x456-w976/
Summaries are generated and may contain mistakes; the official description above is the record.
