Skip to content

Latest commit

 

History

History
67 lines (45 loc) · 2.69 KB

CWA-2024-004.md

File metadata and controls

67 lines (45 loc) · 2.69 KB

CWA-2024-004: Gas mispricing in cosmwasm-vm

Severity

Medium (Moderate + Likely)1

Affected versions:

  • wasmvm >= 2.1.0, < 2.1.2
  • wasmvm >= 2.0.0, < 2.0.3
  • wasmvm < 1.5.4
  • cosmwasm-vm >= 2.1.0, < 2.1.3
  • cosmwasm-vm >= 2.0.0, < 2.0.6
  • cosmwasm-vm < 1.5.7

Patched versions:

  • wasmvm 1.5.4, 2.0.3, 2.1.2
  • cosmwasm-vm 1.5.7, 2.0.6, 2.1.3

Description of the bug

Some Wasm operations take significantly more gas than our benchmarks indicated. This can lead to missing the gas target 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.

Patch

See the cosmwasm-vm with gas price adjustments:

Applying the patch

The patch will be shipped in releases of wasmvm. You can update more or less as follows:

  1. Check the current wasmvm version: go list -m github.com/CosmWasm/wasmvm
  2. Bump the github.com/CosmWasm/wasmvm dependency in your go.mod to 1.5.4, 2.0.3 or 2.1.2 depending on which minor version you are; go mod tidy; commit.
  3. If you use the static libraries libwasmvm_muslc.aarch64.a/libwasmvm_muslc.x86_64.a, update them accordingly.
  4. Check the updated wasmvm version: go list -m github.com/CosmWasm/wasmvm and ensure you see 1.5.4, 2.0.3 or 2.1.2.
  5. Follow your regular practices to deploy chain upgrades.

To double check if the correct libary version is loaded at runtime, use this query: <appd> query wasm libwasmvm-version. It must show 1.5.4, 2.0.3 or 2.1.2.

The patch is consensus breaking and requires a coordinated upgrade.

Acknowledgement

This issue was found by unknown feature who reported it to the Cosmos Bug Bounty Program on HackerOne.

If you believe you have found a bug in the Interchain Stack or would like to contribute to the program by reporting a bug, please see https://hackerone.com/cosmos.

Timeline

  • 2024-07-31: Confio receives a report through the Amulet program.
  • 2024-08-01: Confio security contributors confirm the report.
  • 2024-08-02: Confio developed the patch internally.
  • 2024-08-08: Patch released
  • 2024-08-08: Updated patched versions to ones that will invalidate the cache

Footnotes

  1. following Amulet's Severity Classification Framework ACMv1: https://github.com/interchainio/security/blob/e0227a1fb4059144aab4f6003eeee7f09912db3a/resources/CLASSIFICATION_MATRIX.md