You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
GoodDollarExpansionController::mintUBIFromReserveBalance() will always revert or misbehave for reserveAssets with less than 18 decimals.
Summary
GoodDollarExpansionController::mintUBIFromReserveBalance() does not normalise the contractReserveBalance to 18 decimals making the function unusable for reserveAssets with less than 18 decimals since it will always revert or misbehave.
Root Cause
In GoodDollarExpansionController::mintUBIFromReserveBalance(), there is no normalisation to 18 decimals for the contractReserveBalance which will be in the native decimals of the ERC20. However, the reserveBalance of the PoolExchangeis normalised to 18 decimals. The subtraction of them will, most likely, result to the transaction to be reverted since it will try to do e6 - e18. As we can see in the implementation:
function mintUBIFromReserveBalance(bytes32exchangeId) externalreturns (uint256amountMinted) {
IBancorExchangeProvider.PoolExchange memory exchange =IBancorExchangeProvider(address(goodDollarExchangeProvider))
.getPoolExchange(exchangeId);
// @> uint256 contractReserveBalance = IERC20(exchange.reserveAsset).balanceOf(reserve);// @> uint256 additionalReserveBalance = contractReserveBalance - exchange.reserveBalance;if (additionalReserveBalance >0) {
amountMinted = goodDollarExchangeProvider.mintFromInterest(exchangeId, additionalReserveBalance);
IGoodDollar(exchange.tokenAddress).mint(address(distributionHelper), amountMinted);
// Ignored, because contracts only interacts with trusted contracts and tokens// slither-disable-next-line reentrancy-eventsemitInterestUBIMinted(exchangeId, amountMinted);
}
}
As we can see the subtraction tries to subtract a normalised amount(exchange.reserveBalance) from a non normalised amount in native decimals ( contractReserveBalance). It is, almost, sure that it will revert or misbehave.
Internal pre-conditions
The reserveAsset of the PoolExchange to have less than 18 decimals, which is very likely and that's way Mento has introduced the tokenPrecisionMultipliers mapping on BancorExchangeProvider.
External pre-conditions
Someone to call GoodDollarExpansionController::mintUBIFromReserveBalance(), in order to mint UBI (G$ tokens) from the additionalReserveBalance of reserve contract.
Attack Path
1.PoolExchange with a reserveAsset with less than 18 decimals is created (6 decimals for example). This is expected from Mento and that's why the tokenPrecisionMultipliers have been introduced in GoodDollarExchangeProvider.
2. GoodDollarExpansionController::mintUBIFromReserveBalance() function get called so to mint some G$ from the reserve balance.
3. The transaction will revert and the functionality is unusable for ever.
Impact
The impact of this bug is that mintUBIFromReserveBalance() functionality will be broken for exchanges with reserveAsset with less than 18 decimals, and there will be absolutely no way to mint UBI from the excess balance of Reserve contract. This is one of the main functionalities of the GoodDollarExpansionController and it will be broken for all assets which don't have 18 decimals.
PoC
No response
Mitigation
To mitigate successfully this vulnerability, normalise the contractReserveBalance to 18 decimals before the subtraction with exchange.reserveBalance .
The text was updated successfully, but these errors were encountered:
sherlock-admin3
changed the title
Gorgeous Fossilized Caribou - GoodDollarExpansionController::mintUBIFromReserveBalance() will always revert or misbehave for reserveAssets with less than 18 decimals.
zarkk01 - GoodDollarExpansionController::mintUBIFromReserveBalance() will always revert or misbehave for reserveAssets with less than 18 decimals.
Nov 5, 2024
zarkk01
High
GoodDollarExpansionController::mintUBIFromReserveBalance()
will always revert or misbehave forreserveAsset
s with less than 18 decimals.Summary
GoodDollarExpansionController::mintUBIFromReserveBalance()
does not normalise thecontractReserveBalance
to 18 decimals making the function unusable forreserveAsset
s with less than 18 decimals since it will always revert or misbehave.Root Cause
In
GoodDollarExpansionController::mintUBIFromReserveBalance()
, there is no normalisation to 18 decimals for thecontractReserveBalance
which will be in the native decimals of the ERC20. However, thereserveBalance
of thePoolExchange
is normalised to 18 decimals. The subtraction of them will, most likely, result to the transaction to be reverted since it will try to doe6 - e18
. As we can see in the implementation:Link to code
As we can see the subtraction tries to subtract a normalised amount(
exchange.reserveBalance
) from a non normalised amount in native decimals (contractReserveBalance
). It is, almost, sure that it will revert or misbehave.Internal pre-conditions
reserveAsset
of thePoolExchange
to have less than 18 decimals, which is very likely and that's wayMento
has introduced thetokenPrecisionMultipliers
mapping onBancorExchangeProvider
.External pre-conditions
GoodDollarExpansionController::mintUBIFromReserveBalance()
, in order to mint UBI (G$
tokens) from theadditionalReserveBalance
ofreserve
contract.Attack Path
1.
PoolExchange
with areserveAsset
with less than 18 decimals is created (6 decimals for example). This is expected fromMento
and that's why thetokenPrecisionMultipliers
have been introduced inGoodDollarExchangeProvider
.2.
GoodDollarExpansionController::mintUBIFromReserveBalance()
function get called so to mint someG$
from the reserve balance.3. The transaction will revert and the functionality is unusable for ever.
Impact
The impact of this bug is that
mintUBIFromReserveBalance()
functionality will be broken forexchanges
withreserveAsset
with less than 18 decimals, and there will be absolutely no way to mint UBI from the excess balance ofReserve
contract. This is one of the main functionalities of theGoodDollarExpansionController
and it will be broken for all assets which don't have 18 decimals.PoC
No response
Mitigation
To mitigate successfully this vulnerability, normalise the
contractReserveBalance
to 18 decimals before the subtraction withexchange.reserveBalance
.The text was updated successfully, but these errors were encountered: