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

managerWithdraw can be called when manager isn't set, wiping all user funds #256

Open
code423n4 opened this issue Dec 12, 2022 · 5 comments
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b Q-25 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/Collateral.sol#L80-L83

Vulnerability details

Impact

The manager role in Collateral.sol must be set manually. It isn't included in the constructor or initialize functions.

It also isn't necessary in order to set the MANAGER_WITHDRAW_ROLE.

In the case where the MANAGER_WITHDRAW_ROLE is set and manager is not, the user is able to call managerWithdraw().

This will send all requested funds to the zero address, where they will be irretrievable.

Proof of Concept

manager isn't set anywhere in the contract except the setManager function.

There is no requirement that this function must have been called in order to call managerWithdraw().

The result is that any call to managerWithdraw() before manager is set will destroy all funds.

Tools Used

Manual Review

Recommended Mitigation Steps

Add a check in this function that the manager is set before sending funds:

require(manager != address(0), 'manager must be set to send funds');

@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Dec 12, 2022
code423n4 added a commit that referenced this issue Dec 12, 2022
@Picodes
Copy link

Picodes commented Dec 13, 2022

This is theoretically possible but is not a high severity finding. It'd require centralization + errors. So downgrading to low as it's more a safety check.

@c4-judge c4-judge added QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax downgraded by judge Judge downgraded the risk level of this issue and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Dec 13, 2022
@c4-judge
Copy link
Contributor

Picodes changed the severity to QA (Quality Assurance)

@c4-judge
Copy link
Contributor

Picodes marked the issue as grade-b

@c4-sponsor c4-sponsor added the sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue label Dec 22, 2022
@c4-sponsor
Copy link

davidprepo marked the issue as sponsor disputed

@ghost
Copy link

ghost commented Dec 22, 2022

System will never be left in this state

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working downgraded by judge Judge downgraded the risk level of this issue grade-b Q-25 QA (Quality Assurance) Assets are not at risk. State handling, function incorrect as to spec, issues with clarity, syntax sponsor disputed Sponsor cannot duplicate the issue, or otherwise disagrees this is an issue
Projects
None yet
Development

No branches or pull requests

5 participants