code-423n4 / 2022-07-swivel-findings

0 stars 1 forks source link

initiating a position may revert for Compound token #177

Closed code423n4 closed 2 years ago

code423n4 commented 2 years ago

Lines of code

https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L134 https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L173 https://github.com/code-423n4/2022-07-swivel/blob/main/Swivel/Swivel.sol#L709

Vulnerability details

Impact

When calling calling Swivel.initiate(), the functions initiateVaultFillingZcTokenInitiate() and initiateZcTokenFillingVaultInitiate() both have an check the return value of deposit() . In the deposit() call, if the p enum is Compound protocol, then most times, the return value might be false when ICompound(c).mint(a) returns uint256 value greater than 0. With the return value being false, initiateVaultFillingZcTokenInitiate() and initiateVaultFillingZcTokenInitiate() would revert with error 'deposit failed', making the user unable to initiate a position on Compound token.

Proof of Concept

  1. Alice calls initiate() with the inputs which include compound protocol in the order.
  2. from initiate() , the initiateVaultFillingZcTokenInitiate() is called,
  3. deposit() call is attempted in line 134
  4. if (p == uint8(Protocols.Compound)) is satisfied, and ICompound(c).mint(a) returns amount greater than zero
  5. bool false is returned back to line 134, and initiateVaultFillingZcTokenInitiate() reverts with Exception error 6 - deposit failed.
  6. Alice is unable to initiate the position on order with compound protocol

Tools Used

Manual review

Recommended Mitigation Steps

The if-statement may need to be changed appropriately.

JTraversa commented 2 years ago

Duplicate of #181

bghughes commented 2 years ago

Duplicate of #181