User can bypass MAX_EXPIRATION when extend expiration
The extend_expiration function validated the duration by subtracting the old expiration date from the new one, which always equals the duration and thus never exceeds MAX_EXPIRATION. An attacker could extend a domain's expiration far beyond the intended maximum, effectively doubling it.
The issue arises because the code subtracts new_expiration_date - expiration_date for validation.
Assume a user registers a domain and the expiration_date is equal to MAX_EXPIRATION+ timestamp. Then, the user performs extend_expiration with a duration value equal to the MAX_EXPIRATION, the new_expiration_date becomes expiration_date + duration.
This leads to the following verification check passing:
Since the new_expiration_date is calculated using expiration_date+duration, the subtraction (new_expiration_date - expiration_date) will always be less than to MAX_EXPIRATION.
As a result, the update_expiration_date function updates the expiration duration to a value far greater than MAX_EXPIRATION, effectively doubling it to MAX_EXPIRATION * 2.
Actually, MAX_EXPIRATION means that you can register/extend to current time + MAX_EXPIRATION. And yes, current logic is not correct. So I updated those in this commit.
The original report as published on Code4rena, by laksmana. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
How it worked
Root cause
The validation compared the new expiration date to the old expiration date rather than to the current timestamp, so the duration check was ineffective.
Impact
A user could extend a domain's expiration to more than double the intended maximum, bypassing the MAX_EXPIRATION limit.
What the attacker needed
A registered domain; ability to call extend_expiration
The fix
The validation should compare the new expiration date to the current timestamp, ensuring it does not exceed MAX_EXPIRATION from now; this was fixed in a commit.
How it was found
Register a domain with an expiration equal to MAX_EXPIRATION plus the current timestamp.
Call extend_expiration with a duration equal to MAX_EXPIRATION.
Observe that the new expiration date is at least twice MAX_EXPIRATION.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
Generating the AI write-up for this report.
This usually takes about 30 seconds. You can read the original meanwhile; this page updates itself.
Writing the technical write-up
Writing the version for beginners
Checking every passage against the original
A smart contract lets users extend how long they own a name. It was supposed to cap the total time, but the check compared the new end date to the old end date instead of to the current time, so the cap never applied. A user could keep extending and end up with a much longer ownership than allowed.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.