Canto Application Specific Dollars and Bonding Curves for 1155s - sl1's results

Tokenizable bonding curves using a Stablecoin-as-a-Service token

General Information

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

Canto

Findings Distribution

Researcher Performance

Rank: 84/120

Findings: 1

Award: $4.08

QA:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

4.0797 USDC - $4.08

Labels

bug
downgraded by judge
grade-b
QA (Quality Assurance)
edited-by-warden
duplicate-124
Q-27

External Links

Lines of code

https://github.com/code-423n4/2023-11-canto/blob/335930cd53cf9a137504a57f1215be52c6d67cb3/1155tech-contracts/src/Market.sol#L114-L127

Vulnerability details

Impact

In order to create a share a user has to call createNewShare() passing shareName, bondingCurve and URI. Currently there exists a check that does not allow creating shares with the same name.

require(shareIDs[_shareName] == 0, "Share already exists");

If the share with the name passed already exists, the tx will simply revert. This approach creates a way for a malicious user to DoS anyone from creating a new share. An attacker can monitor mempool for transactions to createNewShare() and front-run them passing shareName from the original tx. The attacker will only have to pay gas for the transaction, and he can do it indefinetely. The impact would be inability to interact with the core function of the contract. Yes, there is a way to restrict the creation of shares, but that would require never turning it off and manually whitelisting users to allow them to create a share. It will prevent the protocol from ever being permissionless.

POC

 function createNewShare(
        string memory _shareName,
        address _bondingCurve,
        string memory _metadataURI
    ) external onlyShareCreator returns (uint256 id) {
        require(whitelistedBondingCurves[_bondingCurve], "Bonding curve not whitelisted");
        require(shareIDs[_shareName] == 0, "Share already exists"); <----- @audit
        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);
    }

Tools Used

Manual review

The possible solution is to get rid of this check, allowing creation of the shares with the same name. It may not be a problem, as every function in the contract is quering a share by its id, not name. Alternatively, introduce a fee to createNewShare function, so the user would be required to pay for the creation, this way it will disincentivize the attacker from DoS'ing this function.

Assessed type

DoS

#0 - c4-pre-sort

2023-11-18T16:29:31Z

minhquanym marked the issue as duplicate of #124

#1 - c4-judge

2023-11-29T00:41:47Z

MarioPoneder changed the severity to QA (Quality Assurance)

#2 - c4-judge

2023-11-29T22:43:30Z

MarioPoneder marked the issue as grade-b

#3 - kazantseff

2023-12-01T18:49:40Z

@MarioPoneder - Thank you for judging this contest. I would like to add more context to this issue and raise some concerns.

I understand that the incentives for this attack are limited, but the cost of the attack is in fact low for the protocol deployed on Canto blockchain and even more negligible for the protocol deployed on a different blockchain, take Polygon for example. If we calculate the approximate cost of createNewShare transaction on Canto, it will be around 0.05$ per tx, which will yield roughly 5$ per 100 transactions. In comparison if the protocol deployed on Polygon, an attacker would have to spend only around 6$ to DoS a 1000 transactions. This in my opinion could potentially justify the concern that limited incentivies with a low attack cost may still pose a threat to the availability of the system. The impact is not just wasted gas on the side of the user, but the damage to the availability of the protocol. As i’ve stated in my submission, it can prevent protocol from being permisionless either because the attacker will decide who can create shares, or force the protocol to be in restricted state such that only whitelisted users can participate. I believe this is a potential risk and that it is imporant to ensure protocol availability cannot be negatively impacted by any malicious actors.

I would appreciate your perspective on the matter and a reconsideration of the severity of the issue.

Thank you for your time, kind regards.

#4 - MarioPoneder

2023-12-04T12:23:51Z

Thank your for your comment!

I acknowledge the validity of your concerns. In the end it all boils down to where to set the bar for Medium severity findings.

My my perspective:

  • The incentive / potential gain for an attacker to do this, is very limited.
  • The damage that is done by this is limited.
  • There is a potential - already built-in - workaround via whitelisting
  • Awarding this finding with Medium severity would be unfair and inconsistent if compared with many other submissions and their impacts that have been downgraded to QA.

#5 - kazantseff

2023-12-04T12:28:15Z

@MarioPoneder - I understand and grateful for your opinion!

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter