brave-core
brave-core copied to clipboard
fix(wallet): limit account name character length
Resolves https://github.com/brave/brave-browser/issues/23361 Resolves https://github.com/brave/brave-browser/issues/37362
Submitter Checklist:
- [x] I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
- [x] There is a ticket for my issue
- [x] Used Github auto-closing keywords in the PR description above
- [x] Wrote a good PR/commit description
- [ ] Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
- [x] Added appropriate labels (
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issue - [x] Checked the PR locally:
- [ ] Ran
git rebase master
(if needed)
Reviewer Checklist:
- [ ] A security review is not needed, or a link to one is included in the PR description
- [ ] New files have MPL-2.0 license header
- [ ] Adequate test coverage exists to prevent regressions
- [ ] Major classes, functions and non-trivial code blocks are well-commented
- [ ] Changes in component dependencies are properly reflected in
gn
- [ ] Code follows the style guide
- [ ] Test plan is specified in PR before merging
After-merge Checklist:
- [ ] The associated issue milestone is set to the smallest version that the changes has landed on
- [ ] All relevant documentation has been updated, for instance:
- [ ] https://github.com/brave/brave-browser/wiki/Deviations-from-Chromium-(features-we-disable-or-remove)
- [ ] https://github.com/brave/brave-browser/wiki/Proxy-redirected-URLs
- [ ] https://github.com/brave/brave-browser/wiki/Fingerprinting-Protections
- [ ] https://github.com/brave/brave-browser/wiki/Brave%E2%80%99s-Use-of-Referral-Codes
- [ ] https://github.com/brave/brave-browser/wiki/Web-Compatibility-Exceptions-in-Brave
- [ ] https://github.com/brave/brave-browser/wiki/QA-Guide
- [ ] https://github.com/brave/brave-browser/wiki/P3A
Test Plan:
Scenario 1 (Create Account)
- Go to accounts page
- Click the "+" icon
- click "Create account"
- Select a coin type
- enter an account name over 30 characters long
- an error message should be shown and the submit button should be disabled until the name is 30 characters or shorter
- Submit button should continue to work (creates an account with the supplied name)
- repeat for all coin types
Scenario 2 (Import Account)
- Go to accounts page
- Click the "+" icon
- click "Import account"
- Select a coin type
- enter an account name over 30 characters long
- an error message should be shown and the submit button should be disabled until the name is 30 characters or shorter
- enter a private key
- Submit button should continue to work (imports the private key as an account with the supplied name)
- repeat for all coin types
- repeat using a JSON keystore file instead of a pasted private key (Import type)
Scenario 3 (Edit Account)
- Go to accounts page
- Click the kabab icon on an account
- click "Edit"
- enter an account name over 30 characters long
- an error message should be shown and the submit button should be disabled until the name is 30 characters or shorter
- Submit button should continue to work (edits the account to use the newly supplied name)
Scenario 4 (View Private key)
- Go to accounts page
- Click the kabab icon on an account
- click "Export"
- enter you wallet password
- click "show key"
- private key should be revealed (should not be revealed if password is incorrect, should lock wallet after 3 incorrect attempts)
Scenario 4 (Remove account)
- Go to accounts page
- Click the kabab icon on an imported account that can be removed
- click "Remove"
- enter you wallet password
- click "continue"
- the account should be removed (should not be removed if password is incorrect, should lock wallet after 3 incorrect attempts)
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
The security team is monitoring all repositories for certain keywords. This PR includes the word(s) "password" and so security team members have been added as reviewers to take a look.
No need to request a full security review at this stage, the security team will take a look shortly and either clear the label or request more information/changes.
Notifications have already been sent, but if this is blocking your merge feel free to reach out directly to the security team on Slack so that we can expedite this check.
A Storybook has been deployed to preview UI for the latest push
Low risk: Account and password length limits were added. Ensure the backend also enforces these limits to prevent truncation attacks. The UI code should also gracefully handle names longer than 30 chars if they already exist in storage.
Are we checking for password length or is it an AI flutter? @josheleonard
Low risk: Account and password length limits were added. Ensure the backend also enforces these limits to prevent truncation attacks. The UI code should also gracefully handle names longer than 30 chars if they already exist in storage.
Are we checking for password length or is it an AI flutter? @josheleonard
@thypon, this is AI flutter. This PR only adds checks for the account name length
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
A Storybook has been deployed to preview UI for the latest push
[puLL-Merge] - brave/brave-core@22907
Description
This PR adds new Brave Wallet related strings to brave_wallet_constants.h
and brave_wallet.mojom
. It also makes UI changes to the account settings modal, add account modal, and import account modal in the wallet extension.
The main motivation appears to be improving the UX around entering account names by adding validation and character limit checks. Some of the modal components are also refactored to use new shared button and input components.
Changes
Changes
brave_wallet_constants.h
- Adds new string constants for private key import type label, enter password if applicable label, and account name too long error message
brave_wallet.mojom
- Adds a new constant
kAccountNameMaxCharacterLength
to specify the max allowed length for account names
account-settings-modal.tsx
- Refactors to use new shared
Input
andDropdown
components - Adds validation for account name length
- Switches to using
LeoSquaredButton
instead ofNavButton
- Uses new
Alert
component for warnings/disclaimers
add-imported-account-modal.tsx
- Similar changes as account settings modal - uses new input components, adds name length validation
- Switches import type selector to use
Dropdown
component
create-account-modal.tsx
- Also refactors to use new input components and adds name length validation
- Changes network selector to
Dropdown
component
confirm-password-modal/remove-account-modal.tsx
- Minor refactor and rename of component to
RemoveAccountModal
Possible Issues
The max account name length is now defined in both the brave_wallet.mojom
and in each UI component that uses it. This works but is a bit fragile - if the mojom constant is updated, the UI will also need to be updated in several places. Using a shared constant could help mitigate this.
The security team is monitoring all repositories for certain keywords. This PR includes the word(s) "password" and so security team members have been added as reviewers to take a look.
No need to request a full security review at this stage, the security team will take a look shortly and either clear the label or request more information/changes.
Notifications have already been sent, but if this is blocking your merge feel free to reach out directly to the security team on Slack so that we can expedite this check.
A Storybook has been deployed to preview UI for the latest push