Skip to content
Business logic Audit finding Advanced

Bonds created in year cross epoch’s can lead to lost payouts

Bonds created in an epoch that crosses a year boundary can reserve more OLAS than can actually be minted in the current year, because the effectiveBond calculation includes inflation from the next year. When minting fails silently due to the inflation check, depositors and agent/component owners may never receive their payouts.

hash Follow with c0pp3rscr3w3r, HChang26 and 1 other

Originally disclosed on Code4rena

Submitted by hash, also found by c0pp3rscr3w3r, HChang26, and 0xTheC0der

https://github.com/code-423n4/2023-12-autonolas/blob/2a095eb1f8359be349d23af67089795fb0be4ed1/tokenomics/contracts/Tokenomics.sol#L1037-L1038 https://github.com/code-423n4/2023-12-autonolas/blob/2a095eb1f8359be349d23af67089795fb0be4ed1/governance/contracts/OLAS.sol#L75-L84

Bond depositors and agent/component owner’s may never receive the payout Olas. Incorrect inflation control.

Proof of Concept

effectiveBond is used to account how much of Olas is available for bonding. This includes Olas that are to be minted in the current epoch ie. effectiveBond will include the Olas partitioned for bonding in epoch 5 at the beginning of epoch 5 itself. In case of epoch’s crossing YEAR intervals, a portion of the Olas would actually only be mintable in the next year due to the yearwise inflation control enforced at the mint (after 9 years due to fixed supply till 10 years). Due to silent reverts, this can lead to lost Olas payouts

The inflation for bonds are accounted using the effectiveBond variable. https://github.com/code-423n4/2023-12-autonolas/blob/2a095eb1f8359be349d23af67089795fb0be4ed1/tokenomics/contracts/Tokenomics.sol#L609-L617

    function reserveAmountForBondProgram(uint256 amount) external returns (bool success) {

       .....

        // Effective bond must be bigger than the requested amount
        uint256 eBond = effectiveBond;
        if (eBond >= amount) {

            eBond -= amount;
            effectiveBond = uint96(eBond);
            success = true;
            emit EffectiveBondUpdated(eBond);
        }
    }

This variable is updated with the estimated bond Olas at the beginning of an epoch itself.

https://github.com/code-423n4/2023-12-autonolas/blob/2a095eb1f8359be349d23af67089795fb0be4ed1/tokenomics/contracts/Tokenomics.sol#L1037-L1038

    function checkpoint() external returns (bool) {

        .....

        // Update effectiveBond with the current or updated maxBond value
        curMaxBond += effectiveBond;
        effectiveBond = uint96(curMaxBond);

In case of epochs crossing YEAR intervals after 9 years, the new Olas amount will not be fully mintable in the same year due to the inflation control check enforced in the Olas contract.

https://github.com/code-423n4/2023-12-autonolas/blob/2a095eb1f8359be349d23af67089795fb0be4ed1/governance/contracts/OLAS.sol#L75-L84

    function mint(address account, uint256 amount) external {

        ....

        // Check the inflation schedule and mint
        if (inflationControl(amount)) {
            _mint(account, amount);
        }

Whenever a deposit is made on a bond, the required Olas is minted by the treasury and transferred to the Depository contract, from where the depositor claims the payout after the vesting time. Olas.sol doesn’t revert for inflation check failure but fails silently. This can cause a deposit to succeed but corresponding redeem to fail since payout Olas has not been actually minted. It can also happen that agent/component owner’s who have not claimed the topup Olas amount will loose their reward due to silent return when minting their reward.

Example

  • Year 10, 1 month left for Year 11.
  • All Olas associated with previous epochs have been minted.
  • New epoch of 2 months is started, 1 month in Year 10 and 1 month in Year 11.
  • Total Olas for the epoch, t = year 10 1 month inflation + year 11 1 month inflation.

Year 10 1 month inflaiton (y10m1) = (1_000_000_000e18 * 2 / 100 / 12) Year 11 1 month inflation (y11m1) = (1_020_000_000e18 * 2 / 100 / 12) t = y10m1 + y11m1

  • Olas bond percentage = 50%
  • Hence effectiveBond = t/2
  • But actual mintable remaining in year 0, m = y10m1 < effectiveBond
  • A bond is created with supply == effectiveBond
  • User’s deposit for the entire bond supply but only y10m1 Olas can be minted. Depending on the nature of deposits, the actual amount minted can vary from 0 to y10m1. In case of unminted amounts(as rewards of agent/component owner’s etc.) at Year 10, this amount can be minted for bond deposits following which if agent/component owners claim within the year, no Olas will be received by them.
  • Users lose their Olas payout.

POC Test

https://gist.github.com/10xhash/2157c1f2cdc9513b3f0a7f359a65015e

Recommended Mitigation Steps

In case of multi-year epochs, separate bond amounts of next year.

kupermind (Olas) confirmed


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

Likely the effectiveBond calculation includes inflation from the next year when an epoch crosses a year boundary, but the mint function silently rejects amounts that exceed the current year's inflation limit.

Impact

Bond depositors and agent/component owners may lose their OLAS payouts because the mint fails silently when the inflation limit is exceeded.

What the attacker needed

Epoch crosses a year boundary; after 9 years of inflation; bond created with supply equal to effectiveBond

The fix

The recommended mitigation is to separate bond amounts for the next year when epochs span multiple years.

How it was found

  1. Year 10 has one month left before Year 11.
  2. A new epoch of two months starts, spanning one month in Year 10 and one month in Year 11.
  3. The total Olas for the epoch is calculated as the sum of Year 10 one-month inflation and Year 11 one-month inflation.
  4. The effectiveBond is set to half of that total (50% bond percentage).
  5. A bond is created with supply equal to effectiveBond.
  6. A user deposits for the entire bond supply, but only the Year 10 portion can actually be minted; the rest fails silently.

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 bond is a way to lock tokens and earn rewards over time. The system sets aside a pool of tokens for bonds at the start of each period, but if that period spans two calendar years, it counts tokens that are not allowed to be created until the next year. When the system later tries to create those tokens, the creation quietly fails, so people who expected rewards may get nothing.

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 hash

View all

27 more disclosed reports, best first.

More from Olas

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.