Skip to content
This repository has been archived by the owner on Jul 14, 2024. It is now read-only.

cergyk - LibTWAPOracle::setPool Dos on setPool by donating a few wei of 3CRV directly to the metapool #14

Closed
Tracked by #866
sherlock-admin2 opened this issue Jan 10, 2024 · 21 comments
Assignees
Labels
Escalation Resolved This issue's escalations have been approved/rejected Non-Reward This issue will not receive a payout Price: 25 USD Priority: 1 (Normal) Sponsor Confirmed The sponsor acknowledged this issue is valid Time: <1 Hour Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin2
Copy link
Contributor

sherlock-admin2 commented Jan 10, 2024

cergyk

medium

LibTWAPOracle::setPool Dos on setPool by donating a few wei of 3CRV directly to the metapool

Summary

LibTWAPOracle::setPool relies on a perfect match between the initial balance of uAD and 3CRV in the pool, which means that a malicious user can front-run the admin call to setPool and donate a few wei of 3CRV to the pool in order to make the call revert.

Vulnerability Detail

We can see the the admin function LibTWAPOracle::setPool, checks that the balances of uAD and 3CRV are perfectly equal:
https://github.com/sherlock-audit/2023-12-ubiquity/blob/main/ubiquity-dollar/packages/contracts/src/dollar/libraries/LibTWAPOracle.sol#L51

This means that a malicious user can front-run the call to setPool by donating a few wei of 3CRV directly to the metapool, in which case the balances will not match. The admin will not be able to set the pool as the function will revert

Impact

The feature of migrating to a new pool will be DoSed temporarily, as long as the attacker keeps sending a few wei to the metapool contract

Code Snippet

Tool used

Manual Review

Recommendation

Accept a slight imbalance between the balances of uAD and 3CRV (by a few dollars), in order to make this kind of DoS economically impractical for the attacker

@github-actions github-actions bot added the Excluded Excluded by the judge without consulting the protocol or the senior label Jan 14, 2024
@sherlock-admin2
Copy link
Contributor Author

1 comment(s) were left on this issue during the judging contest.

auditsea commented:

The issue describes about DOSing setPool function by manipulating the Curve pool, but it's assumed that the Curve pool deployment, LP deposit, and setPool will be handled in one tx using multicall structure

@github-actions github-actions bot reopened this Jan 16, 2024
@github-actions github-actions bot added Medium A valid Medium severity issue Has Duplicates A valid issue with 1+ other issues describing the same vulnerability and removed Excluded Excluded by the judge without consulting the protocol or the senior labels Jan 16, 2024
@sherlock-admin2
Copy link
Contributor Author

1 comment(s) were left on this issue during the judging contest.

auditsea commented:

The issue describes about DOSing setPool function by manipulating the Curve pool, but it's assumed that the Curve pool deployment, LP deposit, and setPool will be handled in one tx using multicall structure

@rndquu
Copy link

rndquu commented Jan 16, 2024

@gitcoindev @molecula451

The recommendation states to "Accept a slight imbalance between the balances of uAD and 3CRV" but this can also lead to potential DOS.

I think we can simply remove this line.

@gitcoindev
Copy link

@gitcoindev @molecula451

The recommendation states to "Accept a slight imbalance between the balances of uAD and 3CRV" but this can also lead to potential DOS.

I think we can simply remove this line.

I did a research on GitHub and indeed other pool implementations just use

require(_reserve0 > 0 && _reserve1 > 0, "No reserves");

also some pools check for overflow

therefore since 2 lines above this line we check for reserves it is safe to remove this line.

@gitcoindev gitcoindev added the Will Fix The sponsor confirmed this issue will be fixed label Jan 16, 2024
@rndquu
Copy link

rndquu commented Jan 17, 2024

@gitcoindev @molecula451
The recommendation states to "Accept a slight imbalance between the balances of uAD and 3CRV" but this can also lead to potential DOS.
I think we can simply remove this line.

I did a research on GitHub and indeed other pool implementations just use

require(_reserve0 > 0 && _reserve1 > 0, "No reserves");

also some pools check for overflow

therefore since 2 lines above this line we check for reserves it is safe to remove this line.

This overflow check is needed because of downcasting from uint256 to uint128 here. I guess this is not the case for us since we don't use uint128 in the LibUbiquityPool.

@rndquu rndquu added the Sponsor Confirmed The sponsor acknowledged this issue is valid label Jan 17, 2024
@sherlock-admin2 sherlock-admin2 changed the title Radiant Charcoal Horse - LibTWAPOracle::setPool Dos on setPool by donating a few wei of 3CRV directly to the metapool cergyk - LibTWAPOracle::setPool Dos on setPool by donating a few wei of 3CRV directly to the metapool Jan 24, 2024
@sherlock-admin2 sherlock-admin2 added the Reward A payout will be made for this issue label Jan 24, 2024
@nevillehuang
Copy link
Collaborator

  • If flashbots are considered like @Czar102 previously mentioned, I agree that this issue can be low severity
  • If not, this can possibly allow permanent DoS as long as user keep front-running on mainnet and donating funds into the pool, so can possibly be medium severity too

@Czar102
Copy link

Czar102 commented Feb 13, 2024

I agree with the escalation. This issue has the same impact as front-running initializers, which is making the deployment useless (easily detectable) without a loss of funds. This impact is not accepted by Sherlock rules as a Medium severity issue, hence planning to consider this a low.
Will modify the guidelines to include a more generalized rule.

Planning to accept the escalation and invalidate the issue.

@Czar102 Czar102 removed the Medium A valid Medium severity issue label Feb 14, 2024
@sherlock-admin sherlock-admin added Non-Reward This issue will not receive a payout and removed Reward A payout will be made for this issue labels Feb 14, 2024
@Czar102 Czar102 closed this as completed Feb 14, 2024
@Czar102
Copy link

Czar102 commented Feb 14, 2024

Result:
Low
Has duplicates

@sherlock-admin2 sherlock-admin2 removed the Escalated This issue contains a pending escalation label Feb 14, 2024
@sherlock-admin sherlock-admin added the Escalation Resolved This issue's escalations have been approved/rejected label Feb 14, 2024
@sherlock-admin2
Copy link
Contributor Author

Escalations have been resolved successfully!

Escalation status:

Copy link

ubiquibot bot commented Feb 17, 2024

@molecula451 the deadline is at 2024-02-17T13:22:13.234Z

@molecula451 molecula451 assigned rndquu and unassigned molecula451 Feb 17, 2024
Copy link

ubiquibot bot commented Feb 17, 2024

@rndquu the deadline is at 2024-02-17T13:22:20.571Z

Copy link

ubiquibot bot commented Feb 17, 2024

# No linked pull requests to close

Copy link

ubiquibot bot commented Feb 17, 2024

+ Evaluating results. Please wait...

Copy link

ubiquibot bot commented Feb 17, 2024

[ 1.1 WXDAI ]

@molecula451
Contributions Overview
ViewContributionCountReward
IssueComment11.1
Conversation Incentives
CommentFormattingRelevanceReward
PR Confirmation fix: https://github.com/ubiquity/ubiquity-dollar...
1.10.651.1

[ 8.4 WXDAI ]

@gitcoindev
Contributions Overview
ViewContributionCountReward
IssueComment18.4
Conversation Incentives
CommentFormattingRelevanceReward
> @gitcoindev @molecula451 > > The recommendation states to "...
8.4
a:
  count: 3
  score: "3"
  words: 7
code:
  count: 1
  score: "1"
  words: 13
0.6958.4

[ 42.4 WXDAI ]

@rndquu
Contributions Overview
ViewContributionCountReward
IssueTask1.0025
IssueComment20
IssueComment217.4
Conversation Incentives
CommentFormattingRelevanceReward
@gitcoindev @molecula451

The recommendation states to "Accep...

-

a:
  count: 1
  score: "0"
  words: 1
0.86-
> > @gitcoindev @molecula451 > > The recommendation states to "...
-
a:
  count: 5
  score: "0"
  words: 9
code:
  count: 5
  score: "0"
  words: 17
0.81-
@gitcoindev @molecula451

The recommendation states to "Accep...

4.3

a:
  count: 1
  score: "1"
  words: 1
0.864.3
> > @gitcoindev @molecula451 > > The recommendation states to "...
13.1
a:
  count: 5
  score: "5"
  words: 9
code:
  count: 5
  score: "5"
  words: 17
0.8113.1

@sherlock-admin2 sherlock-admin2 removed the Has Duplicates A valid issue with 1+ other issues describing the same vulnerability label Feb 20, 2024
@sherlock-admin
Copy link
Contributor

The protocol team fixed this issue in PR/commit ubiquity/ubiquity-dollar#883.

@sherlock-admin
Copy link
Contributor

The Lead Senior Watson signed off on the fix.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Escalation Resolved This issue's escalations have been approved/rejected Non-Reward This issue will not receive a payout Price: 25 USD Priority: 1 (Normal) Sponsor Confirmed The sponsor acknowledged this issue is valid Time: <1 Hour Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

10 participants