Skip to content
DoS Audit finding Intermediate

depositAndFix can be made to fail

The depositAndFix function in TempusController contains an assert that checks the contract's yield share balance is zero after a swap. An attacker can frontrun the call by sending a tiny amount of yield shares to the contract, causing the assert to fail and the transaction to revert.

cmichel Follow

Originally disclosed on Code4rena

Submitted by cmichel.

There’s a griefing attack where an attacker can make any user transaction for TempusController.depositAndFix fail. In _depositAndFix, swapAmount many yield shares are swapped to principal where swapAmount is derived from the function arguments. A final assert(yieldShares.balanceOf(address(this)) == 0) statement checks that the yield shares of the contract are zero after the swap. This is only true if no other yield shares were already in the contract.

However, an attacker can frontrun this call and send the smallest unit of yield shares to the contract which then makes the original deposit-and-fix transaction fail.

Impact

All depositAndFix calls can be made to fail and this function becomes unusable.

Recommended Mitigation Steps

Remove the assert check.

mijovic confirmed:

Good catch. This can block users from doing this action via controller

mijovic patched:

Fixed in https://github.com/tempus-finance/tempus-protocol/pull/370

The original report as published on Code4rena, by cmichel. 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 contract uses an assert to check that its yield share balance is zero after a swap, but it does not account for pre-existing yield shares that an attacker can add beforehand.

Impact

All depositAndFix calls can be made to fail, making the function unusable.

What the attacker needed

Attacker can frontrun transactions; attacker has a tiny amount of yield shares

The fix

The assert check was removed, and the fix was confirmed by the project.

How it was found

  1. Attacker observes a pending depositAndFix transaction.
  2. Attacker frontruns it by sending the smallest unit of yield shares to the contract.
  3. The original depositAndFix transaction executes and the assert fails, causing a revert.

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 griefing attack where someone makes another person's transaction fail without gaining anything. The function assumes the contract has no yield shares before it runs, but an attacker can send a tiny amount first, so the final check fails and the whole transaction is cancelled.

What is DoS?

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.

More by cmichel

View all

196 more disclosed reports, best first.

More from Tempus Finance contest

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Denial of service

The lesson behind this report.

A request that exhausts resources or crashes a component. Many programs forbid testing it; reports usually show it from code, not by attacking.