Users’ ability to nuke will be DoSed for three days after putting NFTs up for sale and canceling the sale
Submitted by 0rpse, also found by 0xb0k0, smbv-1923, Abhan, mansa11, and anonymousjoe
Users will not be able to nuke their NFTs for three days after canceling sale of their NFTs.
Proof of Concept
When a user puts up their NFT for sale and cancels their NFT sale, the NFT is transferred to the EntityTrading contract and back to the owner. This transfer triggers the _beforeTokenTransfer function, which resets the lastTokenTransferredTimestamp variable.
function _beforeTokenTransfer(
address from,
address to,
uint256 firstTokenId,
uint256 batchSize
) internal virtual override {
super._beforeTokenTransfer(from, to, firstTokenId, batchSize);
uint listedId = entityForgingContract.getListedTokenIds(firstTokenId);
/// @dev don't update the transferred timestamp if from and to address are same
if (from != to) {
lastTokenTransferredTimestamp[firstTokenId] = block.timestamp;
}
if (listedId > 0) {
IEntityForging.Listing memory listing = entityForgingContract.getListings(
listedId
);
if (
listing.tokenId == firstTokenId &&
listing.account == from &&
listing.isListed
) {
entityForgingContract.cancelListingForForging(firstTokenId);
}
}
require(!paused(), 'ERC721Pausable: token transfer while paused');
}
This timestamp is later checked by the nuke function to verify if the owner has held the token for at least three days, allowing them to nuke the NFT for rewards.
The issue arises because the transfers to and from the EntityTrading contract, triggered by the sale listing and cancellation, reset the lastTokenTransferredTimestamp. As a result, even though the owner still possesses the token, the reset timestamp prevents them from nuking the NFT for another three days, denying them the opportunity to receive rewards.
Recommended Mitigation Steps
Add necessary checks to _beforeTokenTransfer so that:
- If a transfer is happening to EntityTrading contract.
- If a transfer is happening from EntityTrading to sale’s original listing account
lastTokenTransferredTimestampis not reset.
Assessed type
DoS
Koolex (judge) decreased severity to Low
This issue effectively locks users out of accessing the nuke functionality for three days after canceling a sale, which will be unexpected and detrimental, especially if users intended to use the nuke feature shortly after the cancellation. Given that the rewards are tied to the NFT’s attributes and the state of the nuke fund, a delay could mean the difference between a lucrative transaction and a missed opportunity.
The nuking function is a key part of the utility and value proposition of the NFT. By introducing an unintended delay through the sale cancellation process, the contract effectively diminishes the NFT’s usability and could potentially harm the user’s financial interests. This is not just a minor inconvenience; it can materially impact the user’s ability to interact with their assets in a way that is consistent with their expectations and strategic planning.
Given these factors, I think the severity should be Medium.
This seems to be a design choice. Otherwise, the fix can be exploited to the locking duration.
@Koolex- When I talked to the sponsors about the issue, they answered that this is just something that people will have to accept because there is no way to stop this without ruining the maturity period mitigation, I don’t think it is a design choice but a flaw.
Otherwise, the fix can be exploited to the locking duration.
I don’t understand how the fix can be exploited;
lastTokenTransferredTimestampis not going to be updated only when a transfer is happening to trading contract, or from the trading contract to the original listing account. This is logically the same thing as transferring from address A to address A, which they have done here.
When I talked to the sponsors about the issue, they answered that this is just something that people will have to accept because there is no way to stop this without ruining the maturity period mitigation, I don’t think it is a design choice but a flaw.
Isn’t this a design choice since the trade-off is would be ruining the maturity period mitigation?
Does this mean if the user list and cancel twice, they have to wait 3 days again? The code seems to apply this. I can see your concern here.
Isn’t this a design choice since the trade-off is would be ruining the maturity period mitigation?
No,
_beforeTokenTransfershould simply check if a user is canceling his/her sale listing and should not update the timestamp (also when a user is listing), if any other kinds of transfers occur, timestamp update will still take place, there is no ruining of maturity period mitigation.Does this mean if the user list and cancel twice, they have to wait 3 days again? The code seems to apply this. I can see your concern here.
If I am not understanding this question please clarify. The code as it stands will block a user’s ability to nuke his NFT for three days after canceling his sale. We can easily imagine a scenario where:
- Alice puts her NFT for sale.
- After some time, Alice notices nuke-fund has gathered a lot of funds and if she nukes her NFT she will make a nice profit.
- Alice cancels the sale and tries to nuke, but at this point she will be locked out of the nuke function for 3 days because of the current implementation.
As Alice is logically the owner of her NFT throughout the sale process, these transfers should not block her ability to nuke her own NFT.
My question is, is this repetitive?
Example: Alice puts her NFT for sale, then cancels. Now she has to wait for 3 days, right? Let’s say she waits for 1 days, since nuke is not possible, she lists her NFT and then canceled. Will she wait again for 3 days?
Alice puts her NFT for sale, then cancels. Now she has to wait for 3 days, right?
Yes.
Let’s say she waits for 1 days, since nuke is not possible, she lists here NFT and then canceled. Will she wait again for 3 days?
Yes, timestamp will be updated again, and she has to wait for another 3 days from the moment of cancellation.
TForge1 (TraitForge) commented:
Yeah, I’d say this is an issue. Maybe low as it’s not detrimental, but can impact UX. We can definitely check if its just being canceled by the original owner and make sure it doesn’t lock it for 3 days. Valid, in my opinion.
After careful review, I believe this issue hits the mark of Medium severity.
Reasoning:
- The problem persists where canceling an NFT sale extends the lock period, preventing immediate nuking.
- After canceling an NFT sale, users face a dilemma: they can’t relist the NFT (as this resets the 3-day waiting period) nor can they nuke it. This restriction is harmful to the user and could negatively impact the game’s economic dynamics.
- The frequency of listing and canceling NFTs is likely high due to competitive price adjustments. This issue affects many active participants, as they’re all temporarily barred from nuking their NFTs, amplifying the overall impact.
- It appears to have a straightforward resolution that doesn’t conflict with any fundamental game design principles.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity doS bug in TraitForge. Code4rena made it public on 13 September 2024. Found in the 2024-07-traitforge audit contest (finding M-15), also found by 5 other wardens.
About DoS
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.