10000 fix: implement proper cleanup of sensitive cryptographic material in SeedlessOnboardingController by huggingbot · Pull Request #5926 · MetaMask/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: implement proper cleanup of sensitive cryptographic material in SeedlessOnboardingController #5926

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

huggingbot
Copy link

Explanation

Current state: The SeedlessOnboardingController handles sensitive cryptographic material (encryption keys, authentication keypairs, OPRF keys, and seed phrases) but was not properly cleaning up this data from memory after use. This creates an increased security risk where sensitive material could be extracted through memory scraping attacks, XSS exploits, or heap inspection.

Solution: Implemented cleanup of sensitive cryptographic material using try-finally blocks with .fill(0) for Uint8Arrays and nullification of all references. Used a declare-first pattern to minimize the number of references to sensitive objects in memory. This reduces the risk but cannot completely eliminate it due to JavaScript's garbage collection behavior, potential engine optimizations, and the inherent limitations of memory management in JavaScript environments.

Limitations:

  • JavaScript garbage collection is non-deterministic
  • JavaScript engines may keep internal copies of data
  • BigInt and string values cannot be reliably cleared from memory
  • Data is still vulnerable during active use

References

This addresses security audit findings related to improper handling of sensitive cryptographic material in memory.

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropr 8000 iate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed, highlighting breaking changes as necessary
  • I've prepared draft pull requests for clients and consumer packages to resolve any breaking changes

@huggingbot huggingbot force-pushed the fix/cleanup-sensitive-crypto-material branch from c0e4cd3 to 9af5cb0 Compare June 10, 2025 03:11
@huggingbot huggingbot marked this pull request as ready for review June 10, 2025 05:36
@huggingbot huggingbot requested review from a team as code owners June 10, 2025 05:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0