# GHSA-wm63-7627-ch33: @vendure/core's insecure currencyCode handling allows wrong payment amounts

> Attackers can manipulate currency codes to pay incorrect amounts, bypassing price validation in Vendure e-commerce deployments.

- **Severity:** Not scored
- **Exploited in the wild:** Not known
- **Login needed:** Any signed-in user
- **Attackable:** Over the internet
- **Victim action needed:** Not needed
- **Fix available:** Yes
- **Published:** 17 Nov 2023

## What is GHSA-wm63-7627-ch33?

GHSA-wm63-7627-ch33 is a vulnerability in @vendure/core, published on 17 Nov 2023. Any signed-in user can exploit it over the network, with no action from the victim.

### Official description

### Impact

Currently, in many Vendure deployments it's possible to select any currencyCode (really any, doesn't need to be assigned to the channel) and pay through Mollie and Stripe in that particular currencyCode.
The prices are not transformed. The result is the Order is in Payment Settled in the foreign currency.
See SS, CZK is not in the channel.
I've tested with Mollie and Stripe it both works.

**Further notes**

After looking into this further and with help from the comments below, the root cause of this vulnerability is the ability to specify an arbitrary `currencyCode` as a query parameter to an API call, and then Vendure will use this and pass it to the rest of the system as `RequestContext.currencyCode`.

The solution is to add validation to the passed `currencyCode` to ensure that it matches one of the available `availableCurrencyCodes` of the active Channel.

Furthermore, an additional check has been added for when the currencyCode changes during the AddingItems stage - in this case we need to re-calculate the prices in the new currency.

### Patches
v2.1.3

### Workarounds
You can define a custom OrderProcess [onTransitionStart function](https://docs.vendure.io/guides/core-concepts/orders/#intercepting-a-state-transition) which can verify the order's `currencyCode` is as expected before allowing the transition to the `ArrangingPayment` state.

## Which versions are affected by GHSA-wm63-7627-ch33?

2 open source packages ship an affected version, including @vendure/core.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `@vendure/core` | npm | All versions | 2.1.3 |
| `@vendure/core` | npm | All versions | 2.1.3 |

## How do I fix GHSA-wm63-7627-ch33?

Upgrade @vendure/core to 2.1.3 or later.

## Is GHSA-wm63-7627-ch33 being exploited?

There is no known exploitation of GHSA-wm63-7627-ch33 in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-wm63-7627-ch33 and fix it if it is affected.

What it is: GHSA-wm63-7627-ch33 is a vulnerability in @vendure/core, published on 17 Nov 2023. Any signed-in user can exploit it over the network, with no action from the victim.
Exploitation: There is no known exploitation of GHSA-wm63-7627-ch33 in the wild and no public exploit code.

Affected packages and fixed versions:
- @vendure/core (npm): affected all versions; fixed in 2.1.3
- @vendure/core (npm): affected all versions; fixed in 2.1.3

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-wm63-7627-ch33/ (Markdown: https://insights.sbomify.com/GHSA-wm63-7627-ch33/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-wm63-7627-ch33

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