Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remaining amount of yeildFeeBalance will be lost if the yeildFeeRecipient tries to withdraw partially. #62

Closed
c4-bot-10 opened this issue Mar 8, 2024 · 5 comments
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-59 🤖_10_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards sufficient quality report This report is of sufficient quality upgraded by judge Original issue severity upgraded from QA/Gas by judge

Comments

@c4-bot-10
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2024-03-pooltogether/blob/480d58b9e8611c13587f28811864aea138a0021a/pt-v5-vault/src/PrizeVault.sol#L611-L622

Vulnerability details

Impact

When the yeildFeeRecipient tries to claim some amount of yeildFeeBalance by calling the claimYieldFeeShares function it will mint the given amount of shares but the remaining yeildFeeBalance will also be deducted.
Which result in loss of yeildFees for the yeildFeeRecipient.

Proof of Concept

function claimYieldFeeShares(uint256 _shares) external onlyYieldFeeRecipient {
        if (_shares == 0) revert MintZeroShares();

        uint256 _yieldFeeBalance = yieldFeeBalance;
        if (_shares > _yieldFeeBalance) revert SharesExceedsYieldFeeBalance(_shares, _yieldFeeBalance);

        yieldFeeBalance -= _yieldFeeBalance;

        _mint(msg.sender, _shares);

        emit ClaimYieldFeeShares(msg.sender, _shares);
    }

If we look at the function it takes an argument uint256 _shares so it is clear that the caller(yeildFeeRecipient) has the choice to specify the amount of yieldFeeBalance he wants to claim.
However regardless of the given amount of _shares to claim, the function mints the given amount of _shares but will always deduct the full amount of yieldFeeBalance.

uint256 _yieldFeeBalance = yieldFeeBalance;

yieldFeeBalance -= _yieldFeeBalance;

        _mint(msg.sender, _shares);

It mints the given amount of shares but always deducts the full amount of yieldFeeBalance.

Since the underlying asset is not withdrawn and still in the yeildVault the assets are not directly lost. It goes back to the availableYeildBalance which will go to the pricePool. There might not be direct loss of assets but the yeildFeeRecipient clearly lost his collectible fees.

Tools Used

manual.

Recommended Mitigation Steps

Replace this line yieldFeeBalance -= _yieldFeeBalance; from the claimYieldFeeShares function with this : yieldFeeBalance -= _shares.

Or another approach would be to remove the parameter uint256 _shares and always mint the total amount of fees;
remove if (_shares > _yieldFeeBalance) revert SharesExceedsYieldFeeBalance(_shares, _yieldFeeBalance);
and change _mint(msg.sender, _shares); to _mint(msg.sender, _yieldFeeBalance);

Assessed type

Other

@c4-bot-10 c4-bot-10 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels Mar 8, 2024
c4-bot-4 added a commit that referenced this issue Mar 8, 2024
@c4-bot-12 c4-bot-12 added the 🤖_10_group AI based duplicate group recommendation label Mar 11, 2024
@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Mar 11, 2024
@c4-pre-sort
Copy link

raymondfam marked the issue as sufficient quality report

@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #10

@c4-pre-sort
Copy link

raymondfam marked the issue as duplicate of #59

@c4-judge c4-judge added 3 (High Risk) Assets can be stolen/lost/compromised directly upgraded by judge Original issue severity upgraded from QA/Gas by judge and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Mar 15, 2024
@c4-judge
Copy link
Contributor

hansfriese changed the severity to 3 (High Risk)

@c4-judge
Copy link
Contributor

hansfriese marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Mar 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working duplicate-59 🤖_10_group AI based duplicate group recommendation satisfactory satisfies C4 submission criteria; eligible for awards sufficient quality report This report is of sufficient quality upgraded by judge Original issue severity upgraded from QA/Gas by judge
Projects
None yet
Development

No branches or pull requests

4 participants