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

What is default duration when creditRateMantissa is not set #10

Open
code423n4 opened this issue Jun 20, 2021 · 0 comments
Open

What is default duration when creditRateMantissa is not set #10

code423n4 opened this issue Jun 20, 2021 · 0 comments
Assignees
Labels
1 (Low Risk) bug Something isn't working

Comments

@code423n4
Copy link
Contributor

Handle

gpersoon

Vulnerability details

Impact

In PrizePool.sol, if the value of _tokenCreditPlans[_controlledToken].creditRateMantissa isn't set (yet), then the function _estimateCreditAccrualTime returns 0.
This means the TimelockDuration is 0 and funds can be withdrawn immediately, defeating the entire timelock mechanism.

Perhaps a different default would be useful.

Proof of Concept

// https://github.com/code-423n4/2021-06-pooltogether/blob/main/contracts/PrizePool.sol#L783
function _estimateCreditAccrualTime( address _controlledToken,uint256 _principal,uint256 _interest ) internal view returns (uint256 durationSeconds) {
uint256 accruedPerSecond = FixedPoint.multiplyUintByMantissa(_principal, _tokenCreditPlans[_controlledToken].creditRateMantissa);
if (accruedPerSecond == 0) {
return 0;
}
return _interest.div(accruedPerSecond);
}

// https://github.com/code-423n4/2021-06-pooltogether/blob/main/contracts/PrizePool.sol#L710
function _calculateTimelockDuration( address from, address controlledToken, uint256 amount) internal returns (uint256 durationSeconds, uint256 burnedCredit ) {
...
uint256 duration = _estimateCreditAccrualTime(controlledToken, amount, exitFee);
if (duration > maxTimelockDuration) {
duration = maxTimelockDuration;
}
return (duration, _burnedCredit);
}

Tools Used

Recommended Mitigation Steps

Consider the default duration for the case _tokenCreditPlans[_controlledToken].creditRateMantissa isn't set.

@code423n4 code423n4 added 1 (Low Risk) bug Something isn't working labels Jun 20, 2021
code423n4 added a commit that referenced this issue Jun 20, 2021
@kamescg kamescg self-assigned this Jun 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants