Ethereum Credit Guild - zhaojohnson's results

A trust minimized pooled lending protocol.

General Information

Platform: Code4rena

Start Date: 11/12/2023

Pot Size: $90,500 USDC

Total HM: 29

Participants: 127

Period: 17 days

Judge: TrungOre

Total Solo HM: 4

Id: 310

League: ETH

Ethereum Credit Guild

Findings Distribution

Researcher Performance

Rank: 91/127

Findings: 1

Award: $46.85

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

46.8502 USDC - $46.85

Labels

bug
3 (High Risk)
satisfactory
sufficient quality report
upgraded by judge
duplicate-1194

External Links

Lines of code

https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/governance/ProfitManager.sol#L409-L436

Vulnerability details

Impact

When users stake on one gauge by credit tokens at the first time, they can claim more rewards that expected.

Proof of Concept

When user try to stake on gauge A at the first time, GuildToken will try to claim existing rewards at first and then increase user's gauge weight. When we try to claim gauge rewards ,we should update userGaugeProfitIndex[user][gauge] to the latest index. However, when user stake on gauge at the first time, We do not have any weight on this gauge. This function will return 0 directly and not update userGaugeWeight to latest index.

After that, when the user want to claim rewards, the rewards will calculate rewards from 1e18(initial) to latest index. Users can claim more rewards that expected.

function claimGaugeRewards(
        address user,
        address gauge
    ) public returns (uint256 creditEarned) {
        uint256 _userGaugeWeight = uint256(
            GuildToken(guild).getUserGaugeWeight(user, gauge)
        );
        if (_userGaugeWeight == 0) {
            return 0;
        }
        uint256 _gaugeProfitIndex = gaugeProfitIndex[gauge];
        uint256 _userGaugeProfitIndex = userGaugeProfitIndex[user][gauge];
        if (_gaugeProfitIndex == 0) {
            _gaugeProfitIndex = 1e18;
        }
        if (_userGaugeProfitIndex == 0) {
            _userGaugeProfitIndex = 1e18;
        }
        uint256 deltaIndex = _gaugeProfitIndex - _userGaugeProfitIndex;
        if (deltaIndex != 0) {
            creditEarned = (_userGaugeWeight * deltaIndex) / 1e18;
            userGaugeProfitIndex[user][gauge] = _gaugeProfitIndex;
        }
        if (creditEarned != 0) {
            emit ClaimRewards(block.timestamp, user, gauge, creditEarned);
            CreditToken(credit).transfer(user, creditEarned);
        }
    }

Tools Used

Manual

        if (_userGaugeWeight == 0) {
           // we should timely update userGaugeWeight here
          userGaugeProfitIndex[user][gauge] = _gaugeProfitIndex;
            return 0;
        }

Assessed type

Error

#0 - c4-pre-sort

2024-01-05T07:43:30Z

0xSorryNotSorry marked the issue as sufficient quality report

#1 - c4-pre-sort

2024-01-05T07:43:47Z

0xSorryNotSorry marked the issue as duplicate of #1211

#2 - c4-judge

2024-01-29T03:56:29Z

Trumpero marked the issue as satisfactory

#3 - c4-judge

2024-01-31T13:46:19Z

Trumpero changed the severity to 3 (High Risk)

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter