Skip to content
Business logic Audit finding Intermediate

BondBaseSDA.setDefaults doesn't validate inputs

The setDefaults function in BondBaseSDA lacks input validation, allowing an authorised caller to set parameters that break market creation or closing logic. For example, setting minDepositInterval larger than minMarketDuration prevents new markets from being created.

rvierdiiev Follow

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2022-11-bond-judging/issues/11

Found by

rvierdiiev

Summary

BondBaseSDA.setDefaults doesn't validate inputs which can lead to initializing new markets incorrectly

Vulnerability Detail

https://github.com/sherlock-audit/2022-11-bond/blob/main/src/bases/BondBaseSDA.sol#L348-L356

Solidity
    function setDefaults(uint32[6] memory defaults_) external override requiresAuth {
        // Restricted to authorized addresses
        defaultTuneInterval = defaults_[0];
        defaultTuneAdjustment = defaults_[1];
        minDebtDecayInterval = defaults_[2];
        minDepositInterval = defaults_[3];
        minMarketDuration = defaults_[4];
        minDebtBuffer = defaults_[5];
    }

Function BondBaseSDA.setDefaults doesn't do any checkings, as you can see. Because of that it's possible to provide values that will break market functionality.

For example you can set minDepositInterval to be bigger than minMarketDuration and it will be not possible to create new market.

Or you can provide minDebtBuffer to be 100% ot 0% that will break logic of market closing.

Impact

Can't create new market or market logic will be not working as designed.

Code Snippet

Provided above

Tool used

Manual Review

Recommendation

Add input validation.

Discussion

Evert0x

Message from sponsor


Agree. We added the following validation checks to setDefaults:

  • defaultTuneInterval >= defaultTuneAdjustment
  • defaultTuneInterval >= minDepositInterval
  • minMarketDuration >= minDepositInterval
  • minDebyDecayInterval >= 5 * minDepositInterval

xiaoming9090

Fixed in https://github.com/Bond-Protocol/bonds/commit/141c286cccb7797f8cca68edaf9b886f12897405

The original report as published on Sherlock, by rvierdiiev. 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 setDefaults function assigns values to state variables without validating their relationships or ranges.

Impact

An authorised caller could set parameters that prevent new markets from being created or cause market closing logic to malfunction.

What the attacker needed

Authorised caller

The fix

The sponsor added validation checks to setDefaults, such as ensuring defaultTuneInterval is at least defaultTuneAdjustment and minMarketDuration is at least minDepositInterval.

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.

This is a smart contract function that sets default values for a bond market. Because it does not check that the values make sense together, someone with permission could set them to bad combinations, like a minimum deposit time longer than the minimum market duration, which stops new markets from being created.

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 rvierdiiev

View all

72 more disclosed reports, best first.

More from Bond Options

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.