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 functions update_name, update_symbol, update_description, and update_icon_url in the CoinManager incorrectly enforce an immutable metadata check, preventing updates to mutable metadata.
Vulnerability Detail
The metadata_is_immutable function in the CoinManager determines whether metadata is immutable based on two conditions:
The function incorrectly evaluates to true if either metadata_immutable is set to true or immutable_metadata contains a value (Some). This logic is used in the update_name, update_symbol, update_description, and update_icon_url functions as follows:
public fun update_name<T>(
_:&CoinManagerMetadataCap<T>,
manager:&mut CoinManager<T>,
name: string::String){assert!(manager.metadata_is_immutable(),ENoMutableMetadata);// Incorrect check
coin::update_name(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), name)}
The assertion expects metadata_is_immutable to return false for updates to proceed. However, due to the flawed logic, the function blocks updates even when metadata is mutable. The same logic error applies to the other mentioned functions.
Prevents Legitimate Updates: Metadata updates fail unnecessarily even when updates should be allowed, disrupting intended functionality.
Code Snippet
// === Update coin metadata ===/// Update the `name` of the coin in the `CoinMetadata`.publicfunupdate_name<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mutCoinManager<T>,
name: string::String
) {
@>> assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_name(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), name)
}
/// Update the `symbol` of the coin in the `CoinMetadata`.publicfunupdate_symbol<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mutCoinManager<T>,
symbol: ascii::String
) {
@>> assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_symbol(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), symbol)
}
/// Update the `description` of the coin in the `CoinMetadata`.publicfunupdate_description<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mutCoinManager<T>,
description: string::String
) {
@>> assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_description(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), description)
}
/// Update the `url` of the coin in the `CoinMetadata`publicfunupdate_icon_url<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mutCoinManager<T>,
url: ascii::String
) {
@>> assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_icon_url(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), url)
}
Tool used
Manual Review
Recommendation
// === Update coin metadata ===
/// Update the `name` of the coin in the `CoinMetadata`.
public fun update_name<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mut CoinManager<T>,
name: string::String
) {
- assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_name(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), name)
}
/// Update the `symbol` of the coin in the `CoinMetadata`.
public fun update_symbol<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mut CoinManager<T>,
symbol: ascii::String
) {
- assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_symbol(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), symbol)
}
/// Update the `description` of the coin in the `CoinMetadata`.
public fun update_description<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mut CoinManager<T>,
description: string::String
) {
- assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_description(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), description)
}
/// Update the `url` of the coin in the `CoinMetadata`
public fun update_icon_url<T>(
_: &CoinManagerMetadataCap<T>,
manager: &mut CoinManager<T>,
url: ascii::String
) {
- assert!(manager.metadata_is_immutable(), ENoMutableMetadata);
coin::update_icon_url(&manager.treasury_cap, option::borrow_mut(&mut manager.metadata), url)
}
The text was updated successfully, but these errors were encountered:
FROM THE AUDIT:
The text was updated successfully, but these errors were encountered: