OpenLevV1Lib’s and LPool’s doTransferOut functions call native payable.transfer , which can be unusable for smart contract calls
The smart contracts use Solidity's transfer() to send native tokens, which forwards only a fixed 2300 gas stipend. If the recipient is a smart contract with a costly fallback function, the transfer fails, so users cannot withdraw their funds or close trades.
Submitted by hyh
When OpenLev operations use a wrapped native token, the whole user withdraw is being handled with a payable.transfer() call.
This is unsafe as transfer has hard coded gas budget and can fail when the user is a smart contract. This way any programmatical usage of OpenLevV1 and LPool is at risk.
Whenever the user either fails to implement the payable fallback function or cumulative gas cost of the function sequence invoked on a native token transfer exceeds 2300 gas consumption limit the native tokens sent end up undelivered and the corresponding user funds return functionality will fail each time.
As OpenLevV1 closeTrade is affected this includes user’s principal funds freeze scenario, so marking the issue as a high severity one.
Proof of Concept
OpenLevV1Lib and LPool have doTransferOut function that calls native token payable.transfer:
OpenLevV1Lib.doTransferOut
LPool.doTransferOut
LPool.doTransferOut is used in LPool redeem and borrow, while OpenLevV1Lib.doTransferOut is used in OpenLevV1 trade manipulation logic:
closeTrade
liquidate
References
The issues with transfer() are outlined here:
https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/
Recommended Mitigation Steps
OpenLevV1’s closeTrade and liquidate as well as LPool’s redeem, redeemUnderlying, borrowBehalf, repayBorrowBehalf, repayBorrowEndByOpenLev are all nonReentrant, so reentrancy isn’t an issue and transfer() can be just replaced.
Using low-level call.value(amount) with the corresponding result check or using the OpenZeppelin Address.sendValue is advised:
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/Address.sol#L60
ColaM12 (OpenLeverage) confirmed and resolved
0xleastwood (judge) commented:
Awesome find! Completely agree with the warden here. This would prevent users from calling sensitive functions which withdraw their funds in some way.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the use of Solidity's transfer() for native token transfers, which forwards a fixed 2300 gas stipend and reverts if the recipient's fallback function requires more gas.
Impact
Users whose accounts are smart contracts may be unable to withdraw funds or close trades, potentially freezing their principal; the report marks this as high severity.
What the attacker needed
User is a smart contract; recipient fallback needs >2300 gas
The fix
The transfer() calls should be replaced with a low-level call that forwards all available gas and checks the result, or with OpenZeppelin's Address.sendValue; the report notes the functions are nonReentrant so reentrancy is not a concern.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
When a smart contract sends cryptocurrency to another contract, it also runs a small piece of code on the receiving contract. The transfer() function only gives that code a tiny, fixed amount of processing power (gas). If the receiving contract needs more, the whole payment fails, and the user cannot get their money back.
What is DoS?
A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.