NFTBridge
60,000 USDC
View results
Submission Details
Severity: low
Invalid

Inadequate Token Supply Checks

Summary

The _depositIntoEscrow and _withdrawFromEscrow functions assume that token deposits and withdrawals are valid without verifying the token supply, especially for ERC1155 tokens.

Vulnerability Details

For ERC1155 tokens, the contract assumes that the token ID has exactly one unit in supply for deposits and withdrawals. This assumption may not hold if the token contract's supply is managed differently.

Impact

If the actual supply of a token ID does not match the assumptions in the contract, it may lead to unexpected behavior, including failed transactions or incorrect token balances.

Tools Used

Manual Code Review

Recommendations

Verify the token supply before performing operations. For ERC1155 tokens, you can use the balanceOf function to check the balance:

function _depositIntoEscrow(
CollectionType collectionType,
address collection,
uint256[] memory ids
)
internal
{
assert(ids.length > 0);
for (uint256 i = 0; i < ids.length; i++) {
uint256 id = ids[i];
if (collectionType == CollectionType.ERC721) {
IERC721(collection).transferFrom(msg.sender, address(this), id);
} else {
uint256 balance = IERC1155(collection).balanceOf(msg.sender, id);
require(balance > 0, "Token balance must be greater than 0");
IERC1155(collection).safeTransferFrom(msg.sender, address(this), id, 1, "");
}
_escrow[collection][id] = msg.sender;
}
}
function _withdrawFromEscrow(
CollectionType collectionType,
address collection,
address to,
uint256 id
)
internal
returns (bool)
{
if (!_isEscrowed(collection, id)) {
return false;
}
address from = address(this);
if (collectionType == CollectionType.ERC721) {
IERC721(collection).safeTransferFrom(from, to, id);
} else {
uint256 balance = IERC1155(collection).balanceOf(from, id);
require(balance > 0, "Token balance must be greater than 0");
IERC1155(collection).safeTransferFrom(from, to, id, 1, "");
}
_escrow[collection][id] = address(0x0);
return true;
}
Updates

Lead Judging Commences

n0kto Lead Judge 11 months ago
Submission Judgement Published
Invalidated
Reason: Out of scope
Assigned finding tags:

invalid-ERC1155-not-in-scope

```compatibilities: Blockchains: - Ethereum/Starknet Tokens: - [ERC721](www.tokenstandard.com) ``` ``` function depositTokens( uint256 salt, address collectionL1, snaddress ownerL2, uint256[] calldata ids, bool useAutoBurn ) external payable { if (!Cairo.isFelt252(snaddress.unwrap(ownerL2))) { revert CairoWrapError(); } if (!_enabled) { revert BridgeNotEnabledError(); } CollectionType ctype = TokenUtil.detectInterface(collectionL1); if (ctype == CollectionType.ERC1155) { @> revert NotSupportedYetError(); } … } ```

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.