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
The balance.move module restricts the maximum supply of a coin to 18,446,744,073,709,551,614u64, but the coin_manager.move module allows a maximum supply of 18,446,744,073,709,551,615u64 when no specific limit is set. This inconsistency in the definition of the maximum supply can lead to logic conflicts.
Vulnerability Detail
In the balance.move module, the increase_supply function ensures that the total supply does not exceed 18,446,744,073,709,551,614u64 by using the following check:
This discrepancy affects multiple functions in coin_manager.move that rely on the maximum_supply value for minting operations, including:
mint: Validates the total supply plus the minted value against maximum_supply.
mint_balance: Performs a similar check before minting a Balance<T>.
available_supply: Computes the remaining supply available for minting.
Impact
The two modules enforce different maximum supply limits, leading to confusion and potential errors in contract logic.
Code Snippet
Balance.move
/// Increase supply by `value` and create a new `Balance<T>` with this value.publicfunincrease_supply<T>(self: &mutSupply<T>, value: u64): Balance<T> {
@>> assert!(value < (18446744073709551615u64 - self.value), EOverflow);
self.value = self.value + value;
Balance { value }
}
Coin_manager.move
/// Get the maximum supply possible as a number. /// If no maximum set it's the maximum u64 possiblepublicfunmaximum_supply<T>(manager: &CoinManager<T>): u64 {
@>> option::get_with_default(&manager.maximum_supply, 18_446_744_073_709_551_615u64)
}
/// Convenience function returning the remaining supply that can be minted stillpublicfunavailable_supply<T>(manager: &CoinManager<T>): u64 {
maximum_supply(manager) - total_supply(manager)
}
/// Get the maximum supply possible as a number.
/// If no maximum set it's the maximum u64 possible
public fun maximum_supply<T>(manager: &CoinManager<T>): u64 {
- option::get_with_default(&manager.maximum_supply, 18_446_744_073_709_551_615u64)+ option::get_with_default(&manager.maximum_supply, 18_446_744_073_709_551_614u64)
}
Also enforce a check in enforce_maximum_supply function.
The text was updated successfully, but these errors were encountered:
FROM THE AUDIT:
The text was updated successfully, but these errors were encountered: