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

Malicious state update after transfer

Summary

In `Escrow.sol`, the state update to `set _escrow[collection][id] = address(0x0)` happens after an attempt on transfer.

Vulnerability Details

The malicious state update could be problematic since if the transfer fails for some reason (e.g., the safeTransferFrom function reverts or throws an exception), `_escrow` mapping would not be updated.
```javascript
if (collectionType == CollectionType.ERC721) {
IERC721(collection).safeTransferFrom(from, to, id);
} else {
// TODO:
// Check here if the token supply is currently 0.
IERC1155(collection).safeTransferFrom(from, to, id, 1, "");
}
@> _escrow[collection][id] = address(0x0);
```

Impact

The consequence of this error could cheat the system that the asset is escrowed even though the transfer did not actually occur. SUch can cause inconsistencies and potential exploits.

Tools Used

Manual Review

Recommendations

Ensure that the state update is happening before transfer happens. Therefore, consider moving the line `_escrow[collection][id] = address(0x0)` before token transfer. Hence, even if the transfer has failed, the state of the escrow would still be updated correctly.
```javascript
@> _escrow[collection][id] = address(0x0);
if (collectionType == CollectionType.ERC721) {
IERC721(collection).safeTransferFrom(from, to, id);
} else {
IERC1155(collection).safeTransferFrom(from, to, id, 1, "");
}
```
Updates

Lead Judging Commences

n0kto Lead Judge 10 months ago
Submission Judgement Published
Invalidated
Reason: Incorrect statement

Support

FAQs

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