Skip to content
Access control Audit finding Beginner

Anyone can set the baseRatePerYear after the updateFrequency has passed

The updateBaseRate function is public and lacks access control, allowing anyone to set the baseRatePerYear after the updateFrequency period has passed. An attacker could change the interest rate, negatively affecting borrow and supply rates and potentially causing economic exploits or bricking integrating contracts.

0xDjango Follow

Originally disclosed on Code4rena

Submitted by 0xDjango, also found by 0x52, Chom, csanuragjain, JMukesh, k, oyc_109, Picodes, Soosh, and WatchPug

https://github.com/Plex-Engineer/lending-market/blob/755424c1f9ab3f9f0408443e6606f94e4f08a990/contracts/NoteInterest.sol#L118-L129

The updateBaseRate() function is public and lacks access control, so anyone can set the critical variable baseRatePerYear once the block delta has surpassed the updateFrequency variable. This will have negative effects on the borrow and supply rates used anywhere else in the protocol.

The updateFrequency is explained to default to 24 hours per the comments, so this vulnerability will be available every day. Important to note, the admin can fix the baseRatePerYear by calling the admin-only _setBaseRatePerYear() function. However, calling this function does not set the lastUpdateBlock so users will still be able to change the rate back after the 24 hours waiting period from the previous change.

Proof of Concept

    function updateBaseRate(uint newBaseRatePerYear) public {
        // check the current block number
        uint blockNumber = block.number;
        uint deltaBlocks = blockNumber.sub(lastUpdateBlock);

        if (deltaBlocks > updateFrequency) {
            // pass in a base rate per year
            baseRatePerYear = newBaseRatePerYear;
            lastUpdateBlock = blockNumber;
            emit NewInterestParams(baseRatePerYear);
        }
    }

Recommended Mitigation Steps

I have trouble understanding the intention of this function. It appears that the rate should only be able to be set by the admin, so the _setBaseRatePerYear() function seems sufficient. Otherwise, add access control for only trusted parties.

tkkwon1998 (Canto) confirmed

Alex the Entreprenerd (judge) commented:

The warden has shown how, due to probably an oversight, a core function that has impact in determining the yearly interest rate was left open for anyone to change once every 24 hrs.

Because the impact is:

  • Potential bricking of integrating contracts
  • Economic exploits

And anyone can perform it

I believe that High Severity is appropriate.

Mitigation requires either deleting the function or adding access control.


The original report as published on Code4rena, by 0xDjango. 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

Root cause

The updateBaseRate function lacks access control, allowing any user to call it and modify the baseRatePerYear after the updateFrequency period.

Impact

An attacker could change the interest rate, potentially causing economic exploits or bricking integrating contracts.

What the attacker needed

None

The fix

The function should be removed or access control should be added to restrict it to trusted parties.

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 a smart contract, some functions are meant to be called only by the administrator. Here, a function that sets a key interest rate can be called by anyone after a certain time has passed. This means an attacker could change the rate to something harmful, affecting how much interest people pay or earn.

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 0xDjango

View all

23 more disclosed reports, best first.

More from Canto

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.