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: 72/120
Findings: 1
Award: $4.08
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: chaduke
Also found by: 0xpiken, Bauchibred, Matin, MohammedRizwan, MrPotatoMagic, OMEN, Pheonix, SandNallani, T1MOH, Topmark, ZanyBonzy, adriro, aslanbek, ayden, bareli, bart1e, bin2chen, btk, cheatc0d3, codynhat, critical-or-high, d3e4, erebus, firmanregar, hunter_w3b, jasonxiale, kaveyjoe, ksk2345, lsaudit, max10afternoon, merlinboii, nailkhalimov, osmanozdemir1, peanuts, pep7siup, pontifex, sbaudh6, shenwilly, sl1, tourist, wisdomn_, young, zhaojie
4.0797 USDC - $4.08
https://github.com/code-423n4/2023-11-canto/blob/335930cd53cf9a137504a57f1215be52c6d67cb3/asD/src/asDFactory.sol#L25 https://github.com/code-423n4/2023-11-canto/blob/335930cd53cf9a137504a57f1215be52c6d67cb3/1155tech-contracts/src/Market.sol#L123
The _cNote
parameter in asD contract's constructor and _bondingCurve
parameter in Market contact's createNewShare function are not checked for zero value.
The asD contract addresses will be stored in asDFactory's isAsD mapping. The shares will be stored in shareIDs and shareData mappings. There are no functionality to update/remove for both of the parameters.
The Canto team confirmed by private DM that the mappings will be used by off-chain applicatons (frontend) to show the data to the user. Most of the off-chain applications will read the data from mappings without checking for zero values for cNote and bondingCurve parameters, which will lead to unnecessary gas usage from users, because many of the functions will revert.
I am adding it as a Medium risk, because of this paragraph from Code4rena docs: "2 — Med: Assets not at direct risk, but the function of the protocol or its availability could be impacted..."
The test case is for asD's mint function, but gas usage will be similar or more for other functions.
contract asDFactory is Test { asD asdToken; asD asdTokenZeroCNote; ...
function setUp() public { ... asdTokenZeroCNote = new asD( asDName, asDSymbol, owner, address(0x0), owner ); uint256 mintAmount = 10e18; NOTE.mint(address(this), mintAmount); NOTE.approve(address(asdTokenZeroCNote), mintAmount);
function testMintZeroCNote() public { asdTokenZeroCNote.mint(10e18); }
Run only the new test case with forge test --match-test "testMintZeroCNote"
Test result:
Running 1 test for src/test/asD.t.sol:asDFactory [FAIL. Reason: EvmError: Revert] testMintZeroCNote() (gas: 8647) Test result: FAILED. 0 passed; 1 failed; 0 skipped; finished in 2.06ms Ran 1 test suites: 0 tests passed, 1 failed, 0 skipped (1 total tests)
Foundry, Manual review
Add zero address check for both of the parameters.
Invalid Validation
#0 - c4-pre-sort
2023-11-20T15:42:13Z
minhquanym marked the issue as insufficient quality report
#1 - minhquanym
2023-11-20T15:43:01Z
QA
#2 - c4-judge
2023-11-29T16:09:00Z
MarioPoneder changed the severity to QA (Quality Assurance)
#3 - MarioPoneder
2023-11-29T16:09:51Z
Valid QA, but insufficient impact for Med
#4 - c4-judge
2023-11-29T22:36:31Z
MarioPoneder marked the issue as grade-b