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

Reorg & Frontrunning Attack Vulnerability in createTerm() #1259

Closed
c4-bot-4 opened this issue Dec 28, 2023 · 7 comments
Closed

Reorg & Frontrunning Attack Vulnerability in createTerm() #1259

c4-bot-4 opened this issue Dec 28, 2023 · 7 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-c insufficient quality report This report is not of sufficient quality QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards

Comments

@c4-bot-4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/main/src/governance/LendingTermOnboarding.sol#L153

Vulnerability details

Impact

The createTerm() function in the LendingTermOnboarding.sol contract is vulnerable to a reorg/frontrunning attack. This function deploys a new LendingTerm contract using OZ's Clone.clone(), which uses create() under the hood. Here, the address derivation depends solely on the LendingTermOnboarding nonce.

The worst-case scenario is an attacker exploiting the predictability of contract creation to manipulate votes, leading to a malicious contract being approved instead of the intended one.

https://github.com/code-423n4/2023-12-ethereumcreditguild/blob/main/src/governance/LendingTermOnboarding.sol#L153
https://github.com/OpenZeppelin/openzeppelin-contracts/blob/fd81a96f01cc42ef1c9a5399364968d0e07e9e90/contracts/proxy/Clones.sol#L33

This is a Medium severity issues previously reported here an in the referenced reports https://solodit.xyz/issues/m-09-create-methods-are-suspicious-of-the-reorg-attack-code4rena-pooltogether-pooltogether-git

Proof of Concept

The following sequence of events illustrates the vulnerability:

  1. Alice, a user with a significant amount of GUILD tokens, submits a series of transactions in which she:
    • Calls createTerm() with profitable parameters
    • Calls proposeOnboard() to propose its onboarding
    • Calls castVote() to cast her vote in support of her proposal
  2. Bob observes Alice's transactions and frontruns her by calling createTerm() with malicious parameters before Alice's transactions are executed.
  3. Bob's malicious term gets the address Alice expected to create.
  4. Since the proposal ID only depends on the term address, Alice's votes are cast in support of Bob's malicious term.

Tools Used

Manual review

Recommended Mitigation Steps

Use Clones.cloneDeterministic() passing a hash of the proposal parameters as the salt.

Assessed type

Other

@c4-bot-4 c4-bot-4 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 Dec 28, 2023
c4-bot-1 added a commit that referenced this issue Dec 28, 2023
@0xSorryNotSorry
Copy link

0xSorryNotSorry commented Jan 3, 2024

  1. ETH Main Network will not have re-orgs
  2. If a re-org forms on Arbitrum, Alice's transactions will not be executed. Once Alice calls the transaction again, it will revert due to the term is already created.

@c4-pre-sort
Copy link

0xSorryNotSorry marked the issue as insufficient quality report

@c4-pre-sort c4-pre-sort added the insufficient quality report This report is not of sufficient quality label Jan 3, 2024
@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 21, 2024
@0xEVom
Copy link

0xEVom commented Feb 2, 2024

Hi @Trumpero

Re-raising this since as you may be aware reorgs do happen on mainnet https://ethereum.org/en/developers/docs/consensus-mechanisms/pos/attack-and-defense#attacks-by-small-stakeholders

On Arbitrum, an L1 reorg would cause an L2 reorg

As far as I can tell, this is a very unlikely but nevertheless legitimate finding, which the mitigation addresses. Here are several instances in the past year in which similar findings were accepted:
2023-01-rabbithole-findings/M-01
2023-04-frankencoin-findings/M-14
2023-08-pooltogether-findings/M-09

@Trumpero
Copy link

Trumpero commented Feb 8, 2024

@0xEVom Agree that this issue is valid and should be fixed, but it only has low severity. If an attacker creates a term maliciously to receive the votes, this proposal still needs to wait for the 7-day voting duration to be executed. During this time, the Guardian role can cancel it directly, or Guild holders can veto it to cancel, so it doesn't cause any impact.
Additionally, this issue has a very unlikely likelihood, and the issue of the chain system should be considered QA as per C4's docs. I mark this as grade-c because it's grade of combination all QA issues from that warden

@c4-judge
Copy link
Contributor

c4-judge commented Feb 8, 2024

Trumpero changed the severity to QA (Quality Assurance)

@c4-judge c4-judge added downgraded by judge Judge downgraded the risk level of this issue QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax grade-c and removed 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value labels Feb 8, 2024
@c4-judge
Copy link
Contributor

c4-judge commented Feb 8, 2024

Trumpero marked the issue as grade-c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-c insufficient quality report This report is not of sufficient quality QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax unsatisfactory does not satisfy C4 submission criteria; not eligible for awards
Projects
None yet
Development

No branches or pull requests

6 participants