Skip to content
Smart contracts Audit finding Intermediate

SafeMath not completely used in yield source contracts

Some arithmetic operations in yield source contracts do not use the SafeMath library, which could allow integer underflow or overflow. An attacker could potentially exploit this to disrupt the yield sources.

shw Follow

Originally disclosed on Code4rena

Submitted by shw, also found by cmichel

SafeMath is not completely used at the following lines of yield source contracts, which could potentially cause arithmetic underflow and overflow:

  1. line 78 in SushiYieldSource
  2. line 67 in BadgerYieldSource
  3. line 91 and 98 in IdleYieldSource

Recommend using the SafeMath library functions in the above lines.

asselstine (PoolTogether) confirmed and disagreed with severity:

While the arithmetic ceiling is quite high, if an overflow occurred this would significantly disrupt the yield sources. I’d qualify this issue higher as 2 (Med Risk).

dmvt (judge) commented:

I agree with the sponsor’s risk evaluation. Increasing to medium.

The original report as published on Code4rena, by shw. 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 developers omitted SafeMath in certain arithmetic operations, leaving them vulnerable to integer overflow/underflow.

Impact

If an overflow occurred, it could significantly disrupt the yield sources, though the arithmetic ceiling is quite high.

What the attacker needed

None

The fix

The recommendation is to use SafeMath library functions in the identified lines.

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.

SafeMath is a set of functions that prevent numbers from wrapping around when they get too big or too small. Without it, a calculation could produce an unexpected result, which might break the contract or be abused.

What is Smart contracts?

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.

More by shw

View all

22 more disclosed reports, best first.

More from PoolTogether

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Smart contract vulnerabilities

The lesson behind this report.

Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.