Depositing `stETH` to puffer finance will revert due to wrong implementation of `PufETHAdapter._stake` call
The PufETHAdapter contract calls the PufferDepositor's depositStETH function with only one argument, but the upgraded PufferDepositor requires two arguments (a Permit and a recipient address). As a result, any attempt to deposit stETH through this adapter will revert, making deposits to Puffer impossible.
Bauer Follow with Drynooo, Ironsidesec and 9 others
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2024-05-napier-update-judging/issues/21
Found by
Bauer, Drynooo, Ironsidesec, KupiaSec, PNS, blackhole, blutorque, karsar, merlin, no, yamato, zzykxx
Summary
Reason: PufETHAdapter._stake will always revert due to wrong external call implementation.
Impact: Can't deposit to Puffer.
Likelihood: always.
Vulnerability Detail
File: 2024-05-napier-update\napier-uups-adapters\src\adapters\puffer\PufETHAdapter.sol
66: function _stake(uint256 stakeAmount) internal override returns (uint256) {
...
74:
75: IWETH9(Constants.WETH).withdraw(stakeAmount);
76: uint256 _stETHAmt = STETH.balanceOf(address(this));
77: STETH.submit{value: stakeAmount}(address(this));
78: _stETHAmt = STETH.balanceOf(address(this)) - _stETHAmt;
79: if (_stETHAmt == 0) revert InvariantViolation();
80:
81: // Stake stETH to PufferDepositor
82: >>> uint256 _pufETHAmt = PUFFER_DEPOSITOR.depositStETH(Permit(block.timestamp, _stETHAmt, 0, 0, 0));
84:
...
88: }
Issue flow:
- When depositing by calling
PUFFER_DEPOSITOR.depositStETH(Permit),PufETHAdapterpasses only one parameterPermitlook at line 82 above. - But the current
PUFFER_DEPOSITOR.depositStETHhas 2 parameters (Permit, address recipient). Check https://etherscan.io/address/0x4aA799C5dfc01ee7d790e3bf1a7C2257CE1DcefF#writeProxyContract#F1. - This is due to the proxy upgrade of
PUFFER_DEPOSITORfrom implementation v1 to implementation v2.
To check upgares of PUFFER_DEPOSITOR, scroll on https://etherscan.io/address/0x4aA799C5dfc01ee7d790e3bf1a7C2257CE1DcefF#writeProxyContract
Previous implementation where it had only one param https://etherscan.io/address/0x7276925e42f9c4054afa2fad80fa79520c453d6a#code#F1#L182
Latest implementation has 2 params https://etherscan.io/address/0x8c9517a9e99c74cd072a118d3dc6b4f3217f8b9b#code#F1#L67
Impact
Depositing stETH to puffer finance is not possible with current PufETHAdapter
Code Snippet
https://etherscan.io/address/0x8c9517a9e99c74cd072a118d3dc6b4f3217f8b9b#code#F1#L41
https://etherscan.io/address/0x4aA799C5dfc01ee7d790e3bf1a7C2257CE1DcefF#writeProxyContract
Tool used
Manual Review
Recommendation
function _stake(uint256 stakeAmount) internal override returns (uint256) {
...
IWETH9(Constants.WETH).withdraw(stakeAmount);
uint256 _stETHAmt = STETH.balanceOf(address(this));
STETH.submit{value: stakeAmount}(address(this));
_stETHAmt = STETH.balanceOf(address(this)) - _stETHAmt;
if (_stETHAmt == 0) revert InvariantViolation();
// Stake stETH to PufferDepositor
- uint256 _pufETHAmt = PUFFER_DEPOSITOR.depositStETH(Permit(block.timestamp, _stETHAmt, 0, 0, 0));
+ uint256 _pufETHAmt = PUFFER_DEPOSITOR.depositStETH(Permit(block.timestamp, _stETHAmt, 0, 0, 0), address(this));
if (_pufETHAmt == 0) revert InvariantViolation();
return stakeAmount;
}
Discussion
sherlock-admin2
The protocol team fixed this issue in the following PRs/commits: https://github.com/napierfi/napier-uups-adapters/pull/10
zzykxx
This has been fixed by changing the functionality of the _stake() function, now it deposits WETH instead of stETH.
sherlock-admin2
The Lead Senior Watson signed off on the fix.
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 adapter's call to PUFFER_DEPOSITOR.depositStETH uses the old function signature (one argument) after the PufferDepositor contract was upgraded to require two arguments.
Impact
Depositing stETH to Puffer Finance is not possible with the current PufETHAdapter because the call always reverts.
What the attacker needed
None
The fix
The protocol team fixed this issue by changing the _stake function to deposit WETH instead of stETH.
How it was found
- Call the deposit function that triggers PufETHAdapter._stake.
- The adapter withdraws WETH and submits it to obtain stETH.
- The adapter calls PUFFER_DEPOSITOR.depositStETH with only a Permit argument.
- The call reverts because the function now expects two arguments.
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.
This is a smart contract bug where a function call is made with the wrong number of arguments. The adapter tries to call depositStETH with one argument, but the updated PufferDepositor expects two, so the call fails and the transaction reverts. This means users cannot deposit their stETH to Puffer through this adapter.
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.