Frankencoin - Satyam_Sharma's results

A decentralized and fully collateralized stablecoin.

General Information

Platform: Code4rena

Start Date: 12/04/2023

Pot Size: $60,500 USDC

Total HM: 21

Participants: 199

Period: 7 days

Judge: hansfriese

Total Solo HM: 5

Id: 231

League: ETH

Frankencoin

Findings Distribution

Researcher Performance

Rank: 170/199

Findings: 2

Award: $21.10

Gas:
grade-b

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Equity.sol#L313

Vulnerability details

Impact

Address to wipeout will never be called instead only 0 index address will be called again and again, since the address index will not called ever address will remain their forever and never get deleted.

Proof of Concept

Equity.restructureCapTable is using only one address to wipeout from addressesToWipe array instead it should use variable i that fetches address for each index under addressesToWipe arrat to wipe out.

https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Equity.sol#L313

address current = addressesToWipe[0];

Tools Used

Use variable i instead hardedcoded index.

#0 - c4-pre-sort

2023-04-20T14:16:32Z

0xA5DF marked the issue as duplicate of #941

#1 - c4-judge

2023-05-18T14:23:23Z

hansfriese marked the issue as satisfactory

1. gas optimization

under bid function expectedSize should be used instead using challenge.size which saves gas , since using challenge.size directly from storage is expensive and since it checks whether expectedSize equals to challenge.size then only it proceeds to the below code therefore we can use expectedSize instead challenge.size.

https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/MintingHub.sol#L208-L212

if (challenge.position.tryAvertChallenge(challenge.size, _bidAmountZCHF)) {//@audit using expectedSize instead challenge.size save us gas // bid was high enough, let bidder buy collateral from challenger zchf.transferFrom(msg.sender, challenge.challenger, _bidAmountZCHF); challenge.position.collateral().transfer(msg.sender, challenge.size);//@audit using expectedSize instead challenge.size save us gas emit ChallengeAverted(address(challenge.position), _challengeNumber); delete challenges[_challengeNumber];

2.gas optimization

Under frankencoin.suggestMinter totalsupply() is checked two times, which can be expensive as Every time totalSupply() is called, it requires a read operation from the blockchain state which consumes gas.

https://github.com/code-423n4/2023-04-frankencoin/blob/main/contracts/Frankencoin.sol#L84-L85

if (_applicationPeriod < MIN_APPLICATION_PERIOD && totalSupply() > 0) revert PeriodTooShort(); if (_applicationFee < MIN_FEE && totalSupply() > 0) revert FeeTooLow();

Check under one condition is sufficient since is uses && operator which only proceeds the code further if both the conditions are right.

#0 - c4-judge

2023-05-16T13:32:31Z

hansfriese marked the issue as grade-b

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