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

Prevent user from editing a contract interaction created by a dapp #16498

Merged
merged 6 commits into from
Nov 15, 2022

Conversation

danjm
Copy link
Contributor

@danjm danjm commented Nov 15, 2022

Fixes problem introduced in #15812

As of that PR, it became possible for users to edit contract interact transactions. That is okay if the transaction originates from MetaMask, but not if the transaction originates from a dapp. Editing the recipient or the asset type can have unexpected consequences in that case, include allowing the user to transfer tokens to a smart contract address.

This PR prevents the user from editing contract interactions from a dapp. This was the way things were prior to v10.21.0

An e2e test is added to prevent such a regression in the future

@danjm danjm requested a review from a team as a code owner November 15, 2022 00:41
@danjm danjm requested a review from digiwand November 15, 2022 00:41
@github-actions
Copy link
Contributor

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

brad-decker
brad-decker previously approved these changes Nov 15, 2022
Copy link
Contributor

@brad-decker brad-decker left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -1158,11 +1158,13 @@ export default class ConfirmTransactionBase extends Component {
} = this.getNavigateTxData();

let functionType;
let isContractInteractionFromDapp = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we make this a const and set its value to:

const isContractInteractionFromDapp = txData.type === TRANSACTION_TYPES.CONTRACT_INTERACTION && txData.origin !== 'metamask';

...and use that for the if?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in 358dacb

@Gudahtt
Copy link
Member

Gudahtt commented Nov 15, 2022

This PR prevents the user from editing contract interactions from a dapp. This was the way things were prior to v10.21.0

I don't think this is accurate. Contract interactions in general were not editable prior to v10.21.0, but simple send transactions suggested by dapps were editable.

Edit: Oh, but this PR still allows simple sends from dapps to be edited, sorry I missed that.

Gudahtt
Gudahtt previously approved these changes Nov 15, 2022
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!

@seaona
Copy link
Contributor

seaona commented Nov 15, 2022

From QA looks good!

@Gudahtt Gudahtt merged commit 0a5c46b into develop Nov 15, 2022
@Gudahtt Gudahtt deleted the prevent-dapp-contract-edit branch November 15, 2022 15:58
@github-actions github-actions bot locked and limited conversation to collaborators Nov 15, 2022
@metamaskbot
Copy link
Collaborator

Builds ready [c8791bb]
Page Load Metrics (2282 ± 130 ms)
PlatformPageMetricMin (ms)Max (ms)Average (ms)StandardDeviation (ms)MarginOfError (ms)
ChromeHomefirstPaint912076220427205
domContentLoaded178028802265272131
load178029072282271130
domInteractive178028802265272131
Bundle size diffs
  • background: 0 bytes
  • ui: 61 bytes
  • common: 0 bytes

highlights:

storybook

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants