Victim's fund can be stolen due to rounding error and exchange rate manipulation
Victim's funds can be stolen by malicious users by exploiting the rounding error and through exchange rate manipulation.\\nThe LST Adaptor attempts to guard against the well-known vault inflation attack by reverting the TX when the amount of shares minted is rounded down to zero in Line 78 below.\\n```\\nFile: BaseLSTAdapter.sol\\n    function prefundedDeposit() external nonReentrant returns (uint256, uint256) {\\n        uint256 bufferEthCache = bufferEth; // cache storage reads\\n        uint256 queueEthCache = withdrawalQueueEth; // cache storage reads\\n        uint256 assets = IWETH9(WETH).balanceOf(address(this)) - bufferEthCache; // amount of WETH deposited at this time\\n        uint256 shares = previewDeposit(assets);\\n\\n        if (assets == 0) return (0, 0);\\n        if (shares == 0) revert ZeroShares();\\n```\\n\\nHowever, this control alone is not sufficient to guard against vault inflation attacks.\\nLet's assume the following scenario (ignoring fee for simplicity's sake):\\nThe victim initiates a transaction that deposits 10 ETH as the underlying asset when there are no issued estETH shares.\\nThe attacker observes the victim's transaction and deposits 1 wei of ETH (issuing 1 wei of estETH share) before the victim's transaction. 1 wei of estETH share worth of PT and TY will be minted to the attacker.\\nThen, the attacker executes a transaction to directly transfer 5 stETH to the adaptor. The exchange rate at this point is `1 wei / (5 ETH + 1 wei)`. Note that the `totalAssets` function uses the `balanceOf` function to compute the total underlying assets owned by the adaptor. Thus, this direct transfer will increase the total assets amount.\\nWhen the victim's transaction is executed, the number of estETH shares issued is calculated as 10 ETH * `1 wei / (5 ETH + 1 wei)`, resulting in 1 wei being issued due to round-down.\\nThe attacker will combine the PT + YT obtained earlier to redeem 1 wei of estETH share from the adaptor.\\nThe attacker, holding 50% of the issued estETH shares (indirectly via the PT+YT he owned), receives `(15 ETH + 1 wei) / 2` as the underlying asset.\\nThe attacker seizes 25% of the underlying asset (2.5 ETH) deposited by the victim.\\nThis scenario demonstrates that even when a revert is triggered due to the number of issued estETH share being 0, it does not prevent the attacker from capturing the user's funds through exchange rate manipulation.
Following are some of the measures that could help to prevent such an attack:\\nMint a certain amount of shares to zero address (dead address) during contract deployment (similar to what has been implemented in Uniswap V2)\\nAvoid using the `balanceOf` so that malicious users cannot transfer directly to the contract to increase the assets per share. Track the total assets internally via a variable.
Loss of assets for the victim.
```\\nFile: BaseLSTAdapter.sol\\n    function prefundedDeposit() external nonReentrant returns (uint256, uint256) {\\n        uint256 bufferEthCache = bufferEth; // cache storage reads\\n        uint256 queueEthCache = withdrawalQueueEth; // cache storage reads\\n        uint256 assets = IWETH9(WETH).balanceOf(address(this)) - bufferEthCache; // amount of WETH deposited at this time\\n        uint256 shares = previewDeposit(assets);\\n\\n        if (assets == 0) return (0, 0);\\n        if (shares == 0) revert ZeroShares();\\n```\\n