Request validation should not throw if verifyingContract is not defined in typed signature#328
Request validation should not throw if verifyingContract is not defined in typed signature#328
Conversation
…ed in typed signature
| } = parseTypedMessage(data); | ||
| if (!isValidHexAddress(verifyingContract)) { | ||
| const { domain: { verifyingContract } = {} } = parseTypedMessage(data); | ||
| if (verifyingContract && !isValidHexAddress(verifyingContract)) { |
There was a problem hiding this comment.
Does it matter if verifyingContract is an empty string?
There was a problem hiding this comment.
An empty value will not throw error.
There was a problem hiding this comment.
I think @jiexi meant to ask should it throw an error.
I've just tested with v12.0.6 and it looks like an empty verifyingContract was accepted though, so continuing to accept it sounds reasonable for now. It did trigger a blockaid warning on v12.0.6, but no crash, and I was able to sign it.
Gudahtt
left a comment
There was a problem hiding this comment.
LGTM! Some test cleanup suggested, but the tests were already pretty messy to start with
There was a problem hiding this comment.
Nit: It looks like we're testing the case where the domain is in the type definition given for the message, but missing from the message itself. It would also be useful to test these cases:
- The type definition omits
verifyingContract, anddomainis missing from the message - The type definition includes
verifyingContract, anddomainis included in the message, butverifyingContractis missing
| const promise = pify(engine.handle).call(engine, payload); | ||
| const result = await promise; |
There was a problem hiding this comment.
Nit: Unnecessary deferred Promise:
| const promise = pify(engine.handle).call(engine, payload); | |
| const result = await promise; | |
| const result = await pify(engine.handle).call(engine, payload); |
| const promise = pify(engine.handle).call(engine, payload); | ||
| const result = await promise; |
There was a problem hiding this comment.
Nit: Unnecessary deferred Promise:
| const promise = pify(engine.handle).call(engine, payload); | |
| const result = await promise; | |
| const result = await pify(engine.handle).call(engine, payload); |
| const witnessedMsgParams: TypedMessageParams[] = []; | ||
| const processTypedMessageV3 = async (msgParams: TypedMessageParams) => { | ||
| witnessedMsgParams.push(msgParams); |
There was a problem hiding this comment.
Nit: This variable seems to serve no purpose:
| const witnessedMsgParams: TypedMessageParams[] = []; | |
| const processTypedMessageV3 = async (msgParams: TypedMessageParams) => { | |
| witnessedMsgParams.push(msgParams); | |
| const processTypedMessageV3 = async (msgParams: TypedMessageParams) => { |
| const witnessedMsgParams: TypedMessageParams[] = []; | ||
| const processTypedMessageV4 = async (msgParams: TypedMessageParams) => { | ||
| witnessedMsgParams.push(msgParams); |
There was a problem hiding this comment.
Nit: This variable isn't used either
| const witnessedMsgParams: TypedMessageParams[] = []; | |
| const processTypedMessageV4 = async (msgParams: TypedMessageParams) => { | |
| witnessedMsgParams.push(msgParams); | |
| const processTypedMessageV4 = async (msgParams: TypedMessageParams) => { |
* origin/main: fix: change types signatures verifyingContract validation to allow 'cosmos' as address (#334) Update `main` with changes from v14.0.1 (#332) Request validation should not throw if verifyingContract is not defined in typed signature (#328) Add changelog entries for `#318` (#327) remove eth_sign (#320)
* Request validation should not throw if verifyingContract is not defined in typed signature (#328) (#330) * 14.0.1 (#331) * [14.x] fix: support ethermint's EIP712 implementation (#333) * setting cosmos as allowed string for verifyingContract field * fixed and linter * readability * Update condition to match main branch * Remove duplicate copy of test --------- Co-authored-by: Jyoti Puri <jyotipuri@gmail.com> Co-authored-by: Mark Stacey <markjstacey@gmail.com> * Version 14.0.2 (#339) * Version 14.0.2 * Fix typo Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com> --------- Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com> --------- Co-authored-by: Jyoti Puri <jyotipuri@gmail.com> Co-authored-by: Michael Tsitrin <114929630+mtsitrin@users.noreply.github.com> Co-authored-by: Michele Esposito <34438276+mikesposito@users.noreply.github.com>
MetaMask/metamask-extension#26908