Missing sender address check in receive may lea
The receive function of the PufferVault contract accepts Ether from any sender, but only accounts for withdrawals from Lido. Ether sent by other addresses becomes permanently locked and also skews the totalAssets calculation.
- Disclosed after under an hour
28779 - [SC - Insight] Missing sender address check in receive may lea...
Submitted on Feb 26th 2024 at 21:58:19 UTC by @djxploit for Boost | Puffer Finance
Report ID: #28779
Report type: Smart Contract
Report severity: Insight
Target: https://etherscan.io/address/0xd9a442856c234a39a81a089c06451ebaa4306a72
Impacts:
- Permanent freezing of funds
Description
Brief/Intro
The receive function of PufferVault.sol contract, is meant to receive Ether only from Lido. Hence any other ether sent to the contract (accidentally) will be forever locked in the contract, as it will not be accounted for.
Vulnerability Details
Add an address check in receive() of PufferVault.sol to ensure the only address sending ETH being received in receive() is the Lido contract.
This will prevent stray Ether from being sent accidentally to this contract and getting locked.
Impact Details
Ethers will get permanently locked in the PufferVault contract, if they are sent from addresses other than Lido contract. Furthermore it will also affect the accounting of the totalAssets functions, as it depends on the ether balance of the contract.
References
https://etherscan.io/address/0xd9a442856c234a39a81a089c06451ebaa4306a72?utm\\_source=immunefi
Proof of Concept
Receive function of PufferVault contract
receive() external payable virtual {
VaultStorage storage $ = _getPufferVaultStorage();
if ($.isLidoWithdrawal) {
$.lidoLockedETH -= msg.value;
}
}
We can fix it by adding an address check like
receive() external payable virtual {
VaultStorage storage $ = _getPufferVaultStorage();
require($.isLidoWithdrawal, "Not allowed");
$.lidoLockedETH -= msg.value;
}
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
The receive function lacks a check that the sender is the Lido contract, so it accepts and mis-accounts Ether from any address.
What the attacker needed
Ether sent from a non-Lido address
The fix
The receive function should require that the call comes from the Lido contract before accepting Ether.
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.
A smart contract can have a special function that runs when it receives Ether. This one was meant to accept Ether only from a specific partner contract (Lido), but it does not check who sent the Ether. If anyone else sends Ether by mistake, the contract has no way to send it back, so it stays stuck there forever.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.