Currently auctioned NFTs can be transferred to a different address in a specific edge case
An NFT being auctioned could be transferred to another address by the initial bidder under specific conditions, allowing them to withdraw collateral that was only partially funded. This could lead to theft of ETH from the protocol.
Source: https://github.com/sherlock-audit/2024-02-radicalxchange-judging/issues/33
Found by
zzykxx
Summary
Currently auctioned NFTs can be transferred to a different address in a specific edge case, leading to theft of funds.
Vulnerability Detail
The protocol assumes that an NFT cannot change owner while it's being auctioned, this is generally the case but there is an exception, an NFT can change owner via mintToken() while an auction is ongoing when all the following conditions apply:
- An NFT is added to the collection without being minted (ie.
toset toaddress(0)). - The NFT is added to the collection with the parameter
tokenInitialPeriodStartTime[]set to a timestamp lower thanl.initialPeriodStartTimebut bigger than0(ie.0 < tokenInitialPeriodStartTime[] < l.initialPeriodStartTime). - The current
block.timestampis in-betweentokenInitialPeriodStartTime[]andl.initialPeriodStartTime.
A malicious initialBidder can take advantage of this by:
- Bidding on the new added NFT via placeBid().
- Calling mintToken() to transfer the NFT to a different address he controls.
- Closing the auction via closeAuction()
At point 3., because the NFT owner changed, the winning bidder (ie. initialBidder) is not the current NFT owner anymore. This will trigger the following line of code:
l.availableCollateral[oldBidder] += l.highestBids[tokenId][currentAuctionRound].bidAmount;
Which increases the availableCollateral of the oldBidder (ie. the address that owns the NFT after point 2.) by bidAmount of the highest bid. But because at the moment the highest bid was placed initialBidder was also the NFT owner, he only needed to transfer the ETH fee to the protocol instead of the whole bid amount.
The initialBidder is now able to extract ETH from the protocol via the address used in point 2. by calling withdrawCollateral() while also retaining the NFT license.
Impact
Malicious initial bidder can potentially steal ETH from the protocol in an edge case. If the ADD_TOKEN_TO_COLLECTION_ROLE is also malicious, it's possible to drain the protocol.
Code Snippet
Tool used
Manual Review
Recommendation
Don't allow tokenInitialPeriodStartTime[] to be set at a timestamp beforel.initialPeriodStartTime.
Discussion
zzykxx
Escalate
Not a duplicate of #9. This issue describes a correct edge case in which a currently auctioned NFT can be transferred.
sherlock-admin2
Escalate
Not a duplicate of #9. This issue describes a correct edge case in which a currently auctioned NFT can be transferred.
You've created a valid escalation!
To remove the escalation from consideration: Delete your comment.
You may delete or edit your escalation comment anytime before the 48-hour escalation window closes. After that, the escalation becomes final.
Hash01011122
Even I considered it unique medium as it was edge case but sponsors viewed it as duplicate of #9 as it has same root cause @gravenp anything which you would like to add?
St4rgarden
Not a duplicate because #9 is a non-issue.
gravenp
@Hash01011122 after @St4rgarden took another look at #33 and #9, we determined that these should NOT be duplicates. I was mistaken. Sorry. We've marked #9 invalid and @St4rgarden is working on a hardhat test to reproduce this one.
Czar102
Planning to consider this a separate issue.
@zzykxx why do you think High severity is appropriate? I'd like to know more about the likelihood of this exploit.
zzykxx
Planning to consider this a separate issue.
@zzykxx why do you think High severity is appropriate? I'd like to know more about the likelihood of this exploit.
I submitted as high severity because a combination of malicious initialBidder and ADD_TOKEN_TO_COLLECTION_ROLE can steal funds currently in the contract.
The sponsor is stating somewhere else that initialBidder is a trusted role, which would make the issue invalid.
However, the fact that the initalBidder or ADD_TOKEN_TO_COLLECTION_ROLE is a trusted role was not mentioned anywhere during the time of the audit.
One argument on why initialBidder should be considered trusted is that it has the power to mint NFTs (and to mint them to himself), and this power is given to them by the owner which is trusted according to the README. I'm not sure this implies that the initialBidder (and ADD_TOKEN_TO_COLLECTION_ROLE) are trusted to not steal funds in the contract. To me having the power of minting/wrapping NFTs (which will then be auctioned) and the power to steal funds in the contract are two different levels of trust.
This being said, I'll leave this to you and the judges as the decision on the severity mainly revolves around judging technicalities. Feel free to tag me if you need more information.
gravenp
We agree that this is valid. I'm not steeped in the judging technicalities on severity either.
To attempt to clarify a bit, we're not trying to imply elsewhere that the address in initialBidder is trusted (just that this field is by default set to the artist, who is trusted, at initialization/the first auction). The ADD_TOKEN_TO_COLLECTION_ROLE and other admin roles are also trusted with their defined scope, but stealing funds auction funds wouldn't be in that role scope. I don't know where that nets out on likelihood so am ok ceding that determination to the judges and their experience with the contest rules.
Czar102
This issue is certainly valid, and I would place it on the borderline Med/High, but I think Medium is appropriate given that not everyone is able to exploit this vulnerability, only few whitelisted parties.
Evert0x
Planning to remove duplication state and assign Medium severity
Evert0x
Result: Medium Unique
sherlock-admin3
Escalations have been resolved successfully!
Escalation status:
- zzykxx: accepted
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/RadicalxChange/pco-art/pull/11
zzykxx
The issue has been fixed by preventing the auction start time of a newly added NFT to be in the past.
sherlock-admin2
The Lead Senior Watson signed off on the fix.
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
Likely the protocol allows an NFT's initial period start time to be set in the past, enabling minting and ownership transfer during an ongoing auction, which breaks the assumption that the NFT owner cannot change.
Impact
A malicious initial bidder could potentially steal ETH from the protocol in this edge case; if the ADD_TOKEN_TO_COLLECTION_ROLE is also malicious, it's possible to drain the protocol.
What the attacker needed
Malicious initialBidder; malicious ADD_TOKEN_TO_COLLECTION_ROLE; NFT added with past start time
The fix
The issue was fixed by preventing the auction start time of a newly added NFT from being set in the past.
How it was found
- Add an NFT to the collection without minting it (to address(0)) and set its tokenInitialPeriodStartTime to a timestamp between 0 and the license's initialPeriodStartTime, with the current block timestamp in that range.
- As the initial bidder, place a bid on the newly added NFT.
- Call mintToken() to transfer the NFT to a different address controlled by the attacker.
- Close the auction, which credits the full bid amount as available collateral to the new owner (the attacker's address).
- Withdraw the collateral from the attacker's address, retaining the NFT license.
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.
In an auction, the person who places the first bid (the initial bidder) is often the current owner of the NFT. They only need to pay a small fee instead of the full bid amount because the system assumes they already own the NFT. If they can transfer the NFT to another address they control during the auction, the system still credits the full bid amount as collateral to that new address, which they can then withdraw, effectively stealing funds.
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.