Open code423n4 opened 3 years ago
This is a re-entrancy finding.
There is no denying that the code is vulnerable to re-entrancy
The warden identified the way to exploit re-entrancy by using a malicious bounty token.
I think the finding is valid and the warden has shown how to run re-entrnacy.
That said the POC the warden shows requires calling publishNewIndex
which is a onlyPublisher
function.
This exploit would be contingent on the publisher rugging the basket.
The code is:
Despite the fact that the POC is flawed, I believe this finding highlights a different vector for re-entrancy (bounty token transfers) as such I agree with a high severity
Handle
kenzo
Vulnerability details
The settleAuction() function calls withdrawBounty() before setting auctionOngoing = false, thereby allowing reentrancy.
Impact
A malicious publisher can bypass the index timelock mechanism and publish new index which the basket's users won't have time to respond to. At worst case, this means setting weights that allow the publisher to withdraw all the basket's underlying funds for himself, under the guise of a valid new index.
Proof of Concept
POC exploit: Password to both files: "exploit". AttackPublisher.sol , to be put under contracts/contracts/Exploit: https://pastebin.com/efHZjstS ExploitPublisher.test.js , to be put under contracts/test: https://pastebin.com/knBtcWkk
Tools Used
Manual analysis, hardhat.
Recommended Mitigation Steps
In settleAuction(), move basketAsERC20.transfer() and withdrawBounty() to the end of the function, conforming with Checks Effects Interactions pattern.