Skip to content
Business logic Audit finding Intermediate

Lack of burn mechanism for JUSD repayments causes oversupply of JUSD

The JUSDBank contract allows users to repay JUSD debt by transferring JUSD tokens to itself, but it never burns those tokens, so the JUSD supply grows without being backed by collateral. This oversupply could destabilise JUSD and potentially cause a depeg.

Ruhum Follow with igingu, immeas and 1 other

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-04-jojo-judging/issues/306

Found by

Ruhum, igingu, immeas, peakbolt

Summary

JUSDBank.repay() allow users to repay their JUSD debt and interest by transfering in JUSD tokens. Without a burn mechanism, it will cause an oversupply of JUSD that is no longer backed by any collateral.

Vulnerability Detail

JUSDBank receives JUSD tokens for the repayment of debt and interest. However, there are no means to burn these tokens, causing JUSD balance in JUSDBank to keep increasing.

That will lead to an oversupply of JUSD that is not backed by any collateral. And the oversupply of JUSD will increase significantly during market due to mass repayments from liquidation.

https://github.com/sherlock-audit/2023-04-jojo/blob/main/JUSDV1/src/Impl/JUSDBank.sol#L307-L330

Solidity
    function _repay(
        DataTypes.UserInfo storage user,
        address payer,
        address to,
        uint256 amount,
        uint256 tRate
    ) internal returns (uint256) {
        require(amount != 0, JUSDErrors.REPAY_AMOUNT_IS_ZERO);
        uint256 JUSDBorrowed = user.t0BorrowBalance.decimalMul(tRate);
        uint256 tBorrowAmount;
        uint256 t0Amount;
        if (JUSDBorrowed <= amount) {
            tBorrowAmount = JUSDBorrowed;
            t0Amount = user.t0BorrowBalance;
        } else {
            tBorrowAmount = amount;
            t0Amount = amount.decimalDiv(tRate);
        }
        IERC20(JUSD).safeTransferFrom(payer, address(this), tBorrowAmount);
        user.t0BorrowBalance -= t0Amount;
        t0TotalBorrowAmount -= t0Amount;
        emit Repay(payer, to, tBorrowAmount);
        return tBorrowAmount;
    }

Impact

To maintain its stability, JUSD must always be backed by more than 1 USD worth of collateral.

When there is oversupply of JUSD that is not backed by any collateral, it affects JUSD stability and possibly lead to a depeg event.

Code Snippet

https://github.com/sherlock-audit/2023-04-jojo/blob/main/JUSDV1/src/Impl/JUSDBank.sol#L307-L330

Tool used

Manual review

Recommendation

Instead of transfering to the JUSDBank upon repayment, consider adding a burn mechanism to reduce the supply of JUSD so that it will be adjusted automatically.

Discussion

JoscelynFarr

Will add burn mechanism in the contract

JoscelynFarr

fix link: https://github.com/JOJOexchange/JUSDV1/commit/a72604efba3a9cbce997aefde742be4c5036a039

IAm0x52

Fix looks good. Excess JUSD can now be refunded by the owner

The original report as published on Sherlock, by Ruhum. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

The repayment function transfers JUSD tokens to the contract but does not burn them, so the total supply of JUSD increases without a corresponding increase in collateral.

Impact

The oversupply of unbacked JUSD could affect JUSD stability and possibly lead to a depeg event.

What the attacker needed

Users repay JUSD debt; no burn mechanism exists

The fix

A burn mechanism was added so that JUSD repaid is burned, reducing the supply, and the owner can refund excess JUSD.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

JUSD is a stablecoin that should always be backed by collateral worth at least one US dollar per token. When users repay their loans, the JUSD they send back is not destroyed, so the total supply of JUSD keeps growing even though the collateral does not. This can make the stablecoin lose its peg to the dollar.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by Ruhum

View all

55 more disclosed reports, best first.

More from JOJO Exchange

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.