Skip to content
This repository has been archived by the owner on Sep 17, 2023. It is now read-only.

roguereddwarf - Missing input validation for _rewardProportion parameter allows keeper to escalate his privileges and pay back all loans #11

Open
sherlock-admin opened this issue Mar 13, 2023 · 3 comments
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability High A valid High severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed

Comments

@sherlock-admin
Copy link
Contributor

roguereddwarf

high

Missing input validation for _rewardProportion parameter allows keeper to escalate his privileges and pay back all loans

Summary

According to the Contest page and discussion with the sponsor, the role of a keeper is to perform liquidations and to swap yield token for TAU using the SwapHandler.swapForTau function:
https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/SwapHandler.sol#L45-L52

They are also able to choose how much yield token to swap and what the proportion of the resulting TAU is that is distributed to users vs. not distributed in order to erase bad debt.

So a keeper is not trusted to perform any actions that go beyond swapping yield / performing liquidations.

However there is a missing input validation for the _rewardProportion parameter in the SwapHandler.swapForTau function.
This allows a keeper to "erase" all debt of users.
So users can withdraw their collateral without paying any of the debt.

Vulnerability Detail

By looking at the code we can see that _rewardProportion is used to determine the amount of TAU that _withholdTau is called with:
Link

_withholdTau((tauReturned * _rewardProportion) / Constants.PERCENT_PRECISION);

Any value of _rewardProportion greater than 1e18 means that more TAU will be distributed to users than has been burnt (aka erasing debt).

It is easy to see how the keeper can chose the number so big that _withholdTau is called with a value close to type(uint256).max which will certainly be enough to erase all debt.

Impact

A keeper can escalate his privileges and erase all debt.
This means that TAU will not be backed by any collateral anymore and will be worthless.

Code Snippet

https://github.com/sherlock-audit/2023-03-taurus/blob/main/taurus-contracts/contracts/Vault/SwapHandler.sol#L45-L101

Tool used

Manual Review

Recommendation

I discussed this issue with the sponsor and it is intended that the keeper role can freely chose the value of the _rewardProportion parameter within the [0,1e18] range, i.e. 0%-100%.

Therefore the fix is to simply check that _rewardProportion is not bigger than 1e18:

diff --git a/taurus-contracts/contracts/Vault/SwapHandler.sol b/taurus-contracts/contracts/Vault/SwapHandler.sol
index c04e3a4..ab5064b 100644
--- a/taurus-contracts/contracts/Vault/SwapHandler.sol
+++ b/taurus-contracts/contracts/Vault/SwapHandler.sol
@@ -59,6 +59,10 @@ abstract contract SwapHandler is FeeMapping, TauDripFeed {
             revert zeroAmount();
         }
 
+        if (_rewardProportion > Constants.PERCENT_PRECISION) [
+            revert invalidRewardProportion();
+        ]
+
         // Get and validate swap adapter address
         address swapAdapterAddress = SwapAdapterRegistry(controller).swapAdapters(_swapAdapterHash);
         if (swapAdapterAddress == address(0)) {
@github-actions github-actions bot added High A valid High severity issue Has Duplicates A valid issue with 1+ other issues describing the same vulnerability labels Mar 21, 2023
@Sierraescape Sierraescape added Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed labels Mar 21, 2023
@Sierraescape
Copy link

@sherlock-admin sherlock-admin added the Reward A payout will be made for this issue label Apr 1, 2023
@MLON33
Copy link

MLON33 commented Apr 10, 2023

@IAm0x52
Copy link
Collaborator

IAm0x52 commented Apr 18, 2023

Fix looks good. swapForTau will now revert if keeper specifies a _rewardProportion that is too large

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Has Duplicates A valid issue with 1+ other issues describing the same vulnerability High A valid High severity issue Reward A payout will be made for this issue Sponsor Confirmed The sponsor acknowledged this issue is valid Will Fix The sponsor confirmed this issue will be fixed
Projects
None yet
Development

No branches or pull requests

4 participants