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

Staked Credit Rewards can be unfairly divided because of MEV/Just-in-time deposits #864

Closed
c4-bot-3 opened this issue Dec 28, 2023 · 6 comments
Labels
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 duplicate-994 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards sufficient quality report This report is of sufficient quality

Comments

@c4-bot-3
Copy link
Contributor

c4-bot-3 commented Dec 28, 2023

Lines of code

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

Vulnerability details

Vulnerability details

An attacker can use MEV (via gas auction or Flashbots or control of miners) to cause an unfair division of rewards. By providing a large (relative to the size of all other staked tokens) credit token deposit Just-in-Time before a GAUGE_PNL_NOTIFIER call to ProfitManager.notifyPnL the CREDIT deposited by the attacker will receive a big portion of the rewards and the attacker can immediately withdraw their deposit after rewards are distributed.

We assume this allows an attacker to get a lot of the rewards (in GUILD and CREDIT) even though they haven't provided any deposit that has been borrowed.

Impact

Credit holders get rewards, they have not earned

Proof of Concept

  1. An attacker watches the mempool for calls to ProfitManager.notifyPnL by the GAUGE_PNL_NOTIFIER role.
  2. The attacker orders the block's transactions (most easily using a flashbots bundle) in the following order:
    1. Attacker deposits assets to lend (ideally the pool will be the one with the least volume).
    2. GAUGE_PNL_NOTIFIER call to ProfitManager.notifyPnL happens
    3. Attacker withdraws their deposit.

Tools Used

Manual review

Recommended Mitigation Steps

A good mitigation approach could use something like snapshotting who has deposited since the last reward distribution and only give these depositors rewards based on the size of their deposits the next time yield is distributed.

Assessed type

MEV

@c4-bot-3 c4-bot-3 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Dec 28, 2023
c4-bot-4 added a commit that referenced this issue Dec 28, 2023
@c4-bot-7 c4-bot-7 removed the 3 (High Risk) Assets can be stolen/lost/compromised directly label Dec 28, 2023
@code4rena-admin code4rena-admin added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value edited-by-warden labels Dec 28, 2023
@c4-pre-sort
Copy link

0xSorryNotSorry marked the issue as sufficient quality report

@c4-pre-sort c4-pre-sort added the sufficient quality report This report is of sufficient quality label Jan 5, 2024
@c4-pre-sort
Copy link

0xSorryNotSorry marked the issue as duplicate of #1173

@c4-judge
Copy link
Contributor

Trumpero marked the issue as not a duplicate

@c4-judge
Copy link
Contributor

Trumpero marked the issue as duplicate of #994

@c4-judge
Copy link
Contributor

Trumpero marked the issue as unsatisfactory:
Invalid

@c4-judge c4-judge added the unsatisfactory does not satisfy C4 submission criteria; not eligible for awards label Jan 27, 2024
@c4-judge
Copy link
Contributor

Trumpero marked the issue as satisfactory

@c4-judge c4-judge added satisfactory satisfies C4 submission criteria; eligible for awards and removed unsatisfactory does not satisfy C4 submission criteria; not eligible for awards labels Jan 27, 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 bug Something isn't working duplicate-994 edited-by-warden satisfactory satisfies C4 submission criteria; eligible for awards sufficient quality report This report is of sufficient quality
Projects
None yet
Development

No branches or pull requests

5 participants