The vulnerability is a denial-of-service in go-ethereum caused by processing a specially crafted p2p message. The analysis of the patch commit 895a8597cb16c02203e38707ed2d1da5c500fe60 reveals that the vulnerability lies in the cryptographic library secp256k1 used for handling elliptic curve operations.
The core of the issue is improper input validation of elliptic curve points. When a node receives a p2p message containing cryptographic data like a public key or a signature, it needs to deserialize and validate the associated elliptic curve points. The patch shows that the functions responsible for this validation were missing crucial checks.
Specifically, the coordinates of the points were not checked to be within the valid range of the curve's field. An attacker could craft a message with a point having coordinates larger than the curve's prime modulus. When the vulnerable node attempts to perform cryptographic operations on this invalid point, it can lead to a panic or crash in the underlying C or Go code, causing a denial of service.
The patch addresses this by adding checks in three places:
- In
crypto/secp256k1/curve.go, the IsOnCurve method for BitCurve now validates the coordinates against the curve's prime P.
- In the C-level code
crypto/secp256k1/ext.h, the secp256k1_ext_scalar_mul function now checks the return value of secp256k1_fe_set_b32_limit, which fails for out-of-range values.
- In
crypto/signature_nocgo.go (for builds without cgo), a new IsOnCurve method is added for btCurve to perform the same coordinate validation.
Any p2p message that triggers public key recovery or signature verification could be a vector for this attack. The identified functions are directly involved in the validation process that was initially flawed. During exploitation, a profiler would likely show these functions being called with the malicious input just before the crash.