Skip to content
Business logic Audit finding Intermediate

Not handling return value of transferFrom command can create inconsistency

The contract calls transferFrom on a token but does not check its return value, so a failed transfer still emits an event. This can cause downstream applications to record a wrong transaction or protocol state.

hubble Follow

Originally disclosed on Code4rena

Submitted by hubble

https://github.com/code-423n4/2022-03-joyn/blob/c9297ccd925ebb2c44dbc6eaa3effd8db5d2368a/core-contracts/contracts/CoreCollection.sol#L175-L176

https://github.com/code-423n4/2022-03-joyn/blob/c9297ccd925ebb2c44dbc6eaa3effd8db5d2368a/core-contracts/contracts/ERC721Payable.sol#L54-L55

Vulnerability details

The below transferFrom command is called at two places in the core contracts, followed by an emit event

payableToken.transferFrom(msg.sender,recipient,_amount)
emit ...(...);

The return value is not checked during the payableToken.transferFrom

Impact

In the event of failure of payableToken.transferFrom(…), the emit event is still generated causing the downstream applications to capture wrong transaction / state of the protocol.

Proof of Concept

  1. Contract CoreCollection.sol function withdraw()
  2. Contract ERC721Payable.sol function _handlePayment

Recommended Mitigation Steps

Add a require statement as being used in the RoyaltyVault.sol

require( payableToken.transferFrom(msg.sender,recipient,_amount) == true,
            "Failed to transfer amount to recipient" );

sofianeOuafir (Joyn) confirmed, disagreed with severity and commented:

In my opinion, the severity level should be 3 (High Risk) instead of 2 (Med Risk) duplicate of #52

deluca-mike (judge) commented:

No longer a duplicate because this issue pertains specifically to the false emission of events when an underlying call would have failed.


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

If the token transfer fails, an event is still emitted, which could mislead downstream applications about the transaction or protocol state.

What the attacker needed

A token whose transferFrom returns false on failure

The fix

The code should check the return value of transferFrom with a require statement, as done in RoyaltyVault.sol.

How it was found

  1. Call the withdraw function in CoreCollection.sol.
  2. Call the _handlePayment function in ERC721Payable.sol.

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 moves tokens by calling a function that returns true or false to say if it worked. Here the code ignores that answer and always announces success, so other programs listening may believe a transfer happened when it did not.

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 hubble

View all

11 more disclosed reports, best first.

More from Joyn contest

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.