Skip to content
Business logic Audit finding Beginner

Previously created markets can be overwritten

The createMarket function lacks a check for an existing market, allowing a previously created market for the same underlying and maturity to be overwritten. An attacker could accidentally or maliciously replace a legitimate market, potentially disrupting the protocol.

0xRajeev Follow

Originally disclosed on Code4rena

Submitted by 0xRajeev, also found by 0xsanson, cmichel, gpersoon, itsmeSTYJ, and pauliax.

Impact

The createMarket function allows accidental overwriting of previously created markets for the same combination of underlying and maturity timestamp (u, m) because there is no zero-address check to see if a previously created market exists for that combination.

Proof of Concept

Tools Used

Manual Analysis

Recommended Mitigation Steps

Add a zero-address check for markets\[u]\[m] in createMarket before writing to it

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

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

Likely, the createMarket function writes to a storage mapping without first verifying that the entry is empty (zero address), so any existing market for the same key is silently overwritten.

Impact

A previously created market could be overwritten, potentially disrupting the protocol or causing loss of funds for users relying on the original market.

What the attacker needed

None

The fix

Add a zero-address check for markets[u][m] in createMarket before writing to it.

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.

A smart contract function that creates new markets does not check if a market already exists for the same pair of assets and expiry date. This means someone could call it again and replace the existing market, which could cause confusion or loss of funds.

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 0xRajeev

View all

61 more disclosed reports, best first.

More from Swivel v3 contest

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.