# GHSA-rg2q-2jh9-447q: Gas mispricing in cosmwasm-vm

> A malicious smart contract can cause a blockchain denial of service by exploiting gas mispricing in the CosmWasm VM library.

- **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:** 8 Aug 2024
- **Also known as:** RUSTSEC-2024-0361

## What is GHSA-rg2q-2jh9-447q?

GHSA-rg2q-2jh9-447q is a denial of service vulnerability in github.com/CosmWasm/wasmvm, published on 8 Aug 2024. An attacker can exploit it over the internet without logging in, with no action from the victim.

### Official description

**Component:** wasmvm
**Criticality:** Medium ([ACMv1](https://github.com/interchainio/security/blob/main/resources/CLASSIFICATION_MATRIX.md): I:Moderate; L:Likely)
**Patched versions:** wasmvm 1.5.4, 2.0.3, 2.1.2

Some Wasm operations take significantly more gas than our benchmarks indicated. This can lead to missing the [gas target](https://github.com/CosmWasm/cosmwasm/blob/e50490c4199a234200a497219b27f071c3409f58/docs/GAS.md#cosmwasm-gas-pricing) we defined by a factor of ~10x. This means a malicious contract could take 10 times as much time to execute as expected, which can be used to temporarily DoS a chain.

See [CWA-2024-004](https://github.com/CosmWasm/advisories/blob/main/CWAs/CWA-2024-004.md) for more details.

## Which versions are affected by GHSA-rg2q-2jh9-447q?

13 open source packages ship an affected version, including github.com/CosmWasm/wasmvm/v2, github.com/CosmWasm/wasmvm and cosmwasm-vm.


| Package | Ecosystem | Affected | Fixed in |
| --- | --- | --- | --- |
| `github.com/CosmWasm/wasmvm/v2` | Go | From 2.0.0 | 2.0.3 |
| `github.com/CosmWasm/wasmvm/v2` | Go | From 2.0.0 | 2.0.3 |
| `github.com/CosmWasm/wasmvm/v2` | Go | From 2.1.0 | 2.1.2 |
| `github.com/CosmWasm/wasmvm/v2` | Go | From 2.1.0 | 2.1.2 |
| `github.com/CosmWasm/wasmvm` | Go | All versions | 1.5.4 |
| `github.com/CosmWasm/wasmvm` | Go | All versions | 1.5.4 |
| `cosmwasm-vm` | crates.io | All versions | 1.5.6 |
| `cosmwasm-vm` | crates.io | All versions | 1.5.6 |
| `cosmwasm-vm` | crates.io | From 0.0.0-0 | 1.5.7, 2.0.6, 2.1.3 |
| `cosmwasm-vm` | crates.io | From 2.0.0 | 2.0.5 |
| `cosmwasm-vm` | crates.io | From 2.0.0 | 2.0.5 |
| `cosmwasm-vm` | crates.io | From 2.1.0 | 2.1.2 |
| `cosmwasm-vm` | crates.io | From 2.1.0 | 2.1.2 |

## How do I fix GHSA-rg2q-2jh9-447q?

Upgrade github.com/CosmWasm/wasmvm/v2 to a fixed version for your release line: 2.0.3 or 2.1.2.

## Is GHSA-rg2q-2jh9-447q being exploited?

There is no known exploitation of GHSA-rg2q-2jh9-447q in the wild and no public exploit code.

## Fix prompt for AI coding agents

```text
Check this codebase for GHSA-rg2q-2jh9-447q and fix it if it is affected.

What it is: GHSA-rg2q-2jh9-447q is a denial of service vulnerability in github.com/CosmWasm/wasmvm, published on 8 Aug 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-rg2q-2jh9-447q in the wild and no public exploit code.

Affected packages and fixed versions:
- github.com/CosmWasm/wasmvm/v2 (Go): affected from 2.0.0; fixed in 2.0.3
- github.com/CosmWasm/wasmvm/v2 (Go): affected from 2.0.0; fixed in 2.0.3
- github.com/CosmWasm/wasmvm/v2 (Go): affected from 2.1.0; fixed in 2.1.2
- github.com/CosmWasm/wasmvm/v2 (Go): affected from 2.1.0; fixed in 2.1.2
- github.com/CosmWasm/wasmvm (Go): affected all versions; fixed in 1.5.4
- github.com/CosmWasm/wasmvm (Go): affected all versions; fixed in 1.5.4
- cosmwasm-vm (crates.io): affected all versions; fixed in 1.5.6
- cosmwasm-vm (crates.io): affected all versions; fixed in 1.5.6
- cosmwasm-vm (crates.io): affected from 0.0.0-0; fixed in 1.5.7, 2.0.6, 2.1.3
- cosmwasm-vm (crates.io): affected from 2.0.0; fixed in 2.0.5
- cosmwasm-vm (crates.io): affected from 2.0.0; fixed in 2.0.5
- cosmwasm-vm (crates.io): affected from 2.1.0; fixed in 2.1.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-rg2q-2jh9-447q/ (Markdown: https://insights.sbomify.com/GHSA-rg2q-2jh9-447q/index.md)
```

## Sources

- OSV: https://osv.dev/vulnerability/GHSA-rg2q-2jh9-447q

---
From sbomify Insights: https://insights.sbomify.com/GHSA-rg2q-2jh9-447q/
Summaries are generated and may contain mistakes; the official description above is the record.
