code-423n4 / 2023-04-frankencoin-findings

5 stars 4 forks source link

The contract can not restructure the cap table due to the iteration is wrong. #909

Closed code423n4 closed 1 year ago

code423n4 commented 1 year ago

Lines of code

https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/Equity.sol#L309-L316

Vulnerability details

Impact

Due to the wrong iteration code, the contract can not restructure the system.

Proof of Concept

In this line of the contract https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/Equity.sol#L313

    address current = addressesToWipe[0];

the code won't work as intended due to code is getting addressesToWipe variable's first index in every iteration.

    function restructureCapTable(address[] calldata helpers, address[] calldata addressesToWipe) public {
        require(zchf.equity() < MINIMUM_EQUITY);
        checkQualified(msg.sender, helpers);
        for (uint256 i = 0; i<addressesToWipe.length; i++){
            address current = addressesToWipe[0];
            _burn(current, balanceOf(current));
        }
    }

Tools Used

Manual

Recommended Mitigation Steps

The correct code for this line: https://github.com/code-423n4/2023-04-frankencoin/blob/1022cb106919fba963a89205d3b90bf62543f68f/contracts/Equity.sol#L313

Would be:

    address current = addressesToWipe[i];
    function restructureCapTable(address[] calldata helpers, address[] calldata addressesToWipe) public {
        require(zchf.equity() < MINIMUM_EQUITY);
        checkQualified(msg.sender, helpers);
        for (uint256 i = 0; i<addressesToWipe.length; i++){
            address current = addressesToWipe[i];
            _burn(current, balanceOf(current));
        }
    }
c4-pre-sort commented 1 year ago

0xA5DF marked the issue as duplicate of #941

c4-judge commented 1 year ago

hansfriese changed the severity to 2 (Med Risk)

c4-judge commented 1 year ago

hansfriese marked the issue as satisfactory