No check for Individual mint amount surpassing 10% when the circulation reaches 10_000_000 in mint() of LybraEUSDVaultBase contract
The mint function in LybraEUSDVaultBase lacks a check to prevent individual mint amounts from exceeding 10% of the total circulation when circulation reaches 10,000,000, contrary to the documented requirement. An attacker could mint a large amount, potentially manipulating the market or bypassing intended limits.
Submitted by adeolu
Lines of code
https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/pools/base/LybraEUSDVaultBase.sol#L124 https://github.com/code-423n4/2023-06-lybra/blob/7b73ef2fbb542b569e182d9abf79be643ca883ee/contracts/lybra/pools/base/LybraEUSDVaultBase.sol#L126
Impact
The mint functions in LybraEUSDVaultBase have no checks for when the supplied amount to mint is more than 10% if circulation reaches 10,000,000, as specified in the comments explaining the logic of the function.
Proof of Concept
Lets have a look at mint() code in the LybraEUSDVaultBase contract:
/**
* @notice The mint amount number of EUSD is minted to the address
* Emits a `Mint` event.
*
* Requirements:
* - `onBehalfOf` cannot be the zero address.
* - `amount` Must be higher than 0. Individual mint amount shouldn't surpass 10% when the circulation
reaches 10_000_000
*/
function mint(address onBehalfOf, uint256 amount) external {
require(onBehalfOf != address(0), "MINT_TO_THE_ZERO_ADDRESS");
require(amount > 0, "ZERO_MINT");
_mintEUSD(msg.sender, onBehalfOf, amount, getAssetPrice());
}
function _mintEUSD(address _provider, address _onBehalfOf, uint256 _mintAmount, uint256 _assetPrice) internal virtual {
require(poolTotalEUSDCirculation + _mintAmount <= configurator.mintVaultMaxSupply(address(this)), "ESL");
try configurator.refreshMintReward(_provider) {} catch {}
borrowed[_provider] += _mintAmount;
EUSD.mint(_onBehalfOf, _mintAmount);
_saveReport();
poolTotalEUSDCirculation += _mintAmount;
_checkHealth(_provider, _assetPrice);
emit Mint(msg.sender, _onBehalfOf, _mintAmount, block.timestamp);
}
From the code above, we can see there is no check prevent mint amount from being greater than 10% of 10,000,000 or more if the poolTotalEUSDCirculation is 10,000,000 or more as specified in the comments.
Tools Used
VS CODE
Recommended Mitigation Steps
Add checks to the mint() to revert if mint amount is greater than 10% of the total supply, if total supply is >= 10,000,000.
function mint(address onBehalfOf, uint256 amount) external {
require(onBehalfOf != address(0), "MINT_TO_THE_ZERO_ADDRESS");
require(amount > 0, "ZERO_MINT");
if ( poolTotalEUSDCirculation >= 10_000_000 ) {
require(amount <= (10 * poolTotalEUSDCirculation) / 100, 'amount greater than 10% of circulation' );
}
_mintEUSD(msg.sender, onBehalfOf, amount, getAssetPrice());
}
Assessed type
Error
0xean (judge) decreased severity to Medium and commented:
@LybraFinance - this appears to be more of a M severity issue as it doesn’t directly lead to assets being lost or stolen.
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 mint function does not implement the documented limit on individual mint amounts relative to total circulation.
Impact
An attacker could mint an amount exceeding 10% of the total circulation when circulation is at least 10,000,000, potentially disrupting the intended economic safeguards, though the judge noted it does not directly lead to asset loss or theft.
What the attacker needed
Circulation >= 10,000,000
The fix
The mint function should be modified to revert if the mint amount exceeds 10% of the total circulation when circulation is at least 10,000,000.
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 for a stablecoin. The code comments say that once a lot of the stablecoin is in circulation, no single person should be able to mint more than 10% of it at once. But the code never actually enforces that rule, so someone could mint a very large amount in one go.
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.