Skip to content
Business logic Audit finding Intermediate

Incorrect checking in _assertUserHasEnoughGiantLPToClaimVaultLP

The batch withdrawal functions check the wrong token's last-interaction timestamp, so after the first withdrawal the shared token's timestamp is updated and any further withdrawals in the same batch fail. An attacker could not gain funds, but legitimate users could not withdraw several LP tokens in one transaction, forcing one withdrawal per day.

hihen Follow with Trust and Lambda

Originally disclosed on Code4rena

Submitted by hihen, also found by Trust and Lambda

The batch operations of withdrawDETH() in GiantSavETHVaultPool.sol and withdrawLPTokens() in GiantPoolBase.sol are meaningless because they will fail whenever more than one lpToken is passed. Each user can perform withdrawDETH() or withdrawLPTokens() with one LPToken only once a day.

Proof of Concept

Both the withdrawDETH() in GiantSavETHVaultPool.sol and withdrawLPTokens() in GiantPoolBase.sol will call GiantPoolBase._assertUserHasEnoughGiantLPToClaimVaultLP(lpToken, amount) and lpTokenETH.burn(msg.sender, amount):

There is a require in _assertUserHasEnoughGiantLPToClaimVaultLP():

require(lpTokenETH.lastInteractedTimestamp(msg.sender) + 1 days < block.timestamp, "Too new");

At the same time, lpTokenETH.burn(msg.sender, amount) will update lastInteractedTimestamp[msg.sender] to latest block timestamp in _afterTokenTransfer() of GiantLP.sol.

So, a user can perform withdrawDETH or withdrawLPTokens of one LPToken only once a day, others more will fail by _assertUserHasEnoughGiantLPToClaimVaultLP().

Tools Used

VS Code

Recommended Mitigation Steps

The LPToken being operated on should be checked for lastInteractedTimestamp rather than lpTokenETH.

diff --git a/contracts/liquid-staking/GiantPoolBase.sol b/contracts/liquid-staking/GiantPoolBase.sol
index 8a8ff70..5c009d9 100644
--- a/contracts/liquid-staking/GiantPoolBase.sol
+++ b/contracts/liquid-staking/GiantPoolBase.sol
@@ -93,7 +93,7 @@ contract GiantPoolBase is ReentrancyGuard {
     function _assertUserHasEnoughGiantLPToClaimVaultLP(LPToken _token, uint256 _amount) internal view {
         require(_amount >= MIN_STAKING_AMOUNT, "Invalid amount");
         require(_token.balanceOf(address(this)) >= _amount, "Pool does not own specified LP");
-        require(lpTokenETH.lastInteractedTimestamp(msg.sender) + 1 days < block.timestamp, "Too new");
+        require(_token.lastInteractedTimestamp(msg.sender) + 1 days < block.timestamp, "Too new");
     }

     /// @dev Allow an inheriting contract to have a hook for performing operations post depositing ETH

vince0656 (Stakehouse) confirmed


The original report as published on Code4rena, by hihen. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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 check reads the timestamp from the shared lpTokenETH contract instead of the specific LPToken being withdrawn, while the burn updates the shared timestamp.

Impact

Batch withdrawals of more than one LP token always revert, so users can only withdraw one token per day; no funds are lost.

What the attacker needed

Holds LP tokens in the pool; waits a day between withdrawals

How it was found

  1. Call withdrawDETH or withdrawLPTokens with more than one LP token in the batch.
  2. The function checks the shared lpTokenETH last-interaction timestamp for the caller.
  3. The first burn updates that shared timestamp to the current block.
  4. The next item in the batch fails the 'Too new' require and the whole call reverts.

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 lets people withdraw several tokens at once, but it checks a shared record of when the user last acted instead of the record for each token. The first withdrawal updates that shared record, so the rest of the batch is rejected as 'too new'. This is a logic bug that breaks a feature rather than letting someone steal money.

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.

More by hihen

View all

10 more disclosed reports, best first.

More from LSD Network - Stakehouse contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.