# Unvalidated flash loan parameters

Caller-supplied debt, swap or slippage params reaching value-moving sinks without bounds or identity checks

_Area: DeFi oracles, liquidations and flash loans. Seen in 3 disclosed reports; latest 2025-02-08. Updated 2026-12-04._

## How it works
A flash loan entrypoint or callback trusts the parameters the caller hands it. The contract assumes those parameters describe an operation the caller is entitled to perform, but nothing binds them to the caller's identity, to sane bounds, or to the protocol's own state. The caller can name arbitrary debt tokens, amounts, swap targets, calldata, or slippage, and the contract executes them against its own balances and approvals. The broken assumption is "the caller supplies parameters for their own operation"; in reality the caller supplies parameters that steer the protocol's funds.

## Where it shows up
- Flash loan request/callback functions taking structs or bytes (debt tokens, amounts, swapData) with no allowlist or bound checks [E1](https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md)
- Low-level calls or DEX routers invoked with caller-supplied calldata, where that calldata is not restricted to safe targets [E1](https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md)
- Migration functions that move liquidity tokens based on caller-influenced state, with no check that the caller owns the position being migrated [E2](https://bugbountylibrary.com/r/dhl%3A20220409-gym-1.md)
- Reward/treasury functions exposing a caller-settable slippage or min-out parameter that feeds an internal swap [E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md)
- Any `amountOutMinimum` derived directly from a user argument rather than an oracle or constant [E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md)

## How to review
For each externally callable function that takes parameters and then moves value:
- Trace every parameter to its sink (swap call, transfer, low-level call). The invariant: no caller-supplied value may set the recipient, the token, the amount beyond the caller's own entitlement, or the minimum output of a protocol-owned swap.
- Check identity: does the function verify the caller owns the debt/collateral/liquidity it is manipulating? If not, arbitrary manipulation is possible [E1](https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md).
- Check bounds: slippage and min-out must be clamped or ignored in favor of an oracle/constant; a caller-set `amountOutMinimum` is a sandwich primitive [E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md).
- Check calldata: if swapData is executed, confirm it cannot invoke sensitive functions on behalf of other users [E1](https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md).
- For migration paths, confirm state cannot be manipulated between add-liquidity and migrate [E2](https://bugbountylibrary.com/r/dhl%3A20220409-gym-1.md).

## How finders spotted it
- Static review habit: when a contract accepts arbitrary swapData and makes low-level calls, ask whether attacker-controlled calldata can reach `transferFrom` or other sensitive functions on other users' behalf [E1](https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md).
- Static review habit: examine migration functions for improper handling of liquidity tokens or state manipulable via flash loans and swaps [E2](https://bugbountylibrary.com/r/dhl%3A20220409-gym-1.md).
- Static review: noted that `depositFromPairedLpToken` exposes `_slippageOverride` as a caller-controlled parameter feeding `amountOutMinimum`, making reward processing sandwichable [E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md).
- Grep reward/treasury contracts for user-supplied slippage or min-out parameters that feed internal DEX swaps [E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md).

## Variants seen
- Arbitrary debt/collateral/swapData in a deleverage connector, exploited via a crafted flashloanReq call [E1](https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md)
- Liquidity migration flaw exploited with a flash loan plus add-liquidity and migrate [E2](https://bugbountylibrary.com/r/dhl%3A20220409-gym-1.md)
- Caller-set slippage override on a reward swap, exploited by flash-swapping to skew price [E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md)

## Impact and severity
Direct fund loss scaled to protocol balances: ~$1.8M drained [E1](https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md), fund drain via migration [E2](https://bugbountylibrary.com/r/dhl%3A20220409-gym-1.md), and ~$3,500 from reward slippage [E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md). Severity rises with the value the function can move and whether a flash loan supplies the capital to manipulate price in the same transaction [E2](https://bugbountylibrary.com/r/dhl%3A20220409-gym-1.md)[E3](https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md).

## Evidence
- E1: https://bugbountylibrary.com/r/dhl%3A20240712-doughfina.md
- E2: https://bugbountylibrary.com/r/dhl%3A20220409-gym-1.md
- E3: https://bugbountylibrary.com/r/dhl%3A20250208-peapodsfinance.md
