Skip to content

Integrate LavaDome private key protection#22381

Merged
weizman merged 39 commits intodevelopfrom
weizman/try-lavadome
Feb 1, 2024
Merged

Integrate LavaDome private key protection#22381
weizman merged 39 commits intodevelopfrom
weizman/try-lavadome

Conversation

@weizman
Copy link
Copy Markdown
Contributor

@weizman weizman commented Dec 21, 2023

Description

New LavaDome tool can help to better hide the private key from potential malicious code running in the app when the user asks to see it.

Related issues

None

Manual testing steps

This PR changes the "show private key" dialog, not in terms of appearance, and not in terms of interaction but only in terms of "behind the scenes" security, so nothing should change in terms of manual interaction with this feature - that is the most important thing to check here QA-wise.

One thing that is changed, is that the private key text is no longer selectable as it was before, and now the only way to copy it is to use the copy-to-clipboard button.

That is on purpose, allowing selection of sensitive information such as the private key is unsafe, and disablement of selection capabilities of sensitive info is done intentionally to enhance security.

Screenshots/Recordings

Before

Screenshot 2024-01-10 at 22 43 55

After

key in image isn't real

Pre-merge author checklist

  • I’ve followed MetaMask Coding Standards.
  • I've clearly explained what problem this PR is solving and how it is solved.
  • I've linked related issues
  • I've included manual testing steps
  • I've included screenshots/recordings if applicable
  • I’ve included tests if applicable
  • I’ve documented my code using JSDoc format if applicable
  • I’ve applied the right labels on the PR (see labeling guidelines). Not required for external contributors.
  • I’ve properly set the pull request status:
    • In case it's not yet "ready for review", I've set it to "draft".
    • In case it's "ready for review", I've changed it from "draft" to "non-draft".

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

@metamaskbot metamaskbot added the INVALID-PR-TEMPLATE PR's body doesn't match template label Dec 21, 2023
@socket-security
Copy link
Copy Markdown

socket-security bot commented Dec 21, 2023

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/@lavamoat/lavadome-core@0.0.10 None 0 22.5 kB weizman
npm/@lavamoat/lavadome-react@0.0.10 Transitive: environment +9 3.61 MB weizman

View full report↗︎

@socket-security
Copy link
Copy Markdown

socket-security bot commented Dec 21, 2023

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

View full report↗︎

@weizman weizman changed the title wip try lavadome WIP - try integrating LavaDome Dec 22, 2023
@weizman
Copy link
Copy Markdown
Contributor Author

weizman commented Jan 9, 2024

Once LavaMoat/LavaDome#18 is merged and published, eab7582 should work too

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [65c6f87]
Page Load Metrics (852 ± 46 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint97154118168
domContentLoaded105520136
load73611848529746
domInteractive105520136
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 156 Bytes (0.00%)
  • ui: 4.29 KiB (0.06%)
  • common: 0 Bytes (0.00%)

darkwing
darkwing previously approved these changes Jan 30, 2024
@weizman weizman force-pushed the weizman/try-lavadome branch from 44a2bc7 to 2cc62b4 Compare January 31, 2024 17:02
Copy link
Copy Markdown
Contributor

@danjm danjm left a comment

Choose a reason for hiding this comment

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

The code changes look good to me. I will approve when we get another QA pass

@danjm
Copy link
Copy Markdown
Contributor

danjm commented Jan 31, 2024

actually, I will QA this myself

@weizman weizman requested review from danjm and darkwing January 31, 2024 17:25
@danjm
Copy link
Copy Markdown
Contributor

danjm commented Jan 31, 2024

QA passed, all following scenarios have been tested:

user can still reveal their private key
user can still copy their private key using the copy button
user cannot copy their private key any other way (i.e. the can't select the text and copy it)
private key cannot be seen if the html is inspected with the browser tools

These tests continue to pass, and I can also see the implemented message upon clicking the private key

Screenshot from 2024-01-31 14-03-13

@metamaskbot
Copy link
Copy Markdown
Collaborator

Builds ready [1394bad]
Page Load Metrics (798 ± 55 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint85168112199
domContentLoaded94520115
load704120679811455
domInteractive94519115
Bundle size diffs [🚨 Warning! Bundle size has increased!]
  • background: 156 Bytes (0.00%)
  • ui: 5.07 KiB (0.07%)
  • common: 0 Bytes (0.00%)

@weizman weizman removed the DO-NOT-MERGE Pull requests that should not be merged label Jan 31, 2024
Copy link
Copy Markdown
Contributor

@georgewrmarshall georgewrmarshall left a comment

Choose a reason for hiding this comment

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

LGTM! Tested and it works well. Nice use of component-library components. Left 2 non-blocking comments

style={{ wordBreak: 'break-word' }}
>
{privateKey}
<span onClick={() => setShowDisableSelectWarn(true)}>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: could we reduce html bloat and increase the click area of the text slightly by moving the onClick to the wrapping Text component?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

onClick={() => handlePrivateKeyCopy(privateKey)}
onClick={() =>
setShowDisableSelectWarn(false) || handlePrivateKeyCopy(privateKey)
}
Copy link
Copy Markdown
Contributor

@georgewrmarshall georgewrmarshall Jan 31, 2024

Choose a reason for hiding this comment

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

non-blocking: To improve the accessibility here we could add an ariaLabel={t('copyPrivateKey')} which would need to be created in messages.json. ariaLabel is a a required prop for the ButtonIcon component

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@weizman weizman changed the title Introduce LavaDome Integrate LavaDome private key protection Feb 1, 2024
@weizman weizman merged commit 030d8cb into develop Feb 1, 2024
@weizman weizman deleted the weizman/try-lavadome branch February 1, 2024 07:19
@github-actions github-actions bot locked and limited conversation to collaborators Feb 1, 2024
@github-actions github-actions bot removed the needs-dev-review PR needs reviews from other engineers (in order to receive required approvals) label Feb 1, 2024
@metamaskbot metamaskbot added the release-11.11.0 Issue or pull request that will be included in release 11.11.0 label Feb 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

dependencies Pull requests that update a dependency file QA Passed release-11.11.0 Issue or pull request that will be included in release 11.11.0 team-lavamoat type-security

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants