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.
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
- User A creates a new promotion using createPromotion function. By mistake he provides 1 year ago value for
\_startTimestampwith promotion duration as 6 months - Since there is no check to see that
\_startTimestamp > block.timestampso this promotion gets created - 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
- Even promotion creator cannot claim back his tokens since promotion end date has already passed so
cancelPromotionwill fail - 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).
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).
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
- User A calls createPromotion with a start timestamp one year in the past and a duration of six months.
- The promotion is created because there is no check that the start timestamp is in the future.
- Users cannot claim the promotion because they did not hold promotion tokens during the past promotion period.
- The promotion creator cannot cancel the promotion because the end date has already passed, so cancelPromotion fails.
- 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.