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

Upgraded Q -> 2 from #481 [1706648292480] #1280

Closed
c4-judge opened this issue Jan 30, 2024 · 2 comments
Closed

Upgraded Q -> 2 from #481 [1706648292480] #1280

c4-judge opened this issue Jan 30, 2024 · 2 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value duplicate-994 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@c4-judge
Copy link
Contributor

Judge has assessed an item in Issue #481 as 2 risk. The relevant finding follows:

5, Attacker can front run distribute reward from GUILD token and steal newly added rewards

Lines of code

https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/main/src/loan/SurplusGuildMinter.sol#L114-#L212

Vulnerability details

Every time the notifyPnL() get called, if in the config, there is a part of token distribute for guild, there will be credit token distribute for guild holder:

        if (amountForGuild != 0) {
            uint256 _gaugeWeight = uint256(GuildToken(guild).getGaugeWeight(gauge));
            if (_gaugeWeight != 0) {
                uint256 _gaugeProfitIndex = gaugeProfitIndex[gauge];
                if (_gaugeProfitIndex == 0) {
                    _gaugeProfitIndex = 1e18;
                }
                gaugeProfitIndex[gauge] = _gaugeProfitIndex + (amountForGuild * 1e18) / _gaugeWeight;
            }

This enables a well-known attack vector, in which the attacker will deposit peg token to get credit token, stake them and unstake right after claim reward.

Impact

Not everytime user can claim reward and get profit like this, it depend alot about other factor: total credit token can be minted by RateLimitedMinter, total profit gained, ....., but the attack effectively steal the part of the newly added rewards

Recommendation

Reward distribute by staking guild token should be distributed like credit token rebasing,

@c4-judge c4-judge added the 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value label Jan 30, 2024
@c4-judge
Copy link
Contributor Author

Trumpero marked the issue as duplicate of #994

@c4-judge
Copy link
Contributor Author

Trumpero marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value duplicate-994 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

1 participant