Core Contracts

Regnum Aurum Acquisition Corp
HardhatReal World AssetsNFT
77,280 USDC
View results
Submission Details
Severity: low
Invalid

Intended behavior vs implementation mismatch in LendingPool::_repay

A user's debt in LendingPool can be paid in 2 ways:

  • Calling repay function

  • Calling repayonBehalft function

Both of them call _repayfunction which have the following comments above it:

/**
* @notice Internal function to repay borrowed reserve assets
* @param amount The amount to repay
* @param onBehalfOf The address of the user whose debt is being repaid. If address(0), msg.sender's debt is repaid.
* @dev This function allows users to repay their own debt or the debt of another user.
* The caller (msg.sender) provides the funds for repayment in both cases.
* If onBehalfOf is set to address(0), the function defaults to repaying the caller's own debt.
*/
function _repay(uint256 amount, address onBehalfOf) internal {
if (amount == 0) revert InvalidAmount();
if (onBehalfOf == address(0)) revert AddressCannotBeZero();

So, the comments say that If onBehalfOf is set to address(0), the function defaults to repaying the caller's own debt. which is wrong, because we see that the code has this check if (onBehalfOf == address(0)) revert AddressCannotBeZero(); so, everything that is written in that comment is wrong, and the function will revert in the case that the address onBehalfOf is address(0).

Which also means that if the user wanted to pay their own debt via calling repayOnBehalfwith address(0) passed as onBehalfOf param, the function will revert. See repayOnBehalf function for reference:

/**
* @notice Allows a user to repay borrowed reserve assets on behalf of another user
* @param amount The amount to repay
* @param onBehalfOf The address of the user whose debt is being repaid
*/
function repayOnBehalf(
uint256 amount,
address onBehalfOf
) external nonReentrant whenNotPaused onlyValidAmount(amount) {
if (!canPaybackDebt) revert PaybackDebtDisabled();
if (onBehalfOf == address(0)) revert AddressCannotBeZero();
_repay(amount, onBehalfOf);
}

Impact

Code is not doing what it's supposed to do, causing confusion and impacting user experience.

Updates

Lead Judging Commences

inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
inallhonesty Lead Judge 3 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.