code-423n4 / 2024-01-salty-findings

11 stars 6 forks source link

Missing Exchange Access Check in depositCollateralAndIncreaseShare Function #684

Closed c4-bot-1 closed 9 months ago

c4-bot-1 commented 9 months ago

Lines of code

https://github.com/code-423n4/2024-01-salty/blob/53516c2cdfdfacb662cdea6417c52f23c94d5b5b/src/stable/CollateralAndLiquidity.sol#L70-L76

Vulnerability details

Impact

The lack of a direct exchange access check in the depositCollateralAndIncreaseShare function may allow unauthorized wallets to execute the function, potentially leading to unintended or insecure operations. This could compromise the security and functionality of the overall system.

Proof of Concept

The depositCollateralAndIncreaseShare function allows users to deposit WBTC/WETH liquidity as collateral and increase their collateral share. Although it includes the ensureNotExpired modifier, ensuring the transaction is not expired, it lacks a direct check for exchange access. The absence of an explicit check for exchange access might pose a security risk if the function is intended to be executed only by wallets with exchange access.

function depositCollateralAndIncreaseShare(
    uint256 maxAmountWBTC,
    uint256 maxAmountWETH,
    uint256 minLiquidityReceived,
    uint256 deadline,
    bool useZapping
) external nonReentrant ensureNotExpired(deadline) returns (uint256 addedAmountWBTC, uint256 addedAmountWETH, uint256 addedLiquidity) {
    // Missing explicit check for exchange access
    // ... (function logic)
    emit CollateralDeposited(msg.sender, addedAmountWBTC, addedAmountWETH, addedLiquidity);
}

Tools Used

Manual

Recommended Mitigation Steps

It is recommended to include a check for exchange access within the depositCollateralAndIncreaseShare function. This can be achieved by adding an access control modifier or by integrating a mechanism to verify the calling wallet's permissions before allowing the execution of the function.

Assessed type

Access Control

c4-judge commented 9 months ago

Picodes marked the issue as unsatisfactory: Invalid