Skip to content

keyring-controller: validate from-address in signTypedMessage#1293

Merged
legobeat merged 2 commits intoMetaMask:mainfrom
legobeat:fix-sign-empty-address
May 3, 2023
Merged

keyring-controller: validate from-address in signTypedMessage#1293
legobeat merged 2 commits intoMetaMask:mainfrom
legobeat:fix-sign-empty-address

Conversation

@legobeat
Copy link
Contributor

@legobeat legobeat commented May 2, 2023

The normalizeAddress function is can return undefined even if the interface says otherwise.

This adds explicit handling of that case in keyring-controller. Required for #1289 .

@legobeat legobeat force-pushed the fix-sign-empty-address branch 2 times, most recently from 35b9b1d to 4705ae4 Compare May 2, 2023 02:35
@legobeat legobeat marked this pull request as ready for review May 2, 2023 02:36
@legobeat legobeat requested a review from a team as a code owner May 2, 2023 02:36
Copy link
Member

@mikesposito mikesposito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Left just a small suggestion

) {
try {
const address = normalizeAddress(messageParams.from);
if (!address?.length) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: maybe we can use isValidAddress from ethereumjs-util to be sure that what we get is an address

Copy link
Contributor Author

@legobeat legobeat May 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated along with PR title.

@legobeat legobeat requested a review from mikesposito May 2, 2023 22:58
@legobeat legobeat force-pushed the fix-sign-empty-address branch from cdf3025 to 8b42427 Compare May 2, 2023 23:00
@legobeat legobeat force-pushed the fix-sign-empty-address branch from 8b42427 to 67d33ef Compare May 2, 2023 23:00
@legobeat legobeat changed the title keyring-controller: throw explicit error on undefined result from normalizeAddress keyring-controller: validate from address in signTypedMessage May 2, 2023
@legobeat legobeat changed the title keyring-controller: validate from address in signTypedMessage keyring-controller: validate from-address in signTypedMessage May 2, 2023
Copy link
Member

@Gudahtt Gudahtt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@legobeat legobeat merged commit bdeee5a into MetaMask:main May 3, 2023
Gudahtt added a commit that referenced this pull request May 3, 2023
…-rebased

* origin/main:
  docs: update controller-utils/isValidHexAddress to match reality (#1308)
  keyring-controller: validate from-address in signTypedMessage (#1293)
  NetworkController: Fix chain IDs in tests (#1307)
  NetworkController: Normalize INFURA_NETWORKS array (#1306)
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* keyring-controller: throw explicit error on undefined result from normalizeAddress

* key-controller: validate sender address before attempting signature
MajorLift pushed a commit that referenced this pull request Oct 11, 2023
* keyring-controller: throw explicit error on undefined result from normalizeAddress

* key-controller: validate sender address before attempting signature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants