Skip to content

Latest commit

 

History

History
69 lines (47 loc) · 2.71 KB

038.md

File metadata and controls

69 lines (47 loc) · 2.71 KB

Low Tangerine Cod

High

user can make protocol to not catch upside after withdraw

Summary

There is no validation for signature that user uses on withdraw for index, and msg.sender

Root Cause

In withdraw function signature and odos data passed to cds contract

    function withDraw(
        address toAddress,
        uint64 index,
        bytes memory odosAssembledData,
        bytes memory signature
    ) external payable nonReentrant whenNotPaused(IMultiSign.Functions(1)) {
        // check is _toAddress in not a zero address and isContract address
        if (toAddress == address(0) || isContract(toAddress)) revert Borrow_CantBeContractOrZeroAddress(toAddress);

-->        if (!cds.verify(odosAssembledData, signature)) revert Borrow_NotSignedByEIP712Signer();
        // Get the depositor details

Blockchian/contracts/Core_logic/borrowing.sol#L290

E.x. there are two positions. E.x.there is upside - 1 wrsETH after first withdraw and 2 wrsEth after second withdraw. Target for odos swap is TREASURY from tests. Everything goes normal user uses 1 signature for first withdrawal - 1 wrsETH exchange for 1000 udst to treasury Everything goes normal user uses second signature for second withdrawal - 2 wrsETH exchange for 2000 udst to treasury

Attacker uses first signature for second withdrawal 1 wrsETH exchange for 1000 udst, but upside left - 2 wrsETH - 1 wrsETH=1wrsETH left unaccounting. Which means some holders will not receive their stake which leads to depeging as the point of protocol to catch upside and distribute correctly

Internal pre-conditions

No response

External pre-conditions

none

Attack Path

use odos data from 1 withdrawal and use it on another withdrawal

Impact

holders will not receive their stake which leads to depeging as the point of protocol to catch upside and distribute correctly

PoC

Mitigation

index, should be included in signature validation and msg.sender so other users could not use it

    function withDraw(
        address toAddress,
        uint64 index,
        bytes memory odosAssembledData,
        bytes memory signature
    ) external payable nonReentrant whenNotPaused(IMultiSign.Functions(1)) {
        // check is _toAddress in not a zero address and isContract address
        if (toAddress == address(0) || isContract(toAddress)) revert Borrow_CantBeContractOrZeroAddress(toAddress);

-        if (!cds.verify(odosAssembledData, signature)) revert Borrow_NotSignedByEIP712Signer();
+        if (!cds.verify(odosAssembledData, signature, index, msg.sender)) revert Borrow_NotSignedByEIP712Signer();