• LISA
    LISA
    • Public Scans
    • My Scans
    1. Scan
    2. ...
    2025-06-26 10:07:22
    Public
    Full Disclosure

    SiloFinance GeneralSwapModule Vuln

    high4
    Created By:
    Credit Usage:

    Missing minimum amount out validation allows slippage and sandwich attacks

    HIGH

    Description

    The _fillQuote function does not validate the received amount of buy tokens against a minimum expected value. This allows attackers to perform sandwich attacks, front-running the transaction to manipulate the swap price, resulting in significant slippage and loss of funds. The current check only ensures the amount is non-zero, which is insufficient to prevent such attacks.

    Recommendation

    Introduce a minAmountOut parameter in SwapArgs and validate that amountOut (calculated as the difference between post-swap and pre-swap balances) is at least minAmountOut to ensure the swap meets expected price conditions.

    Affected Lines

    Line 44 – 45

    Arbitrary allowance target allows token approval to malicious addresses

    HIGH

    Description

    The allowanceTarget in SwapArgs is not validated, allowing a malicious user to set it to an arbitrary address. This could lead to the contract approving a malicious spender to transfer unlimited or large amounts of the sell token, resulting in theft of funds if the parent contract does not properly restrict allowanceTarget.

    Recommendation

    Validate that allowanceTarget is either the exchangeProxy or a trusted list of addresses. Ensure the parent contract enforces strict checks on allowanceTarget when decoding _swapArgs.

    Affected Lines

    Line 31 – 35

    Incorrect amountOut calculation due to pre-existing buy token balance

    HIGH

    Description

    The amountOut is calculated as the total balance of the buy token after the swap, including any pre-existing balance in the contract. This leads to incorrect accounting, overreporting the actual tokens received from the swap, which could cause fund mismanagement or exploitation in dependent logic.

    Recommendation

    Measure the buy token balance before and after the swap, then compute amountOut as the difference. For example:

    uint256 balanceBefore = IERC20(swapArgs.buyToken).balanceOf(address(this));
    // Perform swap...
    amountOut = IERC20(swapArgs.buyToken).balanceOf(address(this)) - balanceBefore;
    

    Affected Lines

    Line 44 – 44

    Arbitrary `exchangeProxy` and `allowanceTarget` allow fund theft

    HIGH

    Description

    The contract does not validate exchangeProxy and allowanceTarget addresses beyond checking exchangeProxy is non-zero. An attacker can supply malicious addresses to steal approved tokens. For example, if allowanceTarget is set to a malicious contract and swapCallData triggers a token transfer, the contract’s tokens can be drained. This leads to loss of all approved tokens, as the external call executes arbitrary code with the contract’s funds.

    Recommendation

    Implement a whitelist for trusted exchangeProxy and allowanceTarget addresses. Restrict swaps to pre-approved, audited exchange contracts to prevent unauthorized token transfers.

    Affected Lines

    Line 30 – 40