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
Alice calls initiate() with the inputs which include compound protocol in the order.
from initiate() , the initiateVaultFillingZcTokenInitiate() is called,
deposit() call is attempted in line 134
if (p == uint8(Protocols.Compound)) is satisfied, and ICompound(c).mint(a) returns amount greater than zero
bool false is returned back to line 134, and initiateVaultFillingZcTokenInitiate() reverts with Exception error 6 - deposit failed.
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.
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
if (p == uint8(Protocols.Compound))
is satisfied, andICompound(c).mint(a)
returns amount greater than zerodeposit failed
.Tools Used
Manual review
Recommended Mitigation Steps
The if-statement may need to be changed appropriately.