Platform: Code4rena
Start Date: 13/11/2023
Pot Size: $24,500 USDC
Total HM: 3
Participants: 120
Period: 4 days
Judge: 0xTheC0der
Id: 306
League: ETH
Rank: 93/120
Findings: 1
Award: $1.37
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: rvierdiiev
Also found by: 0x175, 0x3b, 0xMango, 0xarno, 0xpiken, Bauchibred, DarkTower, ElCid, Giorgio, HChang26, Kose, KupiaSec, Madalad, PENGUN, Pheonix, RaoulSchaffranek, SpicyMeatball, T1MOH, Tricko, Udsen, Yanchuan, aslanbek, ast3ros, bart1e, bin2chen, chaduke, d3e4, deepkin, developerjordy, glcanvas, inzinko, jasonxiale, jnforja, mahyar, max10afternoon, mojito_auditor, neocrao, nmirchev8, openwide, osmanozdemir1, peanuts, pep7siup, peritoflores, pontifex, rice_cooker, rouhsamad, t0x1c, tnquanghuy0512, turvy_fuzz, twcctop, ustas, vangrim, zhaojie, zhaojohnson
1.3743 USDC - $1.37
https://github.com/code-423n4/2023-11-canto/blob/main/1155tech-contracts/src/bonding_curve/LinearBondingCurve.sol#L14-L25 https://github.com/code-423n4/2023-11-canto/blob/main/1155tech-contracts/src/Market.sol#L150-L169 https://github.com/code-423n4/2023-11-canto/blob/main/1155tech-contracts/src/Market.sol#L174-L189
Because of the linear price increase(LinearBondingCurve) it can be really easy to manipulate the price for next buyer of the shares in the Market.
While sandwich attack is not a problem since the contracts will be deployed to Canto(l2 based on Polygon) there still a possibility of price manipulation attack which will affect user expenses and can be profitable for the malefactor.
**It also worth to mention that during the audit representative of the Canto team - Roman, mentioned that it is possible that this contract will be deployed on other chains. So potential sandwich attack vulnerability is also possible and should be addressed. https://discord.com/channels/810916927919620096/1172195122230853723/1173936821479161866 Roman(c) >> Application specific dollars will only be deployed on Canto. 1155tech may be deployed on other chains in the future (with a different payment token), but the current focus / plan is also the deployment on Canto
The simplest flow is an example where the shares creator is malefactor contract.
require(whitelistedBondingCurves[_bondingCurve], "Bonding curve not whitelisted"); require(shareIDs[_shareName] == 0, "Share already exists"); id = ++shareCount; shareIDs[_shareName] = id; shareData[id].bondingCurve = _bondingCurve; shareData[id].creator = msg.sender; shareData[id].metadataURI = _metadataURI; emit ShareCreated(id, _shareName, _bondingCurve, msg.sender);
require(shareData[_id].creator != msg.sender, "Creator cannot buy"); //@audit this check is nor enough for protection from current attack
for (uint256 i = shareCount; i < shareCount + amount; i++) { uint256 tokenPrice = priceIncrease * i; price += tokenPrice; fee += (getFee(i) * tokenPrice) / 1e18; }
After other users of the Market will buy enough shares the attacker will just sell everything and get a profit. Users buy next 100 tokens with price (100+1..100)*priceIncrease. Attacker sell 100 tokens with price (200-1..100)*priceIncrease. Profit will be the difference between price of last 100 tokens and first 100 tokens.
Because this early-start manipulation is possible for multiple shares it can be replicated many times.
Manual audit
Other
#0 - c4-pre-sort
2023-11-18T10:07:35Z
minhquanym marked the issue as duplicate of #12
#1 - c4-judge
2023-11-28T23:32:15Z
MarioPoneder marked the issue as satisfactory