Skip to content

Conversation

@Koukyosyumei
Copy link

@Koukyosyumei Koukyosyumei commented Jan 11, 2025

Overview

NamecheapPushDomainVerifier template currently validates fromEmailIndex < emailHeaderLength, namecheapBuyerIdIndex < emailBodyLength, and namecheapDomainNameIndex < emailBodyLength with LessThan template.

However, the LessThan(N) template has a known over-flow issue: If the bit-length of the input exceeds $N$, LessThan may produce unintended results. For example, suppose maxHeadersLength = 768, emailHeaderLength = 512, and fromEmailIndex = 21888242871839275222246405745257275088548364400416034343698204186575808495588. In this case, the output of LessThan(log2Ceil(maxHeadersLength))([fromEmailIndex, emailHeaderLength]) is 1, meaning that this malicious input satisfies the constraints of NamecheapPushDomainVerifier.

Fix

To address this problem, I implemented a check on the bit-length of inputs with Num2Bits from circomlib.

Reference

For more details on this vulnerability, refer to:

Note

FromRegex, BodyHashRegex, and VenmoTimestampRegex also contains LessThan without bit-length check. However, this seems fine since they are used for utf-8 body.

@Koukyosyumei Koukyosyumei marked this pull request as draft January 11, 2025 23:42
@Koukyosyumei Koukyosyumei marked this pull request as ready for review January 12, 2025 12:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant