Skip to content
Smart contracts Audit finding Beginner

Function restructureCapTable() in Equity.sol not functioning as expected

The restructureCapTable function in Equity.sol always reads the first element of the addressesToWipe array inside its loop instead of the current index. As a result only the first address's tokens are burned, and the call reverts once that address has a zero balance while other addresses remain.

decade Follow with MiloTruck, EloiManuel and 48 others

Originally disclosed on Code4rena

Submitted by decade, also found by MiloTruck, EloiManuel, juancito, lukino, joestakey, ak1, 0xkaju, karanctf, silviaxyz, Aymen0909, rbserver, giovannidisiena, Arz, Udsen, marwen, 0xDACA, carrotsmuggler, Satyam_Sharma, Jerry0x, zhuXKET, BPZ, kenta, zzebra83, Kek, Lalanda, bin2chen, PNS, lil_eth, Mukund, peakbolt, circlelooper, Jiamin, John, parlayan_yildizlar_takimi, cccz, rvierdiiev, Tricko, Juntao, ladboy233, anodaram, jasonxiale, nobody2018, Ruhum, markus_ether, 0x3b, 0xWeiss, HaCk0, J4de, kodyvim, volodya, deadrxsezzz, ToonVH, RedTiger, mrpathfindr, ravikiranweb3, and 0xWaitress

Incorrect typo in function restructureCapTable() leading to only burning tokens of first address of addressToWipe array argument.

Proof of Concept

Here, in L313, addressToWipe[0] only takes first address of the array. While ignoring the rest and also since first address’s tokens are burned it will fail addressesToWipe array has more than one addresses.

    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));
        }
    }

Recommended Mitigation Steps

Change address current = addressesToWipe[0]; ==> address current = addressesToWipe[i];

luziusmeisser (Frankencoin) confirmed


The original report as published on Code4rena, by decade. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The loop indexes the addressesToWipe array with a hard-coded 0 instead of the loop counter i, so the same first address is processed repeatedly.

Impact

The cap table cannot be restructured for more than one holder: only the first address's tokens are burned and the call reverts when that address's balance is already zero, so the intended wipe of the remaining addresses never happens.

What the attacker needed

Equity below MINIMUM_EQUITY; caller passes checkQualified; more than one address to wipe

The fix

The loop should read the current index of the array rather than always the first element, and the report notes the project confirmed the issue.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

This is a smart contract that lets a qualified caller wipe out shareholders' equity tokens when the system's equity falls too low. The code is meant to loop over a list of addresses and burn each one's tokens, but it keeps picking the first item of the list every time instead of moving through the list. So only the first person's tokens get burned, and the transaction fails if more than one address is supplied.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More from Frankencoin

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.