Skip to content
Business logic Audit finding Beginner

Backdated _startTimestamp can lead to loss of funds

The createPromotion function lacks a check that the start timestamp is in the future, allowing a promotion to be created with a past start date. This can cause the promotion creator's tokens to become permanently stuck in the contract because neither users nor the creator can claim or cancel the promotion.

Anurag Jain Follow

Originally disclosed on Code4rena

Submitted by csanuragjain, also found by defsec, leastwood, and pauliax

Impact

This can lead to loss of funds as there is no recovery function of funds stuck like this

Proof of Concept

  1. User A creates a new promotion using createPromotion function. By mistake he provides 1 year ago value for \_startTimestamp with promotion duration as 6 months
  2. Since there is no check to see that \_startTimestamp > block.timestamp so this promotion gets created
  3. User cannot claim this promotion if they were not having promotion tokens in the 1 year old promotion period. This means promotion amount remains with contract
  4. Even promotion creator cannot claim back his tokens since promotion end date has already passed so cancelPromotion will fail
  5. As there is no recovery token function in contract so even contract cant transfer this token and the tokens will remain in this contract with no one able to claim those

Recommended Mitigation Steps

Add below check in the createPromotion function

function createPromotion(
    address _ticket,
    IERC20 _token,
    uint216 _tokensPerEpoch,
    uint32 _startTimestamp,
    uint32 _epochDuration,
    uint8 _numberOfEpochs
) external override returns (uint256) {
    require(_startTimestamp>block.timestamp,"should be after current time");
}

PierrickGT (PoolTogether) confirmed and disagreed with severity:

It would indeed be an unfortunate event and we will implement this require. That being said, funds of the promotion creator would be at risk, because of an error he made, but not funds of a user, so I consider this bug as being of severity 2 (Med Risk) and not 3 (High Risk).

LSDan (judge) commented:

Per the Judge Onboarding document provided by Code423n4, this qualifies as a high risk issue. A UI bug or simple mistake could cause complete loss of funds as sponsor acknowledged.

3 — High (H): vulns have a risk of 3 and are considered “High” severity when assets can be stolen/lost/compromised directly (or indirectly if there is a valid attack path that does not have hand-wavy hypotheticals).

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

Impact

The promotion creator's funds could be permanently locked in the contract, though the sponsor noted that user funds are not at risk.

What the attacker needed

Promotion creator makes a mistake with start date

The fix

The createPromotion function should be fixed by adding a require statement that the start timestamp is greater than the current block timestamp.

How it was found

  1. User A calls createPromotion with a start timestamp one year in the past and a duration of six months.
  2. The promotion is created because there is no check that the start timestamp is in the future.
  3. Users cannot claim the promotion because they did not hold promotion tokens during the past promotion period.
  4. The promotion creator cannot cancel the promotion because the end date has already passed, so cancelPromotion fails.
  5. The tokens remain stuck in the contract because there is no recovery function.

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 smart contract lets people create promotions with tokens. If someone accidentally sets the start date in the past, the contract doesn't stop them. Then nobody can claim the tokens, and the creator can't get them back, so the tokens are stuck forever.

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 Anurag Jain

View all

63 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.

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.