Skip to content
Business logic Audit finding Intermediate

Lock.sol: claimGovFees function can cause assets to be stuck in the Lock contract

When claimGovFees moves government fee tokens from the GovNFT contract into the Lock contract, the follow-up call to BondNFT.distribute silently returns early if the asset has no shares or is not allowed. The transferred tokens then remain stuck in the Lock contract and cannot be recovered.

HollaDieWaldfee Follow with __141345__ and 0xdeadbeef0x

Originally disclosed on Code4rena

Submitted by HollaDieWaldfee, also found by 141345 and 0xdeadbeef0x

https://github.com/code-423n4/2022-12-tigris/blob/496e1974ee3838be8759e7b4096dbee1b8795593/contracts/Lock.sol#L110

https://github.com/code-423n4/2022-12-tigris/blob/496e1974ee3838be8759e7b4096dbee1b8795593/contracts/BondNFT.sol#L215

Impact

When calling Lock.claimGovFees, assets that are set to be not allowed or assets that don’t have any shares yet in the BondNFT contract will cause a silent failure in BondNFT.distribute.

The funds from the GovNFT contract will get transferred into the Lock contract and then will be stuck there. They cannot be recovered.

Proof of Concept

  1. An asset is added to the BondNFT contract by calling BondNFT.addAsset

  2. There are no bonds yet for this asset so the amount of shares for the asset is zero

  3. Lock.claimGovFees is called

  4. Funds are transferred from the GovNFT contract to the Lock contract

  5. The call to BondNFT.distribute now fails quietly without reverting the transaction:

     if (totalShares[_tigAsset] == 0 || !allowedAsset[_tigAsset]) return;
    
  6. The funds are now stuck in the Lock contract. They cannot be recovered.

Tools Used

VS Code

Recommended Mitigation Steps

A naive solution would be to use revert instead of return in BondNFT.distribute such that funds are either transferred from GovNFT to Lock and then to BondNFT or not at all.

     ) external {
-        if (totalShares[_tigAsset] == 0 || !allowedAsset[_tigAsset]) return;
+        if (totalShares[_tigAsset] == 0 || !allowedAsset[_tigAsset]) revert;
         IERC20(_tigAsset).transferFrom(_msgSender(), address(this), _amount);
         unchecked {
             uint aEpoch = block.timestamp / DAY;

This however is an incomplete fix because if there is a single “bad” asset, rewards for the other assets cannot be distributed either.

Moreover functions like Lock.lock and Lock.release rely on Lock.claimGovFees to not revert.

So you might allow the owner to rescue stuck tokens from the Lock contract. Of course only allow rescuing the balance of the Lock contract minus the totalLocked of the asset in the Lock contract such that the locked amount cannot be rescued.

Alex the Entreprenerd (judge) commented:

Looks off, the transferFrom would happen after the check.

If totalShares is zero, the funds will not be pulled.

Will double check but looks invalid.

TriHaz (Tigris Trade) confirmed and commented:

@Alex the Entreprenerd it is valid, funds will not be pulled to BondNFT, but they will be stuck in Lock.

Alex the Entreprenerd (judge) commented:

The warden has shown how, whenever the totalShares for an asset are zero, or an asset is not allowed, the call to distribute will result in a no-op.

Because claimGovFees uses a delta balance, this means that those tokens will be stuck in the Lock Contract.

Because this finding shows a way to lose yield, due to an external condition, I agree with Medium Severity.

GainsGoblin (Tigris Trade) resolved:

Mitigation: https://github.com/code-423n4/2022-12-tigris/pull/2#issuecomment-1419173369


The original report as published on Code4rena, by HollaDieWaldfee. 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

Likely the distribute function returns early instead of reverting when an asset has zero shares or is not allowed, while the caller has already moved the funds.

Impact

Fee yield can be permanently lost whenever an asset has no shares or is not allowed, though the judge rated this Medium severity.

What the attacker needed

An asset with zero shares or not allowed; claimGovFees is called

The fix

The team resolved it via a linked pull request; the report also suggests reverting instead of returning, or letting the owner rescue balances above the locked amount.

How it was found

  1. An asset is added to the BondNFT contract by calling BondNFT.addAsset
  2. There are no bonds yet for this asset so the amount of shares for the asset is zero
  3. Lock.claimGovFees is called
  4. Funds are transferred from the GovNFT contract to the Lock contract
  5. The call to BondNFT.distribute now fails quietly without reverting the transaction
  6. The funds are now stuck in the Lock contract. They cannot be recovered.

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 moved fee tokens into a holding contract and then asked a second contract to hand them out. That second contract quietly did nothing when the token had no holders yet, so the tokens sat in the holding contract with no way to get them out. A silent early exit instead of an error left the money stranded.

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 HollaDieWaldfee

View all

39 more disclosed reports, best first.

More from Tigris Trade 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.