9.1critical
Vyper incorrectly allocated named re-entrancy locks
- Severity
- 9.1critical CVSS:4.0 by GitHub_M
- Exploit likelihood
- 0.82% (higher than 58% of CVEs; EPSS, by FIRST)
- Published
- Last changed
- Assigned by
- GitHub_M
- Also known as
- GHSA-5824-cm3x-3c38PYSEC-2023-142
Description
Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine (EVM). In versions 0.2.15, 0.2.16 and 0.3.0, named re-entrancy locks are allocated incorrectly. Each function using a named re-entrancy lock gets a unique lock regardless of the key, allowing cross-function re-entrancy in contracts compiled with the susceptible versions. A specific set of conditions is required to result in misbehavior of affected contracts, specifically: a `.vy` contract compiled with `vyper` versions `0.2.15`, `0.2.16`, or `0.3.0`; a primary function that utilizes the `@nonreentrant` decorator with a specific `key` and does not strictly follow the check-effects-interaction pattern (i.e. contains an external call to an untrusted party before storage updates); and a secondary function that utilizes the same `key` and would be affected by the improper state caused by the primary function. Version 0.3.1 contains a fix for this issue.
Affected
| Product or package | Versions | Reported by |
|---|---|---|
| vyperlang vyper | = 0.2.15, = 0.2.16, = 0.3.0, 0.2.15, 0.2.16, 0.3.0 | CVE List, NVD |
| vyper (PyPI) | from 0.2.15 before 0.3.1, all versions | GitHub Advisory Database, PyPA Advisory Database |
All scores
| GitHub_M | 9.1critical CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:H/SA:H/E:A |
| GitHub | 8.7critical CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:C/C:N/I:H/A:H |
| GitHub | critical CVSS:4.0 | CVSS:4.0/AV:N/AC:L/AT:P/PR:N/UI:N/VC:N/VI:H/VA:H/SC:N/SI:H/SA:H/E:A |
| NVD | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N |
| PyPA Advisory Database | 5.9medium CVSS:3.1 | CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:N/I:H/A:N |
Classification
SSVC (CISA-ADP): exploitation none, automatable no, technical impact partial.
What each source says
CVE List
Vyper is a Pythonic Smart Contract Language for the Ethereum Virtual Machine (EVM). In versions 0.2.15, 0.2.16 and 0.3.0, named re-entrancy locks are allocated incorrectly. Each function using a named re-entrancy lock gets a unique lock regardless of the key, allowing cross-function re-entrancy in contracts compiled with the susceptible versions. A specific set of conditions is required to result in misbehavior of affected contracts, specifically: a `.vy` contract compiled with `vyper` versions `0.2.15`, `0.2.16`, or `0.3.0`; a primary function that utilizes the `@nonreentrant` decorator with a specific `key` and does not strictly follow the check-effects-interaction pattern (i.e. contains an external call to an untrusted party before storage updates); and a secondary function that utilizes the same `key` and would be affected by the improper state caused by the primary function. Version 0.3.1 contains a fix for this issue.
GitHub Advisory Database
Impact
In versions 0.2.15, 0.2.16 and 0.3.0, named re-entrancy locks are allocated incorrectly. Each function using a named re-entrancy lock gets a unique lock regardless of the key, allowing cross-function re-entrancy in contracts compiled with the susceptible versions. A specific set of conditions is required to result in misbehavior of affected contracts, specifically:
- A
.vycontract compiled with either of the followingvyperversions:0.2.15,0.2.16,0.3.0 - A primary function that utilizes the
@nonreentrantdecorator with a specifickeyand does not strictly follow the check-effects-interaction pattern (i.e. contains an external call to an untrusted party before storage updates) - A secondary function that utilizes the same
keyand would be affected by the improper state caused by the primary function
Patches
https://github.com/vyperlang/vyper/pull/2439, https://github.com/vyperlang/vyper/pull/2514
Workarounds
Upgrade to 0.3.1 or higher
References
Technical post-mortem report: https://hackmd.io/@vyperlang/HJUgNMhs2
PyPA Advisory Database
Vyer is a Pythonic Smart Contract Language for the Ethereum Virtual Machine (EVM). In versions 0.2.15, 0.2.16 and 0.3.0, named re-entrancy locks are allocated incorrectly. Each function using a named re-entrancy lock gets a unique lock regardless of the key, allowing cross-function re-entrancy in contracts compiled with the susceptible versions. A specific set of conditions is required to result in misbehavior of affected contracts, specifically: a .vy contract compiled with vyper versions 0.2.15, 0.2.16, or 0.3.0; a primary function that utilizes the @nonreentrant decorator with a specific key and does not strictly follow the check-effects-interaction pattern (i.e. contains an external call to an untrusted party before storage updates); and a secondary function that utilizes the same key and would be affected by the improper state caused by the primary function. Version 0.3.1 contains a fix for this issue.
References
| https://github.com/vyperlang/vyper/security/advisories/GHSA-5824-cm3x-3c38 | advisory, exploit, patch, third-party-advisory, web | |
| https://github.com/vyperlang/vyper/pull/2439 | fix, patch, web | |
| https://github.com/vyperlang/vyper/pull/2514 | fix, patch, web | |
| https://hackmd.io/@LlamaRisk/BJzSKHNjn | exploit, third-party-advisory, web | |
| https://hackmd.io/@vyperlang/HJUgNMhs2 | exploit, third-party-advisory, web | |
| https://nvd.nist.gov/vuln/detail/CVE-2023-39363 | advisory | |
| https://github.com/pypa/advisory-database/tree/main/vulns/vyper/PYSEC-2023-142.yaml | web | |
| https://github.com/vyperlang/vyper | package | |
Sources
| Source | Record | Licence |
|---|---|---|
| CVE List | CVE-2023-39363 changed 2024-10-11 | CVE Terms of Use |
| GitHub Advisory Database | GHSA-5824-cm3x-3c38 changed 2026-09-10 | CC-BY-4.0 |
| NVD | CVE-2023-39363 changed 2026-06-17 | Public domain |
| PyPA Advisory Database | PYSEC-2023-142 changed 2025-10-09 | CC-BY-4.0 |