Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Potential Overflow Problem within NamecheapPushDomainVerifier #423

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

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