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

C-01 DoS Due to Unrestricted Growth of poolAssets Array #1889

Merged

Conversation

sparrowDom
Copy link
Member

@sparrowDom sparrowDom commented Oct 23, 2023

BaseBalancerStrategy's cachePoolAssets increases the length of poolAssets list with every call, extending the list by the same assets every time. Calling this method more than once will cause DoS via several paths:

  • BalancerMetaPoolStrategy's _deposit, _withdraw, and withdrawAll, will send malformed requests to Balancer with duplicated asset lists, and fail validation. This will cause all subsequent deposits and withdrawals to fail.
  • Calculations based on the duplicated list will result in incorrectly calculated withdrawal amount of BPT in _withdraw, and create a potential for gas based DoS in the same method.
  • BaseBalancerStrategy's cacheRateProviders will fail its validation check if it will need to be called again.

Crucially, cachePoolAssets lacks access control and as a result, is callable by anyone.
Thus, a malicious second call to this function will break the deposit and withdrawal
functionality of all Balancer strategies.

Consider checking that the poolAssets array is empty at the beginning of
cachePoolAssets

@rafaelugolini rafaelugolini temporarily deployed to preview-oeth-sparrowdom-xll8vu October 23, 2023 14:38 Inactive
@rafaelugolini rafaelugolini temporarily deployed to preview-ousd-sparrowdom-ych3lp October 23, 2023 14:38 Inactive
@sparrowDom sparrowDom changed the base branch from master to sparrowDom/balancer-composable-st-pool October 23, 2023 14:38
@github-actions
Copy link

github-actions bot commented Oct 23, 2023

Messages
📖 🎉 This PR has 2 approved reviews

Generated by 🚫 dangerJS against 74fd116

@codecov
Copy link

codecov bot commented Oct 23, 2023

Codecov Report

Merging #1889 (74fd116) into sparrowDom/balancer-composable-st-pool (292db7a) will decrease coverage by 10.19%.
Report is 1 commits behind head on sparrowDom/balancer-composable-st-pool.
The diff coverage is 0.00%.

@@                             Coverage Diff                             @@
##           sparrowDom/balancer-composable-st-pool    #1889       +/-   ##
===========================================================================
- Coverage                                   67.58%   57.39%   -10.19%     
===========================================================================
  Files                                          51       51               
  Lines                                        2724     2725        +1     
  Branches                                      703      704        +1     
===========================================================================
- Hits                                         1841     1564      -277     
- Misses                                        880     1158      +278     
  Partials                                        3        3               
Files Coverage Δ
...racts/strategies/balancer/BaseBalancerStrategy.sol 0.00% <0.00%> (-77.21%) ⬇️

... and 7 files with indirect coverage changes

📣 Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

@sparrowDom sparrowDom changed the title H-01 DoS attack cache asset C-01 DoS attack cache asset Nov 2, 2023
@sparrowDom sparrowDom changed the title C-01 DoS attack cache asset C-01 DoS Due to Unrestricted Growth of poolAssets Array Nov 2, 2023
@@ -174,6 +174,15 @@ describe("ForkTest: Balancer MetaStablePool rETH/WETH Strategy", function () {
auraRewardPool
);
});

// Un-skip once we re-deploy the strategy
it.skip("Shouldn't be able to cache assets twice", async function () {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are we going to make sure we do this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about like this :)
74fd116

Copy link
Collaborator

@DanielVF DanielVF left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be merged. Will fully verify when all changes integrated.

@sparrowDom sparrowDom merged commit ea1c8ef into sparrowDom/balancer-composable-st-pool Nov 8, 2023
12 of 18 checks passed
@sparrowDom sparrowDom deleted the sparrowDom/balancer-H01 branch November 8, 2023 19:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants