Closed code423n4 closed 1 year ago
We believe there is no issue here, but we will write a test to confirm. I think the relevant detail is that uint256 sellBal = sell.balanceOf(address(this));
. This variable will contain the initial donated balance that did not go out to EasyAuction during init()
.
0xean marked the issue as unsatisfactory: Insufficient proof
Lines of code
https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/p1/Broker.sol#L187-L209 https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/plugins/trading/GnosisTrade.sol#L87
Vulnerability details
Impact
GnosisTrade contract can be frontrunned in order to make it report violation and block broker. This will stop broker from creating another traders.
Proof of Concept
When
BackingManager
is rebalancing, then it can open trade, which can be gnosis trade auction.In this case new
GnosisTrade
is created using create opcode. Note, it's possible to calculate address of next created contract by contract. Attacker needs to know address of creator and his nonce. So it's not hard for attacker to frontrunBackingManager.rebalance
which will createGnosisTrade
auction. What attacker will do is top up that address with some small amount ofreq.sell
token.When
GnosisTrade
is initiated, then his balance is stored toinitBal
variable. And alsoworstCasePrice
is calculated, which isreq.minBuyAmount/req.sellAmount
. This variable is used insidesettle
function to check that gnosis executed auction with good price. https://github.com/reserve-protocol/protocol/blob/c4ec2473bbcb4831d62af55d275368e73e16b984/contracts/plugins/trading/GnosisTrade.sol#L162-L205You can see, that
soldAmt = initBal - sellBal
is used to determine how much sell tokens were sold. And then thissoldAmt
is used to check the price.So the purpose of attacker is to inflate
soldAmt
variable in order to make clearing price less thanworstCasePrice
and initiatereportViolation
call and stop broker.Tools Used
VsCode
Recommended Mitigation Steps
Maybe you need to store
initBal = req.sellAmount
in theinit
. Then no matter if attacker donated smth to the contract, clearing price should be correct.Assessed type
Error