Use safeTransfer/safeTransferFrom consistently instead of transfer/transferFrom
The contract used transfer/transferFrom without checking return values, so a token that fails silently could cause transfers to appear successful while token accounting is wrong. This could lead to a loss of funds under the right external conditions.
Submitted by cccz, also found by 0x1f8b, bobi, byterocket, Dravee, hack3r-0m, sirhashalot, TomFrenchBlockchain, UncleGrandpa925, and WatchPug
It is good to add a require() statement that checks the return value of token transfers or to use something like OpenZeppelin’s safeTransfer/safeTransferFrom unless one is sure the given token reverts in case of a failure. Failure to do so will cause silent failures of transfers and affect token accounting in contract.
Proof of Concept
https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/LaunchEvent.sol#L457
https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/LaunchEvent.sol#L463
https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/LaunchEvent.sol#L489
https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/LaunchEvent.sol#L513
https://github.com/code-423n4/2022-01-trader-joe/blob/main/contracts/LaunchEvent.sol#L537
Recommended Mitigation Steps
Consider using safeTransfer/safeTransferFrom or require() consistently.
cryptofish7 (Trader Joe) confirmed and commented:
Fix: https://github.com/traderjoe-xyz/rocket-joe/commit/9e11786ffbfe71f324bc67411270900ec21355fc
LSDan (judge) increased severity from Low to Medium and commented:
This could result in a loss of funds given the right external conditions.
2 — Med (M): vulns have a risk of 2 and are considered “Medium” severity when assets are not at direct risk, but the function of the protocol or its availability could be impacted, or leak value with a hypothetical attack path with stated assumptions, but external requirements.
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
This could result in a loss of funds given the right external conditions.
What the attacker needed
A token that returns false on failure; external conditions
The fix
The issue was fixed by using safeTransfer/safeTransferFrom or require() consistently.
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.
Some tokens don't revert when a transfer fails; they just return false. If the contract ignores that return value, it may think the transfer worked and update its records incorrectly, which can lose money. Using safeTransfer or checking the return value prevents this.
What is Smart contracts?
Flaws in on-chain code that let an attacker drain funds, freeze them or break the protocol's accounting.