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

Owner can use recoverERC20 to drain reward tokens #81

Closed
code423n4 opened this issue Oct 29, 2022 · 7 comments
Closed

Owner can use recoverERC20 to drain reward tokens #81

code423n4 opened this issue Oct 29, 2022 · 7 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-68 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-10-paladin/blob/2cef3087052f019c8043f66f954d630b81cb16fb/contracts/WardenPledge.sol#L654

Vulnerability details

Impact

recoverERC20 does not allow recovering the token when minAmountRewardToken[token] != 0 such that the owner is not able to drain the reward tokens out of the contracts. However, the owner fully controls minAmountRewardToken[token] and can reset it to 0 with removeRewardToken, even if there is a remaining reward amount that is available for pledges.

This is a significant risk for users (especially pledge creators) that interact with the contract, as the reward tokens that they have transferred can be removed at any point.

Proof Of Concept

Consider the following diff where the owner removes the reward token and then calls recoverERC20 (which does not revert, i.e. the test fails there):

--- a/test/wardenPledge.test.ts
+++ b/test/wardenPledge.test.ts
@@ -3439,6 +3439,12 @@ describe('Warden Pledge contract tests', () => {
                 wardenPledge.connect(admin).recoverERC20(CRV.address)
             ).to.be.revertedWith('CannotRecoverToken')
 
+            await wardenPledge.connect(admin).removeRewardToken(CRV.address)
+
+            await expect(
+                wardenPledge.connect(admin).recoverERC20(CRV.address)
+            ).to.be.revertedWith('CannotRecoverToken')
+
         });
 
         it(' should block non-admin caller', async () => {

Recommended Mitigation Steps

Track for every token if there are remaining pledges. Do not allow recovering the tokens if this is the case.

@code423n4 code423n4 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 Oct 29, 2022
code423n4 added a commit that referenced this issue Oct 29, 2022
@Kogaroshi
Copy link

Duplicate of #17

@Kogaroshi Kogaroshi marked this as a duplicate of #17 Oct 30, 2022
@Kogaroshi Kogaroshi added the duplicate This issue or pull request already exists label Oct 30, 2022
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as not a duplicate

@c4-judge c4-judge removed the duplicate This issue or pull request already exists label Nov 10, 2022
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as duplicate

@c4-judge
Copy link
Contributor

kirk-baird marked the issue as satisfactory

@c4-judge c4-judge reopened this Nov 10, 2022
@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Nov 10, 2022
@c4-judge
Copy link
Contributor

kirk-baird marked the issue as not a duplicate

@c4-judge
Copy link
Contributor

kirk-baird marked the issue as duplicate of #17

@c4-judge
Copy link
Contributor

c4-judge commented Dec 6, 2022

Simon-Busch marked the issue as duplicate of #68

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-68 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

3 participants