{"id":"CVE-2024-32649","aliases":["CVE-2024-32649","GHSA-5jrj-52x8-m64h","PYSEC-2024-209"],"related":[],"kind":"vulnerability","state":"published","title":"vyper performs double eval of the argument of sqrt","summary":"Vyper is a pythonic Smart Contract Language for the Ethereum virtual machine. In versions 0.3.10 and prior, using the `sqrt` builtin can result in double eval vulnerability when the argument has side-effects. It can be seen that the `build_IR` function of the `sqrt` builtin doesn't cache the argument to the stack. As such, it can be evaluated multiple times (instead of retrieving the value from the stack). No vulnerable production contracts were found. Additionally, double evaluation of side-effects should be easily discoverable in client tests. As such, the impact is low. As of time of publication, no fixed versions are available.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Vyper is a pythonic Smart Contract Language for the Ethereum virtual machine. In versions 0.3.10 and prior, using the `sqrt` builtin can result in double eval vulnerability when the argument has side-effects. It can be seen that the `build_IR` function of the `sqrt` builtin doesn't cache the argument to the stack. As such, it can be evaluated multiple times (instead of retrieving the value from the stack). No vulnerable production contracts were found. Additionally, double evaluation of side-effects should be easily discoverable in client tests. As such, the impact is low. As of time of publication, no fixed versions are available.","source":"cvelist"},{"lang":"en","text":"### Summary\nUsing the `sqrt` builtin can result in multiple eval evaluation of side effects when the argument has side-effects. The bug is more difficult (but not impossible!) to trigger as of 0.3.4, when the unique symbol fence was introduced (https://github.com/vyperlang/vyper/pull/2914).\n\nA contract search was performed and no vulnerable contracts were found in production.\n\n### Details\nIt can be seen that the `build_IR` function of the `sqrt` builtin doesn't cache the argument to the stack: \nhttps://github.com/vyperlang/vyper/blob/4595938734d9988f8e46e8df38049ae0559abedb/vyper/builtins/functions.py#L2151\n\nAs such, it can be evaluated multiple times (instead of retrieving the value from the stack).\n\n### PoC\nWith at least Vyper version `0.2.15+commit.6e7dba7` the following contract:\n```vyper\nc: uint256\n\n@internal\ndef some_decimal() -> decimal:\n    self.c += 1\n    return 1.0\n\n@external\ndef foo() -> uint256:\n    k: decimal = sqrt(self.some_decimal())\n    return self.c\n```\npasses the following test:\n```solidity\n// SPDX-License-Identifier: MIT\npragma solidity >=0.8.13;\n\nimport \"../../lib/ds-test/test.sol\";\nimport \"../../lib/utils/Console.sol\";\nimport \"../../lib/utils/VyperDeployer.sol\";\n\nimport \"../ITest.sol\";\n\ncontract ConTest is DSTest {\n    VyperDeployer vyperDeployer = new VyperDeployer();\n\n    ITest t;\n\n    function setUp() public {\n        t = ITest(vyperDeployer.deployContract(\"Test\"));\n    }\n\n    function testFoo() public {\n        uint256 val = t.foo();\n        console.log(val);\n        assert (val == 4);\n    }\n}\n```\n \n### Patches\nPatched in https://github.com/vyperlang/vyper/pull/3976.\n\n### Impact\nNo vulnerable production contracts were found.","format":"markdown","source":"ghsa"},{"lang":"es","text":"Vyper es un lenguaje de contrato inteligente pitónico para la máquina virtual Ethereum. En las versiones 0.3.10 y anteriores, el uso de la función incorporada `sqrt` puede generar una vulnerabilidad de doble evaluación cuando el argumento tiene efectos secundarios. Se puede ver que la función `build_IR` del incorporado `sqrt` no almacena en caché el argumento en la pila. Como tal, se puede evaluar varias veces (en lugar de recuperar el valor de la pila). No se encontraron contratos de producción vulnerables. Además, la doble evaluación de los efectos secundarios debería poder descubrirse fácilmente en las pruebas de los clientes. Como tal, el impacto es bajo. Al momento de la publicación, no hay versiones fijas disponibles.","source":"nvd"}],"published":"2024-04-25T17:53:01.072Z","modified":"2026-06-17T07:30:01.800Z","severity":{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},"severities":[{"scorer":"GitHub_M","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"},{"scorer":"PyPA Advisory Database","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:L/A:N","score":5.3,"rating":"MEDIUM"}],"cwes":["CWE-95"],"affected":[{"ranges":[{"version":"<= 0.3.10","status":"affected"}],"vendor":"vyperlang","product":"vyper","source":"cvelist"},{"ranges":[{"version":"*","status":"affected"}],"vendor":"vyperlang","product":"vyper","cpe":"cpe:2.3:a:vyperlang:vyper:*:*:*:*:*:*:*:*","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.4.0"}],"ecosystem":"PyPI","package":"vyper","purl":"pkg:pypi/vyper","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.4.0"}],"vendor":"vyperlang","product":"vyper","cpe":"cpe:2.3:a:vyperlang:vyper:*:*:*:*:*:python:*:*","source":"nvd"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.4.0"}],"ecosystem":"PyPI","package":"vyper","purl":"pkg:pypi/vyper","source":"pysec"}],"references":[{"url":"https://github.com/vyperlang/vyper/security/advisories/GHSA-5jrj-52x8-m64h","tags":["advisory","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2024-32649","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/vyperlang/vyper/pull/2914","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/vyper/PYSEC-2024-209.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/vyperlang/vyper","tags":["package"],"sources":["ghsa"]},{"url":"https://github.com/advisories/GHSA-5jrj-52x8-m64h","tags":["advisory"],"sources":["pysec"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"poc","automatable":"yes","technicalImpact":"partial","date":"2024-04-29T12:16:42.844Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2024-32649","url":"https://www.cve.org/CVERecord?id=CVE-2024-32649","licence":"CVE Terms of Use","modified":"2024-08-02T02:13:40.270Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-5jrj-52x8-m64h","url":"https://github.com/advisories/GHSA-5jrj-52x8-m64h","licence":"CC-BY-4.0","modified":"2026-06-10T17:14:19.090Z"},{"source":"nvd","name":"NVD","id":"CVE-2024-32649","url":"https://nvd.nist.gov/vuln/detail/CVE-2024-32649","licence":"Public domain","modified":"2026-06-17T07:30:01.800Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2024-209","url":"https://osv.dev/vulnerability/PYSEC-2024-209","licence":"CC-BY-4.0","modified":"2026-06-10T17:14:19.150Z"}],"updatedAt":"2026-11-25T22:58:39.607Z","epss":{"score":0.00573,"percentile":0.41327,"date":"2026-11-30T12:00:22.000Z"}}