56719 sc high the function forcerepay reduces debt before clamp creating unbacked loan forgiveness and protocol insolvency
Description
Brief/Intro
Vulnerability Details
/**
* @notice Force repays earmarked debt of the account owned by `accountId` using account's collateral balance.
* @param accountId The tokenId of the account to repay from.
* @param amount The amount to repay in debt tokens.
* @return creditToYield The amount of yield tokens repaid.
*/
function _forceRepay(uint256 accountId, uint256 amount) internal returns (uint256) {
if (amount == 0) {
return 0;
}
_checkForValidAccountId(accountId);
Account storage account = _accounts[accountId];
// Query transmuter and earmark global debt
_earmark();
// Sync current user debt before deciding how much is available to be repaid
_sync(accountId);
uint256 debt;
// Burning yieldTokens will pay off all types of debt
_checkState((debt = account.debt) > 0);
uint256 credit = amount > debt ? debt : amount;
uint256 creditToYield = convertDebtTokensToYield(credit);
_subDebt(accountId, credit);
// Repay debt from earmarked amount of debt first
uint256 earmarkToRemove = credit > account.earmarked ? account.earmarked : credit;
account.earmarked -= earmarkToRemove;
// Repay debt from earmarked amount of debt first
uint256 earmarkToRemove = credit > account.earmarked ? account.earmarked : credit;
account.earmarked -= earmarkToRemove;
creditToYield = creditToYield > account.collateralBalance ? account.collateralBalance : creditToYield;
account.collateralBalance -= creditToYield;
...Impact Details
References
Proof of Concept
Proof of Concept
Previous57637 sc low acceptadminownership doesn t allow expected user approvalNext58419 sc low alchemistcurator two step ownership transfer mis implemented
Was this helpful?