{"id":"CVE-2023-32058","aliases":["CVE-2023-32058","GHSA-6r8q-pfpv-7cgj","PYSEC-2023-78"],"related":[],"kind":"vulnerability","state":"published","title":"Vyper vulnerable to integer overflow in loop","summary":"Vyper is a Pythonic smart contract language for the Ethereum virtual machine. Prior to version 0.3.8, due to missing overflow check for loop variables, by assigning the iterator of a loop to a variable, it is possible to overflow the type of the latter. The issue seems to happen only in loops of type `for i in range(a, a + N)` as in loops of type `for i in range(start, stop)` and `for i in range(stop)`, the compiler is able to raise a `TypeMismatch` when trying to overflow the variable. The problem has been patched in version 0.3.8.","summarySource":"cvelist","descriptions":[{"lang":"en","text":"Vyper is a Pythonic smart contract language for the Ethereum virtual machine. Prior to version 0.3.8, due to missing overflow check for loop variables, by assigning the iterator of a loop to a variable, it is possible to overflow the type of the latter. The issue seems to happen only in loops of type `for i in range(a, a + N)` as in loops of type `for i in range(start, stop)` and `for i in range(stop)`, the compiler is able to raise a `TypeMismatch` when trying to overflow the variable. The problem has been patched in version 0.3.8.","source":"cvelist"},{"lang":"en","text":"### Impact\n\nDue to missing overflow check for loop variables, by assigning the iterator of a loop to a variable, it is possible to overflow the type of the latter.\n\nIn the following example, calling `test` returns `354`, meaning that the variable `a` did store `354` a value out of bound for the type `uint8`.\n\n```Vyper\n@external\ndef test() -> uint16:\n    x:uint8 = 255\n    a:uint8 = 0\n    for i in range(x, x+100):\n        a = i\n    return convert(a,uint16)\n```\n\nThe issue seems to happen only in loops of type `for i in range(a, a + N)` as in loops of type `for i in range(start, stop)` and `for i in range(stop)`, the compiler is able to raise a `TypeMismatch` when trying to overflow the variable.\n\nthanks to @trocher for reporting\n\n### Patches\n\npatched in 3de1415ee77a9244eb04bdb695e249d3ec9ed868\n\n### Workarounds","format":"markdown","source":"ghsa"}],"published":"2023-05-11T20:55:35.195Z","modified":"2026-09-10T03:50:01.254Z","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:N/A:H","score":7.5,"rating":"HIGH"},"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:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"CISA-ADP","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"},{"scorer":"GitHub","scheme":"CVSS:4.0","vector":"CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:N/VI:N/VA:H/SC:N/SI:N/SA:N","rating":"HIGH"},{"scorer":"NVD","scheme":"CVSS:3.1","vector":"CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:H","score":7.5,"rating":"HIGH"}],"cwes":["CWE-190"],"affected":[{"ranges":[{"version":"< 0.3.8","status":"affected"}],"vendor":"vyperlang","product":"vyper","source":"cvelist"},{"ranges":[{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.3.8"}],"ecosystem":"PyPI","package":"vyper","purl":"pkg:pypi/vyper","source":"ghsa"},{"ranges":[{"status":"affected","fixed":"0.3.8"}],"vendor":"vyperlang","product":"vyper","cpe":"cpe:2.3:a:vyperlang:vyper:*:*:*:*:*:*:*:*","source":"nvd"},{"ranges":[{"type":"git","introduced":"0","status":"affected","fixed":"3de1415ee77a9244eb04bdb695e249d3ec9ed868"},{"type":"ecosystem","introduced":"0","status":"affected","fixed":"0.3.8"}],"ecosystem":"PyPI","package":"vyper","purl":"pkg:pypi/vyper","repo":"https://github.com/vyperlang/vyper","source":"pysec"}],"references":[{"url":"https://github.com/vyperlang/vyper/security/advisories/GHSA-6r8q-pfpv-7cgj","tags":["advisory","exploit","vendor-advisory","web","x-refsource-confirm","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://github.com/vyperlang/vyper/commit/3de1415ee77a9244eb04bdb695e249d3ec9ed868","tags":["fix","patch","web","x-refsource-misc","x-transferred"],"sources":["cvelist","ghsa","nvd","pysec"]},{"url":"https://nvd.nist.gov/vuln/detail/CVE-2023-32058","tags":["advisory"],"sources":["ghsa"]},{"url":"https://github.com/pypa/advisory-database/tree/main/vulns/vyper/PYSEC-2023-78.yaml","tags":["web"],"sources":["ghsa"]},{"url":"https://github.com/vyperlang/vyper","tags":["package"],"sources":["ghsa"]}],"credits":[],"assigner":"GitHub_M","ssvc":{"scorer":"CISA-ADP","exploitation":"none","automatable":"yes","technicalImpact":"partial","date":"2025-01-24T15:56:37.269Z"},"sources":[{"source":"cvelist","name":"CVE List","id":"CVE-2023-32058","url":"https://www.cve.org/CVERecord?id=CVE-2023-32058","licence":"CVE Terms of Use","modified":"2025-01-24T15:57:47.118Z"},{"source":"ghsa","name":"GitHub Advisory Database","id":"GHSA-6r8q-pfpv-7cgj","url":"https://github.com/advisories/GHSA-6r8q-pfpv-7cgj","licence":"CC-BY-4.0","modified":"2026-09-10T03:50:01.254Z"},{"source":"nvd","name":"NVD","id":"CVE-2023-32058","url":"https://nvd.nist.gov/vuln/detail/CVE-2023-32058","licence":"Public domain","modified":"2026-06-17T05:57:59.007Z"},{"source":"pysec","name":"PyPA Advisory Database","id":"PYSEC-2023-78","url":"https://osv.dev/vulnerability/PYSEC-2023-78","licence":"CC-BY-4.0","modified":"2023-11-08T04:12:32.824Z"}],"updatedAt":"2026-11-25T22:58:24.109Z","epss":{"score":0.00913,"percentile":0.61134,"date":"2026-12-01T12:00:22.000Z"}}