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

PrePOMarket.sol : a sender who is not included in the account list can front run and mint prior to setting the _mintHook #266

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

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/prepo-io/prepo-monorepo/blob/3541bc704ab185a969f300e96e2f744a572a3640/apps/smart-contracts/core/contracts/PrePOMarket.sol#L65-L74

Vulnerability details

Impact

a sender who is not included in the account list can front run and mint prior to setting the _mintHook.

Proof of Concept

The contract says,

* Minting will only be done by the team, and thus relies on the `_mintHook`
* to enforce access controls. This is also why there is no fee for `mint()`

But, when we look at the mint function, the sender gets validated only if the _mintHook is valid at line 68.

 function mint(uint256 _amount) external override nonReentrant returns (uint256) {
require(finalLongPayout > MAX_PAYOUT, "Market ended");
require(collateral.balanceOf(msg.sender) >= _amount, "Insufficient collateral");
if (address(_mintHook) != address(0)) _mintHook.hook(msg.sender, _amount, _amount);
collateral.transferFrom(msg.sender, address(this), _amount);
longToken.mint(msg.sender, _amount);
shortToken.mint(msg.sender, _amount);
emit Mint(msg.sender, _amount);
return _amount;

}

The _mintHook is not set during the contract deployment. A separate function is used to set it.

As soon as the contract is deployed, the user can front run and call the mint function.

Tools Used

Manual review

Recommended Mitigation Steps

set the _mintHook in constructor while deploying the contract.

revert if '_mintHook' is not set.

@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
@c4-judge
Copy link
Contributor

Picodes marked the issue as duplicate of #312

@c4-judge
Copy link
Contributor

c4-judge commented Jan 7, 2023

Picodes marked the issue as satisfactory

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

No branches or pull requests

3 participants