Skip to content
Business logic Audit finding Beginner

Incorrect event name

jasonxiale Follow

Originally disclosed on Immunefi

Informational View original
  • Disclosed after under an hour

#35999 [SC-Insight] Incorrect event name

Submitted on Oct 15th 2024 at 13:58:05 UTC by @jasonxiale for IOP | Swaylend

Description

Brief/Intro

While `Market.add_collateral_asset` is called and configuration.asset_id has already been in the system, an event named `Error::UnknownAsset` is emitted in main.sw#L148-L155, however this is incorrect. An event named `Error::AssetAlreadyExist` should be more proper

Especially this should be different from `Error::UnknownAsset` in main.sw#L224, because `Error::UnknownAsset` in Market.update_collateral_asset is used as the asset doesn't exist.

Vulnerability Details

```Rust 171 fn add_collateral_asset(configuration: CollateralConfiguration) { 172 // Only owner can add new collateral asset 173 only_owner(); 174 175 // Check if asset already exists 176 require( 177 storage 178 .collateral_configurations 179 .get(configuration.asset_id) 180 .try_read() 181 .is_none(), 182 Error::UnknownAsset, 183 ); 184 185 storage 186 .collateral_configurations 187 .insert(configuration.asset_id, configuration); 188 storage 189 .collateral_configurations_keys 190 .push(configuration.asset_id); 191 192 log(CollateralAssetAdded { 193 asset_id: configuration.asset_id, 194 configuration, 195 }); 196 } ```

Impact Details

incorrect event name

References

Add any relevant links to documentation or code

Proof of Concept

Proof of Concept

The following code will emit the event ```Rust 171 fn add_collateral_asset(configuration: CollateralConfiguration) { 172 // Only owner can add new collateral asset 173 only_owner(); 174 175 // Check if asset already exists 176 require( 177 storage 178 .collateral_configurations 179 .get(configuration.asset_id) 180 .try_read() 181 .is_none(), 182 Error::UnknownAsset, 183 ); 184 185 storage 186 .collateral_configurations 187 .insert(configuration.asset_id, configuration); 188 storage 189 .collateral_configurations_keys 190 .push(configuration.asset_id); 191 192 log(CollateralAssetAdded { 193 asset_id: configuration.asset_id, 194 configuration, 195 }); 196 } ```

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

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

What is known

A business logic bug in https://github.com/Swaylend/swaylend-monorepo/blob/9132747331188b86dd8cbf9a1ca37b811d08dddb/contracts/market/src/main.sw. Immunefi made it public on 15 October 2024.

About Business logic

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

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 jasonxiale

View all

25 more disclosed reports, best first.

More from Swaylend

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.