Always validate signatures for all types

This commit is contained in:
Amir Bandeali
2019-10-04 18:20:37 -07:00
parent d3dcf7fb0c
commit e2e5152648
2 changed files with 9 additions and 51 deletions

View File

@@ -366,29 +366,19 @@ contract MixinExchangeCore is
}
}
// Validate either on the first fill or if the signature type requires
// regular validation.
address makerAddress = order.makerAddress;
if (orderInfo.orderTakerAssetFilledAmount == 0 ||
_doesSignatureRequireRegularValidation(
// Validate signature
if (!_isValidOrderWithHashSignature(
order,
orderInfo.orderHash,
makerAddress,
signature
)
) {
if (!_isValidOrderWithHashSignature(
order,
orderInfo.orderHash,
signature
)
) {
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
LibExchangeRichErrors.SignatureErrorCodes.BAD_ORDER_SIGNATURE,
orderInfo.orderHash,
makerAddress,
signature
));
}
LibRichErrors.rrevert(LibExchangeRichErrors.SignatureError(
LibExchangeRichErrors.SignatureErrorCodes.BAD_ORDER_SIGNATURE,
orderInfo.orderHash,
order.makerAddress,
signature
));
}
}

View File

@@ -169,38 +169,6 @@ contract MixinSignatureValidator is
return isValid;
}
/// @dev Checks if a signature is of a type that should be verified for
/// every action.
/// @param hash The hash of the order/transaction.
/// @param signerAddress The address of the signer.
/// @param signature The signature for `hash`.
/// @return needsRegularValidation True if the signature should be validated
/// for every action.
function _doesSignatureRequireRegularValidation(
bytes32 hash,
address signerAddress,
bytes memory signature
)
internal
pure
returns (bool needsRegularValidation)
{
// Read the signatureType from the signature
SignatureType signatureType = _readSignatureType(
hash,
signerAddress,
signature
);
// Any signature type that makes an external call needs to be revalidated
// with every partial fill
needsRegularValidation =
signatureType == SignatureType.Wallet ||
signatureType == SignatureType.Validator ||
signatureType == SignatureType.EIP1271Wallet;
return needsRegularValidation;
}
/// @dev Verifies that an order, with provided order hash, has been signed
/// by the given signer.
/// @param order The order.