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

A manager can withdraw all amount and DoS withdrawals #220

Closed
code423n4 opened this issue Dec 12, 2022 · 4 comments
Closed

A manager can withdraw all amount and DoS withdrawals #220

code423n4 opened this issue Dec 12, 2022 · 4 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-254 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/prepo-io/prepo-monorepo/blob/feat/2022-12-prepo/apps/smart-contracts/core/contracts/Collateral.sol#L80-L83
https://github.com/prepo-io/prepo-monorepo/blob/feat/2022-12-prepo/apps/smart-contracts/core/contracts/WithdrawHook.sol#L58

Vulnerability details

Impact

Manager for Collateral smart contract has complete role over collateral funds and is able to withdraw all of it

The assumption is that the manager is honest, even though there is a big risk with wrongly configured MultiSig (e.g. admin that can circumvent M of N votes to take an action), keys compromise, even moving funds to unepected address which would lead to funds being lost.

Proof of Concept

Manager can call managerWithdraw to get all the funds:

80:  function managerWithdraw(uint256 _amount) external override onlyRole(MANAGER_WITHDRAW_ROLE) nonReentrant {
81:    if (address(managerWithdrawHook) != address(0)) managerWithdrawHook.hook(msg.sender, _amount, _amount);
82:    baseToken.transfer(manager, _amount);
83:  }

or halt withdrawals:

Colateral.sol
73:  withdrawHook.hook(msg.sender, _baseTokenAmount, _baseTokenAmountAfterFee);
WithdrawalHook.sol
//withdrawalsAllowed is set by manager account 
58:    require(withdrawalsAllowed, "withdrawals not allowed");//@audit-issue LOW - by default it's false, any withdrawal will fail

Tools Used

VS Code

Recommended Mitigation Steps

If only function of this is to move funds to some yield bearing protocol (e.g. Aave, DEXes), please implement supposed functionality in the smart contract. Otherwise, it's best to remove the function completely.

@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 Dec 12, 2022
code423n4 added a commit that referenced this issue Dec 12, 2022
@hansfriese
Copy link

duplicate of #254

@c4-judge
Copy link
Contributor

Picodes marked the issue as duplicate of #254

@Picodes
Copy link

Picodes commented Dec 17, 2022

Also dup of #305

@c4-judge
Copy link
Contributor

c4-judge commented Jan 1, 2023

Picodes marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jan 1, 2023
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-254 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants