Open code423n4 opened 1 year ago
0xSorryNotSorry marked the issue as primary issue
outdoteth marked the issue as sponsor confirmed
outdoteth marked the issue as sponsor acknowledged
I have considered downgrading to QA for the ETH aspect as technically there is no EIP for ETH flashloans (FL EIP is only for ERC20s)
That said, the way payment is pulled in ERC20s is breaking the spec, and for this reason am awarding Medium Severity
GalloDaSballo marked the issue as selected for report
Lines of code
https://github.com/code-423n4/2023-04-caviar/blob/main/src/PrivatePool.sol#L623
Vulnerability details
Impact
Instead of taking the fee from the receiver of the flashloan callback, it pulls it from
msg.sender
.As specified in EIP-3156:
This will be an unexpected loss of funds for the caller if they have the pool pre-approved to spend funds (e.g. they previously bought NFTs) and are not the owner of the flashloan contract they use for the callback.
Additionally, for ETH pools, it expects the caller to pay the fee upfront. But, the fee is generally paid with the profits made using the flashloaned tokens.
Proof of Concept
If
baseToken
is ETH, it expects the fee to already be sent with the call toflashLoan()
. If it's an ERC20 token, it will pull it frommsg.sender
instead ofreceiver
:Tools Used
none
Recommended Mitigation Steps
Change to: