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

handleFees() will revert if licenseFee is too high #52

Open
code423n4 opened this issue Sep 19, 2021 · 1 comment
Open

handleFees() will revert if licenseFee is too high #52

code423n4 opened this issue Sep 19, 2021 · 1 comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Warden finding

Comments

@code423n4
Copy link
Contributor

Handle

gpersoon

Vulnerability details

Impact

The function handleFees() will revert if feePct >BASE
==> feePct = timeDiff * licenseFee / ONE_YEAR;
==> BASE < timeDiff * licenseFee / ONE_YEAR;
==> licenseFee > BASE * ONE_YEAR / timeDiff
So licenseFee should have a maximum value to prevent this.
Probably there is also a reasonable upperlimit to licenseFee the let the protocol function properly.

Proof of Concept

https://github.com/code-423n4/2021-09-defiProtocol/blob/main/contracts/contracts/Basket.sol#L110
function handleFees() private {
..
uint256 timeDiff = (block.timestamp - lastFee);
uint256 feePct = timeDiff * licenseFee / ONE_YEAR;
uint256 fee = startSupply * feePct / (BASE - feePct); // will revert if feePct > BASE

Tools Used

Recommended Mitigation Steps

Define an upperlimit for licenseFee
Enforce this in the function proposeBasketLicense() of Factory.sol

@code423n4 code423n4 added 1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Warden finding labels Sep 19, 2021
code423n4 added a commit that referenced this issue Sep 19, 2021
@GalloDaSballo
Copy link
Collaborator

Agree with finding, mitigation is to add a limit to licenseFee

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1 (Low Risk) Assets are not at risk. State handling, function incorrect as to spec, issues with comments bug Warden finding
Projects
None yet
Development

No branches or pull requests

2 participants