feat: add superstruct.sensitive#577
Open
ccharly wants to merge 4 commits into
Open
Conversation
ccharly
commented
Jun 25, 2026
ccharly
commented
Jun 25, 2026
ccharly
commented
Jun 25, 2026
| * The private key of the exported account. | ||
| */ | ||
| privateKey: string(), | ||
| privateKey: sensitive(string()), |
Contributor
Author
There was a problem hiding this comment.
Since it's marked as sensitive AND that we use our object struct, this field will never be display in validation/error messages from superstruct.
8cc422c to
fffcf37
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
hmalik88
reviewed
Jul 16, 2026
| ### Changed | ||
|
|
||
| - Use `sensitive` struct for `privateKey` in `PrivateKeyExportedAccountStruct` ([#577](https://github.com/MetaMask/accounts/pull/577)) | ||
| - This make sure the private key value is always redacted in case of validation errors. |
Contributor
There was a problem hiding this comment.
Suggested change
| - This make sure the private key value is always redacted in case of validation errors. | |
| - This ensures the private key value is always redacted in case of validation errors. |
Contributor
|
Can we also add |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding a new
superstruct"decorator" to mark a field as "sensitive" this way, it never gets logged by mistake insuperstructerror messages.Requires:
sensitivestruct superstruct#41Note
Medium Risk
Changes how private-key material appears in validation errors (security-sensitive), but behavior is narrowly scoped to struct validation/redaction with explicit tests and no export signing logic changes.
Overview
Adopts
@metamask/superstruct3.4.0 and wrapsprivateKeyinPrivateKeyExportedAccountStructwithsensitive(string()), so failedassert/ validation on export-account payloads redacts the key (e.g.***) in error messages and failure branches instead of echoing the raw value.The same superstruct bump is applied across keyring workspace packages (lockfile included). New unit tests in
private-key.test.tscover valid payloads, invalidprivateKey, and sibling-field failures where the key must not appear inStructErroroutput.Reviewed by Cursor Bugbot for commit 2ddcfbc. Bugbot is set up for automated code reviews on this repo. Configure here.