Skip to content
Access control Audit finding Beginner

Lack of access control for `mintRebalancer()` and `burnRebalancer()`

Two token functions that should only be callable by the rebalancer contract had no access control, so anyone could mint or burn tokens held by the contract itself. An attacker could mint a near-maximum amount, blocking further minting and distorting the supply figures the rebalancer relies on.

0x2e Follow with 0xAzez, 0xHati and 47 others

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-05-USSD-judging/issues/777

Found by

0x2e, 0xAzez, 0xHati, 0xMojito, 0xPkhatri, 0xRobocop, 0xSmartContract, 0xStalin, 0xeix, 0xyPhilic, 14si2o_Flint, AlexCzm, Angry_Mustache_Man, Aymen0909, Bahurum, Bauchibred, Bauer, BlockChomper, Brenzee, BugBusters, BugHunter101, Delvir0, DevABDee, Dug, Fanz, GimelSec, HonorLt, J4de, JohnnyTime, Juntao, Kodyvim, Kose, Lilyjjo, Madalad, Nyx, PokemonAuditSimulator, RaymondFam, Saeedalipoor01988, SanketKogekar, Schpiel, SensoYard, T1MOH, TheNaubit, Tricko, VAD37, Vagner, WATCHPUG, __141345__, anthony, ast3ros, auditsea, berlin-101, blackhole, blockdev, carrotsmuggler, chainNue, chalex.eth, cjm00n, coincoin, coryli, ctf_sec, curiousapple, dacian, evilakela, georgits, giovannidisiena, immeas, innertia, jah, juancito, kie, kiki_dev, lil.eth, m4ttm, mahdikarimi, mrpathfindr, n33k, neumo, ni8mare, nobody2018, pavankv241, pengun, qbs, qckhp, qpzm, ravikiran.web3, saidam017, sam_gmk, sashik_eth, shaka, shealtielanz, shogoki, simon135, slightscan, smiling_heretic, tallo, theOwl, the_endless_sea, toshii, tsvetanovv, tvdung94, twcctop, twicek, vagrant, ver0759, warRoom, whiteh4t9527, ww4tson, yy

Summary

Lack of access control in USSD.mintRebalancer() and USSD.burnRebalancer() can lead to a denial-of-service attack and malfunction of the rebalancer as it can alter totalSupply, which is used in rebalancer.SellUSSDBuyCollateral to calculate ownval.

Vulnerability Detail

Based on the context, USSD.mintRebalancer() should be onlyBalancer as it should only be allowed to be called by the rebalancer.

However, both USSD.mintRebalancer() and USSD.burnRebalancer() lack access control in the current implementation.

Impact

An attacker can mint an amount of type(uint256).max - totalSupply() and cause a denial-of-service attack by preventing anyone else from minting.

Additionally, minting will also change the totalSupply which alters the collateralFactor and cause the rebalancer to malfunction, as the SellUSSDBuyCollateral() function relies on the USSD.collateralFactor().

The totalSupply is also used in rebalancer.SellUSSDBuyCollateral to calculate the ownval.

Code Snippet

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/USSD.sol#L204-L210

Solidity
function mintRebalancer(uint256 amount) public override {
    _mint(address(this), amount);
}

function burnRebalancer(uint256 amount) public override {
    _burn(address(this), amount);
}

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/USSDRebalancer.sol#L92-L107

Solidity
    function rebalance() override public {
      uint256 ownval = getOwnValuation();
      (uint256 USSDamount, uint256 DAIamount) = getSupplyProportion();
      if (ownval < 1e6 - threshold) {
        // peg-down recovery
        BuyUSSDSellCollateral((USSDamount - DAIamount / 1e12)/2);
      } else if (ownval > 1e6 + threshold) {
        // mint and buy collateral
        // never sell too much USSD for DAI so it 'overshoots' (becomes more in quantity than DAI on the pool)
        // otherwise could be arbitraged through mint/redeem
        // the execution difference due to fee should be taken into accounting too
        // take 1% safety margin (estimated as 2 x 0.5% fee)
        IUSSD(USSD).mintRebalancer(((DAIamount / 1e12 - USSDamount)/2) * 99 / 100); // mint ourselves amount till balance recover
        SellUSSDBuyCollateral();
      }
    }

https://github.com/sherlock-audit/2023-05-USSD/blob/main/ussd-contracts/contracts/USSD.sol#L179-L194

Solidity
function collateralFactor() public view override returns (uint256) {
    uint256 totalAssetsUSD = 0;
    for (uint256 i = 0; i < collateral.length; i++) {
        totalAssetsUSD +=
            (((IERC20Upgradeable(collateral[i].token).balanceOf(
                address(this)
            ) * 1e18) /
                (10 **
                    IERC20MetadataUpgradeable(collateral[i].token)
                        .decimals())) *
                collateral[i].oracle.getPriceUSD()) /
            1e18;
    }

    return (totalAssetsUSD * 1e6) / totalSupply();
}

Tool used

Manual Review

Recommendation

USSD.mintRebalancer() should be onlyBalancer.

The original report as published on Sherlock, by 0x2e. 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 mint and burn functions were declared public with no caller restriction, so the intended rebalancer-only guard was missing.

Impact

An attacker could mint up to the maximum supply minus current supply, preventing anyone else from minting and causing the rebalancer to malfunction through altered supply and collateral factor values.

What the attacker needed

No special access needed; attacker can call the contract directly

The fix

The mint function should be restricted to the rebalancer contract, and the burn function should be similarly guarded.

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.

A smart contract can have functions meant to be used only by another trusted contract. Here those functions had no check on who was calling, so any outside address could use them. That let anyone create a huge number of tokens, which broke the maths the system uses to keep its stablecoin balanced.

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.

More by 0x2e

View all

2 more disclosed reports, best first.

More from USSD - Autonomous Secure Dollar

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Broken access control

The lesson behind this report.

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.