Malicious users can front-run to cause a denial of service (DoS) for StakedUSDe due to MinShares checks
A malicious user can transfer USDe tokens directly to the StakedUSDe contract, inflating totalAssets and causing the share calculation to round down to zero for subsequent depositors. This makes it impossible for legitimate users to deposit enough to meet the minimum share requirement, effectively denying service to the protocol.
Submitted by ayden, also found by d3e4 (1, 2), pontifex, trachev, ciphermarco, Madalad, Yanchuan, peanuts, twcctop, cartlex_, mert_eren, 0xWaitress (1, 2), and critical-or-high
Malicious users can transfer USDe token to StakedUSDe protocol directly lead to a denial of service (DoS) for StakedUSDe due to the limit shares check.
Proof of Concept
User deposit USDe token to StakedUSDe protocol to get share via invoke external deposit function. Let’s see how share is calculate:
function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {
return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);
}
Since decimalsOffset() == 0 and totalAssets equal the balance of USDe in this protocol
function totalAssets() public view virtual override returns (uint256) {
return _asset.balanceOf(address(this));
}
$$ f(share) = (USDeAmount \ast totalSupply) / (totalUSDeAssets() + 1) $$
The minimum share is set to 1 ether.
uint256 private constant MIN_SHARES = 1 ether;
Assuming malicious users transfer 1 ether of USDe into the protocol and receive ZERO shares, how much tokens does the next user need to pay if they want to exceed the minimum share limit of 1 ether? That would be 1 ether times 1 ether, which is a substantial amount.
I add a test case in StakedUSDe.t.sol:
function testMinSharesViolation() public {
address malicious = vm.addr(100);
usdeToken.mint(malicious, 1 ether);
usdeToken.mint(alice, 1000 ether);
//assume malicious user deposit 1 ether into protocol.
vm.startPrank(malicious);
usdeToken.transfer(address(stakedUSDe), 1 ether);
vm.stopPrank();
vm.startPrank(alice);
usdeToken.approve(address(stakedUSDe), type(uint256).max);
//1000 ether can't exceed the minimum share limit of 1 ether
vm.expectRevert(IStakedUSDe.MinSharesViolation.selector);
stakedUSDe.deposit(1000 ether, alice);
}
We can see even Alice deposit a substantial number of tokens but still cannot surpass the 1 ether share limit which will lead to a denial of service (DoS) for StakedUSDe due to MinShares checks.
Tools Used
vscode
Recommended Mitigation Steps
We can solve this issue by setting a minimum deposit amount.
Assessed type
DoS
FJ-Riveros (Ethena) acknowledged, but disagreed with severity and commented via duplicate issue #32:
We acknowledge the potential exploitability of this issue, but we propose marking it as
Mediumseverity. Our rationale is based on the fact that this exploit can only occur during deployment. To mitigate this risk, we plan to fund the smart contract in the next block, ensuring that nobody has access to the ABI or contract source code. We could even use flashbots for this purpose.
0xDjango (judge) commented via duplicate issue #32:
Agree with medium. Several of the duplicate reports vary in their final impacts but mostly consist of:
- Small donation leading to bricked contract
- Large donation can eventually lead to blocked withdrawals
The small donation impact simply requires a redeploy, though the impact is a valid medium. The large donation has major implications for stakers, but the large amount of capital required downgrades it to medium as well. I will be reviewing each duplicate on a case-by-case basis to ensure that all impacts due to the same bug class fit within medium.
0xDjango (judge) decreased severity to Medium
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 share price calculation uses the contract's token balance as totalAssets, which can be inflated by direct transfers, causing new deposits to round down to zero shares and fail the minimum share check.
Impact
Legitimate users cannot deposit into StakedUSDe, causing a denial of service; the attack is only possible shortly after deployment, and the team plans to mitigate by funding the contract in the next block.
What the attacker needed
Attacker has a small amount of USDe; Contract is newly deployed and unfunded
The fix
The issue should be fixed by setting a minimum deposit amount, as recommended in the report.
How it was found
- Attacker transfers 1 ether of USDe directly to the StakedUSDe contract.
- Victim approves the StakedUSDe contract to spend their USDe.
- Victim calls deposit with a large amount (e.g., 1000 ether).
- The transaction reverts with MinSharesViolation because the calculated shares are below 1 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.
The StakedUSDe contract gives out shares when people deposit tokens. If someone sends tokens directly to the contract without depositing, the contract's total assets go up, so each new deposit buys fewer shares. An attacker can send a small amount to make the share calculation round down to zero for everyone else, so no one can deposit enough to get the minimum one share.
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.