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.
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
- https://github.com/Swivel-Finance/gost/blob/5fb7ad62f1f3a962c7bf5348560fe88de0618bae/test/marketplace/MarketPlace.sol#L65
- https://github.com/Swivel-Finance/gost/blob/5fb7ad62f1f3a962c7bf5348560fe88de0618bae/test/marketplace/MarketPlace.sol#L53-L70
Tools Used
Manual Analysis
Recommended Mitigation Steps
Add a zero-address check for markets\[u]\[m] in createMarket before writing to it
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.