Closed sherlock-admin2 closed 8 months ago
1 comment(s) were left on this issue during the judging contest.
takarez commented:
invalid
The prefunded*
functions are used by Tranche
. those functions are not direct entry points for users, and normally, assets would not be left at the end of txn.
st0yanov
medium
Prefunded deposits to children of
BaseLSTAdapter
could be lost and shares stolenSummary
Transfers of underlying token (WETH) to
BaseLSTAdapter
's child contracts (StEtherAdapter
,SFrxETHAdapter
) could be lost and shares could be stolen by an arbitrary sender who invokes theprefundedDeposit
function.Vulnerability Detail
The design of the
prefundedDeposit
function implies that the caller should first transfer some amount of the underlying token and after that call theprefundedDeposit
function within the same transaction, similarly to how it is done in theTranche
contract:https://github.com/sherlock-audit/2024-01-napier/blob/6313f34110b0d12677b389f0ecb3197038211e12/napier-v1/src/Tranche.sol#L206-L208
However if the
prefundedDeposit
function is not invoked within the same transaction, it could be either called by another user or frontrun by an attacker. This way the attacker will steal the shares in the adapter contract, as there aren't any deposit ownership checks or accounting present in theprefundedDeposit
function.https://github.com/sherlock-audit/2024-01-napier/blob/main/napier-v1/src/adapters/BaseLSTAdapter.sol#L71-L139
Impact
Users could lose their WETH deposits to the adapter and not receive shares in return.
Code Snippet
https://github.com/sherlock-audit/2024-01-napier/blob/main/napier-v1/src/adapters/BaseLSTAdapter.sol#L71-L139
PoC
Add the following test in the
napier-v1/test/unit/adapters/BaseTestLSTAdapter.t.sol
test and run it by using:Tool used
Manual Review
Recommendation
If the
BaseLSTAdapter
and its children (StEtherAdapter
,SFrxETHAdapter
) is indeed expected to be used only by theTranche
contract, make theprefundedDeposit
callable only by theTranche
contract via a modifier e.g.: