fix: implement proper cleanup of sensitive cryptographic material in SeedlessOnboardingController #5926
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.
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:
References
This addresses security audit findings related to improper handling of sensitive cryptographic material in memory.
Checklist