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

M-04 MitigationConfirmed #99

Open
c4-bot-1 opened this issue May 24, 2024 · 2 comments
Open

M-04 MitigationConfirmed #99

c4-bot-1 opened this issue May 24, 2024 · 2 comments
Labels
confirmed for report This issue is confirmed for report mitigation-confirmed MR-M-04 satisfactory satisfies C4 submission criteria; eligible for awards

Comments

@c4-bot-1
Copy link
Contributor

Lines of code

Vulnerability details

C4 Issue

M-04: Function Pool.validateOffer() does not work correctly in case principalAmount > currentBalance

Comments

Original vulnerabilities/impacts:
In Pool::validateOffer, check is in place to see of the pool has enough funds to lend, when the required loan principal amount is greater than the pool’s current balance, reallocate() is invoked to transfer the delta amount to the pool.

The problem is the input argument(principalAmount - currentBalance) in reallocate() is incorrect, which will result in funds being transferred out of the pool instead.

Mitigation

Fix: https://github.com/pixeldaogg/florida-contracts/pull/365/files

//src/lib/pools/Pool.sol
    function validateOffer(bytes calldata _offer, uint256 _protocolFee) external override onlyAcceptedCallers {
...
        } else if (principalAmount > currentBalance) {
            IBaseInterestAllocator(getBaseInterestAllocator).reallocate(
                currentBalance, principalAmount, true
            );
        }

The correct parameter input should be reallocate(currentBalance, principalAmount, true). As in reallocate, currentBalance (_currentIdle) and principalAmount(_targetIdle) will be compared and their delta is the transfer amount. This is consistent with the mitigation.

The mitigation corrects the mistake and resolves the issue.

Conclusion

LGTM

@c4-judge
Copy link

c4-judge commented Jun 1, 2024

alex-ppg marked the issue as satisfactory

@c4-judge c4-judge added the satisfactory satisfies C4 submission criteria; eligible for awards label Jun 1, 2024
@c4-judge
Copy link

c4-judge commented Jun 1, 2024

alex-ppg marked the issue as confirmed for report

@c4-judge c4-judge added the confirmed for report This issue is confirmed for report label Jun 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
confirmed for report This issue is confirmed for report mitigation-confirmed MR-M-04 satisfactory satisfies C4 submission criteria; eligible for awards
Projects
None yet
Development

No branches or pull requests

2 participants