GHSA-rjjm-x32p-m3f7 gnark's range checker gadget allows wider inputs up to word alignment
A flaw in gnark's range checker allows inputs wider than intended, potentially affecting zero-knowledge proof integrity in dependent applications.
- Exploited in the wild
- Not known
- Login needed
- Not needed
- Attackable
- Not stated
- Victim action needed
- Not needed
- Fix
- Available
What is GHSA-rjjm-x32p-m3f7?
GHSA-rjjm-x32p-m3f7 is a vulnerability in github.com/consensys/gnark, published on 12 Nov 2023.
Official description
Impact
gnark provides a gadget in the standard library to allow optimized checking of the bitwidth of the inputs. The gadget works by constructing a fixed lookup table containing all valid entries, partitioning the input and checking that all parts are inside the lookup table. The range checker gadget did not take into account that the highest partition may be less than the width limit, allowing the inputs to be up to 16 bits wider than checked.
Range checking gadget is extensively used in field emulation. Users using any dependant gadget (ECDSA verification, proof recursion etc.) is impacted.
We consider the impact of the vulnerability being low as the number of attacker-modifiable bits is significantly smaller compared to the bit-width of scalar field modulus and it won't be possible to construct inputs which would allow to overflow the scalar field.
Patches
The issue has been patched in the stable branch of gnark.
Due to low severity of the issue no emergency release will be issued and we follow the existing release plan. Versions v0.9.2 and higher are patched.
Workarounds
We consider the issue very hard to exploit and do not recommend manual remediation. However, it is possible to perform manual bit decomposition using std/math/bits gadget.
References
Initial issue https://github.com/Consensys/gnark/issues/897
Acknowledgement
The issue was reported by @ultrainstinct30.
Which versions are affected by GHSA-rjjm-x32p-m3f7?
3 open source packages ship an affected version, including github.com/consensys/gnark.
| Package | Affected | Fixed in |
|---|---|---|
github.com/consensys/gnark Go | All versions | 0.9.2 |
github.com/consensys/gnark Go | All versions | 0.9.2 |
github.com/consensys/gnark Go | All versions | 0.9.2-0.20231110170422-f528807119e9 |
How do I fix GHSA-rjjm-x32p-m3f7?
Upgrade github.com/consensys/gnark to a fixed version for your release line: 0.9.2 or 0.9.2-0.20231110170422-f528807119e9.
Is GHSA-rjjm-x32p-m3f7 being exploited?
There is no known exploitation of GHSA-rjjm-x32p-m3f7 in the wild and no public exploit code.
Sources
Also known as GO-2023-2333.