Lack of access control allow anyone to withdrawInterest() for any lender
Submitted by WatchPug
function withdrawInterest(uint256 _id, address _lender) external nonReentrant {
_withdrawInterest(_id, _lender);
}
function _withdrawInterest(uint256 _id, address _lender) internal {
address _strategy = pooledCLConstants[_id].borrowAssetStrategy;
address _borrowAsset = pooledCLConstants[_id].borrowAsset;
(uint256 _interestToWithdraw, uint256 _interestSharesToWithdraw) = _calculateInterestToWithdraw(
_id,
_lender,
_strategy,
_borrowAsset
);
pooledCLVariables[_id].sharesHeld = pooledCLVariables[_id].sharesHeld.sub(_interestSharesToWithdraw);
if (_interestToWithdraw != 0) {
SAVINGS_ACCOUNT.withdraw(_borrowAsset, _strategy, _lender, _interestToWithdraw, false);
}
emit InterestWithdrawn(_id, _lender, _interestSharesToWithdraw);
}
withdrawInterest() at a certain time may not be in the best interest of the specific lender.
It’s unconventional and can potentially cause leak of value for the lender. For example, the lender may still want to accrued more interest from the strategy.
Recommended Mitigation Steps
Change to:
function withdrawInterest(uint256 _id, address _lender) external nonReentrant {
require(msg.sender == _lender);
_withdrawInterest(_id, _lender);
}
ritik99 (Sublime) confirmed, but disagreed with Medium severity and commented:
This is a valid suggestion. This allowed more flexibility from a composability/complexity perspective (for eg, an abstraction can be built that regularly withdraws interests for all lenders), hence the check was not put in place. We will add a check as suggested.
Since assets are not at risk (any withdrawn amount is still transferred to the correct lender), we would suggest lowering the severity to (1) low-risk.
HardlyDifficult (judge) commented:
Agree with medium risk as this seems to potentially leak some value for the lender.
Added access control for withdrawInterest in LenderPool sublime-finance/sublime-v1#374
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is known
A medium-severity access control bug in Sublime contest. Code4rena made it public on 14 July 2022. Found in the 2022-03-sublime audit contest (finding M-02).
About Access control
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
What is Access control?
A user can do something their role should not allow: reach an admin function, act on a feature they have not paid for, or skip a permission check. IDOR is the special case where the object belongs to someone else.