Ethereum Credit Guild - KupiaSec'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: 119/127

Findings: 1

Award: $3.05

🌟 Selected for report: 0

🚀 Solo Findings: 0

Awards

3.0466 USDC - $3.05

Labels

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

External Links

Lines of code

https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/2376d9af792584e3d15ec9c32578daa33bb56b43/src/loan/SurplusGuildMinter.sol#L230

Vulnerability details

Impact

Users that stake their credit token before loss, will not have reward

Proof of Concept

After forgive function of LendingTerm contract is called or less credit token bid on auction, i.e. if loss occured, LendingTerm contract calls notifyPnl() function of ProfitManager contract. In that function, if pnl is negative value, this function calls notifyGaugeLoss function in GuildToken Contract. After that, lastGaugeLoss state of the gauge is updated to block.timestamp. In getRewards function of SurplusGuildMinter contract, usersStake.lastGaugeLoss is 0 forever if the users staked before the gauge loss. So slashed flag will be true. As a result, users cannot get rewards at all.

function getRewards(
        address user,
        address term
    )
        public
        returns (
            uint256 lastGaugeLoss, // GuildToken.lastGaugeLoss(term)
            UserStake memory userStake, // stake state after execution of getRewards()
            bool slashed // true if the user has been slashed
        )
    {
        bool updateState;
        lastGaugeLoss = GuildToken(guild).lastGaugeLoss(term);
        
        if (lastGaugeLoss > uint256(userStake.lastGaugeLoss)) { //@audit userStake.lastGaugeLoss could be zero and slashed is true
            slashed = true;
        }
        // if the user is not staking, do nothing
        userStake = _stakes[user][term];
        if (userStake.stakeTime == 0)
            return (lastGaugeLoss, userStake, slashed);
    }

Tools Used

Manual Review

It should have a logic to manage users' already accumulated rewards before updating lastGuageLoss.

Assessed type

Other

#0 - c4-pre-sort

2023-12-29T18:47:48Z

0xSorryNotSorry marked the issue as sufficient quality report

#1 - c4-pre-sort

2023-12-29T18:48:26Z

0xSorryNotSorry marked the issue as duplicate of #1164

#2 - c4-judge

2024-01-28T20:09:54Z

Trumpero marked the issue as satisfactory

#3 - c4-judge

2024-01-31T13:46:46Z

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