CNft.sol - revert inside safeTransferFrom will break composability & standard behaviour
The CNft contract's safeTransferFrom function always reverts, violating the ERC1155 standard which requires it to succeed for valid transfers. This could break other protocols that integrate CNft and rely on the standard function, causing their operations to fail.
Submitted by hubble
The function safeTransferFrom is a standard interface in ERC1155, and its expected to succeed if all the parametes are valid, and revert on error, which is not the case here so its a deviation.
Refer to the EIP-1155 safeTransferFrom rules:
MUST revert if _to is the zero address. MUST revert if balance of holder for token _id is lower than the _value sent to the recipient. MUST revert on any other error.
There is no loss of assets, but the assets or tokens and CNft contract can be unusable by other protocols, and likelihood & impact of this issue is high.
Impact
If other protocols want to integrate CNft, then in that case just for CNft Contract / tokens, they have to take exception and use safeBatchTransferFrom, instead of safeTransferFrom. If they dont take care of this exception, then their protocol functions will fail while using CNft, even if valid values are given.
Proof of Concept
Contract : CNft.sol Function : safeTransferFrom
Line 204 revert(“CNFT: Use safeBatchTransferFrom instead”);
Recommended Mitigation Steps
Instead of revert, call function safeBatchTransferFrom with 1 item in the array, e.g.,
safeBatchTransferFrom(from, to, [id], [amount], data)
bunkerfinance-dev (bunker.finance) confirmed, but disagreed with High severity and commented:
We can fix this, but we do not feel like this is high severity at all.
gzeon (judge) decreased severity to Medium and commented:
I think this is a Med Risk issue as it impacts the function of the protocol.
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 safeTransferFrom function was intentionally implemented to always revert with a message telling users to use safeBatchTransferFrom instead, which violates the ERC1155 standard.
Impact
Protocols integrating CNft that call safeTransferFrom will have their functions fail, potentially making the token unusable in those systems, though no assets are lost.
What the attacker needed
None
The fix
The function should be changed to call safeBatchTransferFrom with a single-item array instead of reverting.
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.
ERC1155 is a standard for digital tokens on Ethereum. It says that a function called safeTransferFrom should work when you try to send tokens to someone. But this contract always makes that function fail, even when the transfer is valid. That means other apps that try to use this token in the normal way will break.
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.