Frankencoin - Diana'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: 96/199

Findings: 1

Award: $28.28

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: Josiah

Also found by: 0xDACA, Diana, Emmanuel, Kumpa, Nyx, RaymondFam, Ruhum, __141345__, bin2chen, carlitox477, lil_eth, nobody2018, rbserver

Labels

bug
2 (Med Risk)
satisfactory
duplicate-932

Awards

28.2764 USDC - $28.28

External Links

Lines of code

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

Vulnerability details

Impact

Wrong value is returned for function reduceLimitForClone().

As per the natspec comment, reduceLimitForClone() should return the limit for the clone which is calculated as limit -= reduction + _minimum;, however the function wrongly returns the value reduction + _minimum

Due to this, when clonePosition() would be executed in MintingHub.sol, the wrong value will be set for limit at MintingHub.sol#L126:

uint256 limit = existing.reduceLimitForClone(_initialMint);

Proof of Concept

As per the natspec comment at Position.sol#L95, the function should return limit for the clone, which is calculated at Position.sol#L99

limit -= reduction + _minimum;

The new limit value should now be:

limit = limit - reduction + _minimum

However, the function wrongly returns the value of reduction + _minimum instead of limit at Position.sol#L100

return reduction + _minimum;

Due to this, when clonePosition() would be executed in MintingHub.sol#L126, the wrong value will be set for limit:

uint256 limit = existing.reduceLimitForClone(_initialMint);

Tools Used

Manual review

function reduceLimitForClone(uint256 _minimum) external noChallenge noCooldown alive onlyHub returns (uint256) {
        uint256 reduction = (limit - minted - _minimum)/2; // this will fail with an underflow if minimum is too high
        limit -= reduction + _minimum;
-        return reduction + _minimum;
+        return limit;
    }

#0 - c4-pre-sort

2023-04-24T19:55:33Z

0xA5DF marked the issue as duplicate of #932

#1 - c4-judge

2023-05-18T13:58:21Z

hansfriese marked the issue as satisfactory

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