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

setFlashLoanFee() lacks input validation #78

Closed
code423n4 opened this issue Oct 17, 2022 · 4 comments
Closed

setFlashLoanFee() lacks input validation #78

code423n4 opened this issue Oct 17, 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-139 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-10-traderjoe/blob/main/src/LBFactory.sol#L474

Vulnerability details

Impact

Owner could deny users from using flash loans.

Proof of Concept

 function setFlashLoanFee(uint256 _flashLoanFee) external override onlyOwner {
        uint256 _oldFlashLoanFee = flashLoanFee;

        if (_oldFlashLoanFee == _flashLoanFee) revert LBFactory__SameFlashLoanFee(_flashLoanFee);

        flashLoanFee = _flashLoanFee;
        emit FlashLoanFeeSet(_oldFlashLoanFee, _flashLoanFee);
    }

_flashLoanFee is not checked here, so it can be set to any value by a malicious owner.

When a user attempts to call flashLoan() from LBPair.sol the following function is called:

function _getFlashLoanFee(uint256 _amount, uint256 _fee) internal pure returns (uint256) {
        return (_amount * _fee) / Constants.PRECISION;
    }

If _fee is large, this function will revert, which will prevent a user from using flash loan functionality.

Tools Used

vim

Recommended Mitigation Steps

Add upper and lower bounds checks.

@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 Oct 17, 2022
code423n4 added a commit that referenced this issue Oct 17, 2022
@GalloDaSballo
Copy link
Collaborator

Dup of #138

@GalloDaSballo GalloDaSballo added the duplicate This issue or pull request already exists label Oct 27, 2022
@c4-judge
Copy link
Contributor

GalloDaSballo marked the issue as not a duplicate

@c4-judge c4-judge reopened this Nov 23, 2022
@c4-judge c4-judge removed the duplicate This issue or pull request already exists label Nov 23, 2022
@c4-judge
Copy link
Contributor

GalloDaSballo marked the issue as duplicate of #139

@Simon-Busch Simon-Busch added the satisfactory satisfies C4 submission criteria; eligible for awards label Dec 5, 2022
@Simon-Busch
Copy link
Contributor

Marked this issue as Satisfactory as requested by @GalloDaSballo

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-139 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

4 participants