Skip to content
Business logic Audit finding Intermediate

LToken's implmentation is not fully up to EIP-4626's specification

The LToken contract's maxMint and maxDeposit functions return the maximum uint256 value instead of respecting the contract's maxSupply limit, violating the EIP-4626 standard. This could cause unexpected behaviour in the future due to non-compliance.

WatchPug Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-08-sentiment-judging/tree/main/500-M

Found by

WATCHPUG

Summary

Note: This issue is a part of the extra scope added by Sentiment AFTER the audit contest. This scope was only reviewed by WatchPug and relates to these three PRs:

  1. Lending deposit cap
  2. Fee accrual modification
  3. CRV staking

LToken's implmentation is not fully up to EIP-4626's specification. This issue is would actually be considered a Low issue if it were a part of a Sherlock contest.

Vulnerability Detail

https://github.com/sentimentxyz/protocol/blob/ccfceb2805cf3595a95198c97b6846c8a0b91506/src/tokens/utils/ERC4626.sol#L185-L187

Solidity
function maxMint(address) public view virtual returns (uint256) {
    return type(uint256).max;
}

MUST return the maximum amount of shares mint would allow to be deposited to receiver and not cause a revert, which MUST NOT be higher than the actual maximum that would be accepted (it should underestimate if necessary). This assumes that the user has infinite assets, i.e. MUST NOT rely on balanceOf of asset.

https://eips.ethereum.org/EIPS/eip-4626#:~:text=MUST%20return%20the%20maximum%20amount%20of%20shares,NOT%20rely%20on%20balanceOf%20of%20asset

maxMint() and maxDeposit() should reflect the limitation of maxSupply.

Impact

Could cause unexpected behavior in the future due to non-compliance with EIP-4626 standard.

Code Snippet

https://github.com/sentimentxyz/protocol/blob/ccfceb2805cf3595a95198c97b6846c8a0b91506/src/tokens/utils/ERC4626.sol#L185-L187

Solidity
function maxMint(address) public view virtual returns (uint256) {
    return type(uint256).max;
}

Tool used

Manual Review

Recommendation

maxMint() and maxDeposit() should reflect the limitation of maxSupply.

Consider changing maxMint() and maxDeposit() to:

Solidity
function maxMint(address) public view virtual returns (uint256) {
    if (totalSupply >= maxSupply) {
        return 0;
    }
    return maxSupply - totalSupply;
}
Solidity
function maxDeposit(address) public view virtual returns (uint256) {
    return convertToAssets(maxMint(address(0)));
}

Sentiment Team

Fixed as recommended. PR here.

Lead Senior Watson

Confirmed fix.

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

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 maxMint and maxDeposit functions were implemented as simple placeholders returning the maximum uint256 value, without accounting for the contract's maxSupply limit as required by EIP-4626.

Impact

Could cause unexpected behavior in the future due to non-compliance with EIP-4626 standard.

What the attacker needed

None

The fix

The team fixed it by making maxMint and maxDeposit reflect the maxSupply limitation, as recommended.

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 about a smart contract that follows a standard called EIP-4626 for tokenised vaults. The standard says a function called maxMint should tell users the largest number of shares they can mint, but this contract simply says 'the biggest number possible' without considering its own supply cap. That mismatch could confuse other contracts or users who rely on the standard.

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 WatchPug

View all

197 more disclosed reports, best first.

More from Sentiment Update #3

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.