Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
May 3, 2023

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

@@ -461,6 +461,11 @@ export class KeyringController extends BaseController<
) {
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 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