Open code423n4 opened 1 year ago
thereksfour marked the issue as primary issue
~1 in 2**256 chance of this ever happening.
Arachnid marked the issue as disagree with severity
Arachnid marked the issue as sponsor confirmed
dmvt changed the severity to QA (Quality Assurance)
dmvt marked the issue as grade-b
This is so unlikely to occur that it hardly ranks. The impact is also not stated by the warden. Downgrading to QA.
dmvt marked the issue as grade-a
Lines of code
https://github.com/code-423n4/2023-04-ens/blob/45ea10bacb2a398e14d711fe28d1738271cd7640/contracts/dnssec-oracle/algorithms/EllipticCurve.sol#L137-L140
Vulnerability details
Impact
EllipticCurve.isOnCurve
returnsfalse
forx
= 0, but there are valid points ofSECP256R1
whosex
coordinate is 0. If those points are used for public key invalidateSignature
,validateSignature
will returns false for valid signatures.Proof of Concept
EllipticCurve.isOnCurve
returnsfalse
forx
= 0 orx
= p.But
SECP256R1
, which is the curve used here, has a point whosex
coordinate is 0. Let us sayy0 * y0 % p = b
, so(0, y0)
is onSECP256R1
, and(0, p - y0)
is also onSECP256R1
.These are valid points and there is no limitation about these points, so they can be used as public key, even though the probability to choose the corresponding private key is very low. For these valid public key points,
isOnCurve
will return false. In that case,validateSignature
will return false for valid signatures.I attached coded POC for
isOnCurve
, and we don't know the private key of(0, y0)
, so I skipped writing forvalidateSignature
.Tools Used
Manual Review
Recommended Mitigation Steps
We should remove validation about
x
inisOnCurve
.