Extending a domain’s expiration even after the grace period impacts domain buyers
The domain name service allowed anyone to extend a domain's expiration even after the grace period had ended, which should not be possible. An attacker or the previous owner could front-run a new buyer's registration transaction, causing the buyer's transaction to revert and preventing them from acquiring the domain.
Submitted by p4y4b13
Finding description and impact
The name_service.move module allows users to register domain names. If anyone wants to register an already purchased domain, they can only do so once the expiration_date + grace_period for that domain has passed. The name_service.move module allows anyone to call extend_expiration for any domain, which is a feature (according to sponsors).
The main issue is that the extend_expiration() function allows users to extend the expiration of a domain even after the grace period has ended, which is unintended behavior.
As a result, users, multi-sig owners of the actual domain name, or attackers can frontrun and attempt to call extend_expiration() after the grace period has ended, even if other users are trying to buy the same domain name using register_domain().
This breaks a key invariant of the protocol, leading to genuine users being negatively impacted and experiencing a poor user experience.
Proof of Concept
Consider the following attack scenario:
Alicebuys the domain namevitalikfor a specific duration.- The expiration date and grace period for
Alice’s domain are completed. Bobobserves thatAlice’s domainvitalikhas passed itsexpiration_date + grace_period. So,Bobcallsregister_domainto acquire thevitalikdomain name.- At the same time,
Alicecallsextend_expirationfor the domain namevitalik. - Since
Alicepays a higher gas fee, her transaction is picked and executed first. - As a result,
Alicesuccessfully extends the expiration for her domain, andBob’s transaction reverts. - However,
Alice’s transaction should have been reverted since the grace period had already ended.
Recommended mitigation steps
To mitigate this issue, prevent the extend_expiration() function from being called for domains after the completion of expiration_date + grace_period.
public entry fun extend_expiration(
account: &signer,
domain_name: String,
duration: u64,
) acquires ModuleStore {
....
assert!(
duration >= module_store.config.min_duration,
error::invalid_argument(EMIN_DURATION),
);
let (_height, timestamp) = block::get_block_info();
let expiration_date = metadata::get_expiration_date(token);
// @audit Only allow extend_expiration before the grace period
+ assert!(
+ timestamp <= expiration_date + module_store.config.grace_period ,
+ error::invalid_argument(ECANT_EXTEND_EXPIRATION),
+ );
....
}
andrew (Initia) confirmed and commented:
Thank you for reporting. It is fixed on this commit.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The `extend_expiration` function lacked a check that the current time is within the expiration date plus grace period, so it could be called at any time.
Impact
A previous owner or attacker could block a legitimate buyer from registering an expired domain, breaking a protocol invariant and causing a poor user experience.
What the attacker needed
A domain that has passed expiration plus grace period; ability to submit a transaction with higher gas
The fix
The `extend_expiration` function was fixed to only allow extension before the grace period ends.
How it was found
- Alice buys a domain for a set duration.
- The domain's expiration date and grace period pass.
- Bob calls register_domain to acquire the now-available domain.
- Alice calls extend_expiration for the same domain with a higher gas fee.
- Alice's transaction executes first, extending the domain and causing Bob's registration to revert.
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.
A domain name service lets people register names and renew them. Normally, after a name expires and a short grace period passes, anyone can buy it. The bug meant the old owner could still renew the name at the last moment, even after that grace period, and if they paid a higher fee their renewal would be processed first, so the new buyer's purchase would fail.
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.