Skip to content

Commit

Permalink
Merge pull request #457 from axic/unused-params
Browse files Browse the repository at this point in the history
Revert on dirty bits (unused item parameters)
  • Loading branch information
0age authored Jun 8, 2022
2 parents 256c420 + 00a8285 commit 5eb8906
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
4 changes: 4 additions & 0 deletions contracts/conduit/Conduit.sol
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ contract Conduit is ConduitInterface, TokenTransferrer {
function _transfer(ConduitTransfer calldata item) internal {
// Determine the transfer method based on the respective item type.
if (item.itemType == ConduitItemType.ERC20) {
if (item.identifier != 0) {
revert UnusedItemParameters();
}

// Transfer ERC20 token. Note that item.identifier is ignored and
// therefore ERC20 transfer items are potentially malleable — this
// check should be performed by the calling channel if a constraint
Expand Down
7 changes: 7 additions & 0 deletions contracts/interfaces/TokenTransferrerErrors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,13 @@ interface TokenTransferrerErrors {
*/
error MissingItemAmount();

/**
* @dev Revert with an error when attempting to fulfill an order where an
* item has the unused parameters, this includes token and identifier
* for native transfers and identifier for ERC20 transfers.
*/
error UnusedItemParameters();

/**
* @dev Revert with an error when an ERC20, ERC721, or ERC1155 token
* transfer reverts.
Expand Down
4 changes: 4 additions & 0 deletions contracts/lib/BasicOrderFulfiller.sol
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ contract BasicOrderFulfiller is OrderValidator {

// Transfer tokens based on the route.
if (additionalRecipientsItemType == ItemType.NATIVE) {
if ((uint160(parameters.considerationToken) | parameters.considerationIdentifier) != 0) {
revert UnusedItemParameters();
}

_transferIndividual721Or1155Item(
offeredItemType,
parameters.offerToken,
Expand Down
8 changes: 8 additions & 0 deletions contracts/lib/Executor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,17 @@ contract Executor is Verifiers, TokenTransferrer {
) internal {
// If the item type indicates Ether or a native token...
if (item.itemType == ItemType.NATIVE) {
if ((uint160(item.token) | item.identifier) != 0) {
revert UnusedItemParameters();
}

// transfer the native tokens to the recipient.
_transferEth(item.recipient, item.amount);
} else if (item.itemType == ItemType.ERC20) {
if (item.identifier != 0) {
revert UnusedItemParameters();
}

// Transfer ERC20 tokens from the source to the recipient.
_transferERC20(
item.token,
Expand Down

0 comments on commit 5eb8906

Please sign in to comment.