Skip to content
Business logic Audit finding Beginner

Beneficiary cant get fairSideConviction NFT unless they only claim once, and only after it’s fully vested

The vesting contract only transfers the conviction NFT if the final claim amount equals the total vesting amount, so a beneficiary who makes any earlier claim can never receive the NFT. An attacker (or any beneficiary) could permanently lose access to the NFT by claiming in multiple transactions.

WatchPug Follow

Originally disclosed on Code4rena

Submitted by WatchPug, also found by cmichel

Based on the context, once the beneficiary claimed all their vesting tokens, they should get the fairSideConviction NFT.

However, in the current implementation, if the beneficiary has claimed any amounts before it’s fully vested, then they will never be able to get the fairSideConviction NFT, because at L138, it requires the tokenbClaim to be equal to the initial vesting amount.

FSDVesting.sol L124-L142

function claimVestedTokens() external override onlyBeneficiary {
    uint256 tokenClaim = calculateVestingClaim();
    require(
        tokenClaim > 0,
        "FSDVesting::claimVestedTokens: Zero claimable tokens"
    );

    totalClaimed = totalClaimed.add(tokenClaim);
    lastClaimAt = block.timestamp;

    fsd.safeTransfer(msg.sender, tokenClaim);

    emit TokensClaimed(msg.sender, tokenClaim, block.timestamp);

    if (amount == tokenClaim) {
        uint256 tokenId = fsd.tokenizeConviction(0);
        fairSideConviction.transferFrom(address(this), msg.sender, tokenId);
    }
}

Recommendation

Change to:

function claimVestedTokens() external override onlyBeneficiary {
    uint256 tokenClaim = calculateVestingClaim();
    require(
        tokenClaim > 0,
        "FSDVesting::claimVestedTokens: Zero claimable tokens"
    );

    totalClaimed = totalClaimed.add(tokenClaim);
    lastClaimAt = block.timestamp;

    fsd.safeTransfer(msg.sender, tokenClaim);

    emit TokensClaimed(msg.sender, tokenClaim, block.timestamp);

    if (amount == totalClaimed) {
        uint256 tokenId = fsd.tokenizeConviction(0);
        fairSideConviction.transferFrom(address(this), msg.sender, tokenId);
    }
}

YunChe404 (FairSide) confirmed and disagreed with severity

The original report as published on Code4rena, by WatchPug. 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 condition for transferring the NFT compares the current claim amount to the total vesting amount, rather than comparing the cumulative total claimed to the total vesting amount.

What the attacker needed

Beneficiary claims tokens before full vesting

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.

A vesting contract gradually releases tokens to a beneficiary. The contract also promises a special NFT once all tokens are claimed. The bug is that the contract checks if the current claim equals the total amount, instead of checking if the total claimed so far equals the total amount. So if you claim in parts, you never get the NFT.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by WatchPug

View all

197 more disclosed reports, best first.

More from FairSide contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.