CVE-2024-45056
JSON

5.9medium

`fold (xor (shl 1, x), -1) -> (rotl ~1, x)` misoptimization in zksolc

Severity
5.9medium CVSS:3.1 by GitHub_M
Exploit likelihood
0.40% (higher than 36% of CVEs; EPSS, by FIRST)
Published
Last changed
Assigned by
GitHub_M

Description

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

Product or packageVersionsReported by
matter-labs era-compiler-solidity< 1.5.3, before 1.5.3CVE List
matter-labs zksolcbefore 1.5.3NVD

All scores

GitHub_M5.9medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N
NVD5.9medium CVSS:3.1CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N

Classification

CWE-682

SSVC (CISA-ADP): exploitation poc, automatable no, technical impact partial.

What each source says

CVE List

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.

NVD (es)

zksolc es un compilador de Solidity para ZKsync. Todas las versiones de LLVM desde 2015 convierten `(xor (shl 1, x), -1)` en `(rotl ~1, x)` si se ejecutan con optimizaciones habilitadas. Aquí, `~1` se genera como un número de 64 bits sin signo (`2^64-1`). Este número se extiende a 256 bits en el destino EraVM, mientras que debería haberse extendido a signo. Por lo tanto, en lugar de producir `roti 2^256 - 1, x`, el compilador produce `rotl 2^64 - 1, x`. El análisis ha demostrado que ningún contrato se vio afectado a la fecha de publicación de este aviso. Este problema se ha solucionado en la versión 1.5.3. Se recomienda a los usuarios que actualicen y vuelvan a implementar todos los contratos. No existen workarounds para esta vulnerabilidad.

References

Sources

SourceRecordLicence
CVE ListCVE-2024-45056 changed 2024-08-29CVE Terms of Use
NVDCVE-2024-45056 changed 2026-06-17Public domain