Cloudanix VulnDB

CVE-2024-45056

Medium · 5.9

CVSS

5.9

EPSS

0.4%

Published

Aug 29, 2024

CISA due date

—

Cloudanix analysis

Monitor only SSVC: Track

A bug in the compiler used for certain blockchain smart contracts could make those contracts behave incorrectly, so teams should update the compiler and update their contracts on the network.

Exploitation
Supply Chain
Attacker needs
User Interaction
Complexity
Theoretical
Impact
Other
Component
Application
Class
Other
Remediation
Upgrade
Effort
Medium
Patch risk
Low

What it actually does

LLVM optimization incorrectly zero-extends a 64-bit mask instead of sign-extending to 256 bits on EraVM, emitting rotl 2^64-1,x instead of the expected roti 2^256-1,x for the pattern (xor (shl 1, x), -1).

Why it matters to the business

Developers using affected compiler versions risk deploying contracts with incorrect bitwise behavior on ZKsync EraVM; although no contracts were impacted at disclosure, all contracts must still be recompiled and redeployed after upgrade.

How an attack unfolds

An attacker compiles Solidity source containing the specific shift-xor pattern with an affected zksolc version; the resulting contract bytecode contains the wrong rotation constant and may produce incorrect results when executed on EraVM.

How to fix it

Upgrade matter-labs/era-compiler-solidity to commit 055ec47015e3b40cf821ac6e6aeb781f8094d167 (version 1.5.3) or later; recompile all contracts with the fixed compiler and redeploy them. No workarounds exist.

How to confirm the fix worked

Verify compiler binary reports version 1.5.3 or later; recompile a test contract containing the shift-xor pattern and inspect generated EraVM bytecode for the correct 256-bit rotation constant.

Typical attack path

  1. Locate or develop Solidity code containing (xor (shl 1, x), -1) or equivalent
  2. Compile with vulnerable zksolc/LLVM version under optimization
  3. Deploy resulting contract to ZKsync EraVM
  4. Trigger execution paths that exercise the faulty rotation

How to detect it

Search build logs and artifact repositories for zksolc versions prior to 1.5.3; inspect deployed contract bytecode for rotation operations using a 64-bit mask value instead of a full 256-bit mask.

What your security team should do

  • Immediately upgrade all build pipelines to the fixed compiler version
  • Recompile and redeploy every existing contract
  • Add compiler version checks to CI/CD pipelines
  • Monitor downstream dependents for continued use of pre-1.5.3 builds

The record

zksolc is a Solidity compiler for ZKsync. All LLVM versions since 2015 fold `(xor (shl 1, x), -1)` to `(rotl ~1, x)` if run with optimizations enabled. Here `~1` is generated as an unsigned 64 bits number (`2^64-1`). This number is zero-extended to 256 bits on EraVM target while it should have been sign-extended. Thus instead of producing `roti 2^256 - 1, x` the compiler produces `rotl 2^64 - 1, x`. Analysis has shown that no contracts were affected by the date of publishing this advisory. This issue has been addressed in version 1.5.3. Users are advised to upgrade and redeploy all contracts. There are no known workarounds for this vulnerability.

Affected packages

Ecosystem Package Introduced Fixed
Ubuntu:20.04:LTS llvm-toolchain-10 0 No fix
Ubuntu:20.04:LTS llvm-toolchain-11 0 No fix
Ubuntu:20.04:LTS llvm-toolchain-12 0 No fix
Ubuntu:20.04:LTS llvm-toolchain-6.0 0 No fix
Ubuntu:20.04:LTS llvm-toolchain-7 0 No fix
Ubuntu:20.04:LTS llvm-toolchain-8 0 No fix
Ubuntu:20.04:LTS llvm-toolchain-9 0 No fix
Ubuntu:22.04:LTS llvm-toolchain-11 0 No fix
Ubuntu:22.04:LTS llvm-toolchain-12 0 No fix
Ubuntu:22.04:LTS llvm-toolchain-13 0 No fix
Ubuntu:22.04:LTS llvm-toolchain-14 0 No fix
Ubuntu:22.04:LTS llvm-toolchain-15 0 No fix
Ubuntu:24.04:LTS llvm-toolchain-14 0 No fix
Ubuntu:24.04:LTS llvm-toolchain-15 0 No fix
Ubuntu:24.04:LTS llvm-toolchain-16 0 No fix
Ubuntu:24.04:LTS llvm-toolchain-17 0 No fix
Ubuntu:24.04:LTS llvm-toolchain-18 0 No fix
Ubuntu:Pro:14.04:LTS llvm-toolchain-3.6 0 No fix
Ubuntu:Pro:14.04:LTS llvm-toolchain-3.8 0 No fix
Ubuntu:Pro:14.04:LTS llvm-toolchain-3.9 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-3.5 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-3.6 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-3.7 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-3.8 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-3.9 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-4.0 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-5.0 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-6.0 0 No fix
Ubuntu:Pro:16.04:LTS llvm-toolchain-8 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-10 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-3.7 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-3.9 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-4.0 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-5.0 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-6.0 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-7 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-8 0 No fix
Ubuntu:Pro:18.04:LTS llvm-toolchain-9 0 No fix

Related vulnerabilities