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

Reject typeddata request when wrong chainId inside typed data #20821

Merged
merged 7 commits into from
Jul 24, 2024

Conversation

clauxx
Copy link
Member

@clauxx clauxx commented Jul 19, 2024

fixes #20757

Summary

We should reject any request where the typed data includes the wrong chainId (to prevent replay attacks). As a measure of security, we are checking that the typed data has the correct chain-id and reject potentially malicious requests without showing them to the user. Instead, we just show a toast, informing them that the signing is intended for a different network.

Included in the PR:

  • :wallet-connect/send-response no longer dismissed the modal, not it's done in :wallet-connect/finish-session-request. This is done because sometimes we need to reject (with send-response) without having a modal open, which breaks navigation if we dismiss a modal that doesn't exist.
  • rejecting requests when processing a request fails
  • rejecting a request when signing/transaction fails
  • checking the chainId inside the typeddata to make sure it's not different from the chainId of the session. If different, we show a toast informing the user about it.

Steps to test

  1. Make sure you're on the testnet
  2. Connect on https://react-app.walletconnect.com/
  3. Send a eth_signTypedData_v4
  4. A toast is shown and the request is rejected

status: ready

@clauxx clauxx self-assigned this Jul 19, 2024
@clauxx clauxx force-pushed the fix/typed-data-wrong-chain branch from 923e889 to a74100c Compare July 19, 2024 13:58
@status-im-auto
Copy link
Member

status-im-auto commented Jul 19, 2024

Jenkins Builds

Click to see older builds (12)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ a74100c #2 2024-07-19 14:03:58 ~5 min tests 📄log
✔️ a74100c #2 2024-07-19 14:07:28 ~8 min android 🤖apk 📲
✔️ a74100c #2 2024-07-19 14:07:50 ~9 min android-e2e 🤖apk 📲
✔️ a74100c #2 2024-07-19 14:09:04 ~10 min ios 📱ipa 📲
daf8159 #3 2024-07-23 12:54:47 ~2 min tests 📄log
✔️ daf8159 #4 2024-07-23 12:59:36 ~7 min android-e2e 🤖apk 📲
✔️ daf8159 #4 2024-07-23 12:59:36 ~7 min android 🤖apk 📲
✔️ daf8159 #4 2024-07-23 13:01:33 ~9 min ios 📱ipa 📲
✔️ 1d17ea6 #5 2024-07-23 14:04:11 ~5 min tests 📄log
✔️ 1d17ea6 #6 2024-07-23 14:05:24 ~6 min android-e2e 🤖apk 📲
✔️ 1d17ea6 #6 2024-07-23 14:06:02 ~7 min android 🤖apk 📲
✔️ 1d17ea6 #6 2024-07-23 14:08:03 ~9 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 46f4e82 #6 2024-07-24 08:48:06 ~4 min tests 📄log
✔️ 46f4e82 #7 2024-07-24 08:52:19 ~8 min android-e2e 🤖apk 📲
✔️ 46f4e82 #7 2024-07-24 08:52:24 ~8 min android 🤖apk 📲
✔️ 46f4e82 #7 2024-07-24 08:53:51 ~10 min ios 📱ipa 📲
✔️ 78a50cf #7 2024-07-24 09:06:43 ~6 min tests 📄log
✔️ 78a50cf #8 2024-07-24 09:08:06 ~7 min android-e2e 🤖apk 📲
✔️ 78a50cf #8 2024-07-24 09:09:10 ~8 min ios 📱ipa 📲
✔️ 78a50cf #8 2024-07-24 09:09:24 ~9 min android 🤖apk 📲

@clauxx clauxx requested a review from stefandunca July 22, 2024 07:42
@clauxx
Copy link
Member Author

clauxx commented Jul 23, 2024

@qoqobolo @pavloburykh Ready for QA testing

@qoqobolo qoqobolo self-assigned this Jul 23, 2024
@status-im-auto
Copy link
Member

71% of end-end tests have passed

Total executed tests: 7
Failed tests: 1
Expected to fail tests: 1
Passed tests: 5
IDs of failed tests: 702745 
IDs of expected to fail tests: 727232 

Failed tests (1)

Click to expand
  • Rerun failed tests

  • Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745

    Device 2: Find `MemberPhoto` by `xpath`: `//*[starts-with(@text,'profile_photo')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']//*[@content-desc='user-avatar']`
    Device 2: Image differs from template to 27.895962584252448 percents

    critical/chats/test_1_1_public_chats.py:320: in test_1_1_chat_non_latin_messages_stack_update_profile_photo
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Image of user in 1-1 chat is too different from template!
    



    Device sessions

    Expected to fail tests (1)

    Click to expand

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_watch_only_account, id: 727232

    Device 1: Find EditBox by accessibility id: add-address-to-watch
    Device 1: Type 0x8d2413447ff297d30bdc475f6d5cb00254685aae to EditBox

    critical/test_wallet.py:249: in test_wallet_add_remove_watch_only_account
        self.wallet_view.add_watch_only_account(address=address_to_watch, account_name=new_account_name)
    ../views/wallet_view.py:163: in add_watch_only_account
        self.account_has_activity_label.wait_for_visibility_of_element()
    ../views/base_element.py:147: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 1: Text by accessibility id:`account-has-activity` is not found on the screen after wait_for_visibility_of_element 
    

    [[Missing networks in account address, https://github.com//issues/20166]]

    Device sessions

    Passed tests (5)

    Click to expand

    Class TestWalletOneDevice:

    1. test_wallet_add_remove_regular_account, id: 727231
    Device sessions

    Class TestWalletMultipleDevice:

    1. test_wallet_send_asset_from_drawer, id: 727230
    2. test_wallet_send_eth, id: 727229

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    2. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133
    Device sessions

    @qoqobolo
    Copy link
    Contributor

    @clauxx could you take a look at the tests please? The build has failed

    Screenshot 2024-07-23 at 15 30 37

    @clauxx
    Copy link
    Member Author

    clauxx commented Jul 23, 2024

    @clauxx could you take a look at the tests please? The build has failed

    Screenshot 2024-07-23 at 15 30 37

    thanks! Pushed again

    @qoqobolo
    Copy link
    Contributor

    Thanks @clauxx, the PR is ready for merge.

    @clauxx clauxx merged commit 07005f8 into develop Jul 24, 2024
    6 checks passed
    @clauxx clauxx deleted the fix/typed-data-wrong-chain branch July 24, 2024 09:12
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    Status: DONE
    Development

    Successfully merging this pull request may close these issues.

    Failing to sign typed data if it contains the wrong chainId in the domain
    4 participants