code-423n4 / 2023-02-ethos-findings

8 stars 6 forks source link

Potential Denial-of-Service in Strategy #774

Open code423n4 opened 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/ReaperStrategyGranarySupplyOnly.sol#L156-L171 https://github.com/code-423n4/2023-02-ethos/blob/main/Ethos-Vault/contracts/mixins/VeloSolidMixin.sol#L32

Vulnerability details

Impact

The swap steps that are specified within the reaper strategy's ReaperStrategyGranarySupplyOnly::setHarvestSteps call are not sanitized as having a valid veloSwapPath defined, thereby permitting a swap step to be defined without a path to execute it and thus causing all ReaperStrategyGranarySupplyOnly::_harvestCore invocations to fail until a swap has been defined due to an arithmetic underflow.

This can be taken advantage of when a ReaperBaseStrategyv4::harvest transaction has been submitted but not executed yet to cause a DoS deliberately or it can result from misuse or incorrect coordination between transactors.

Proof of Concept

To illustrate the issue, the following contract has been devised:

contract InexistentSwapPath {
    /**
     * Simplified Assumptions:
     *
     * - Contract is at least `ADMIN` of `ReaperStrategyGranarySupplyOnly`
     */
    function demonstrate(IStrategy strategy, IERC20 swappableToken) external {
        // Flaw: Setup a swap step w/o a swap path
        address[2][] memory steps = new address[2](1);
        address[2] memory pair = [swappableToken, address(strategy.gWant())];
        steps.push(pair);
        strategy.setHarvestSteps(steps);

        // Step: Execute a harvest call 
        try strategy.harvest() {
            revert("Unreachable");
        } catch (bytes memory e) {
            revert("ISSUE: Harvest Failed");
        }
    }
}

Tools Used

Manual review.

Recommended Mitigation Steps

The ReaperStrategyGranarySupplyOnly::setHarvestSteps function should mandate that a valid veloSwapPath has already been defined for the swap steps being introduced to avoid unavailability of the protocol.

c4-judge commented 1 year ago

trust1995 changed the severity to QA (Quality Assurance)

trust1995 commented 1 year ago

Does not meet the impact requirements of medium severity.

c4-judge commented 1 year ago

trust1995 marked the issue as grade-b

c4-sponsor commented 1 year ago

0xBebis marked the issue as sponsor disputed

0xBebis commented 1 year ago

sanitizing swap paths on chain would not be very sensible