Description
PlatformWalletManager.createWallet(mnemonic:network:name:createDefaultAccounts:birthHeight:) passes the phrase to platform_wallet_manager_create_wallet_from_mnemonic_with_birth_height through withCString without checking for NUL bytes. Rust reads the C string only up to the first NUL, so a phrase followed by a NUL and junk creates a wallet from the valid prefix instead of failing.
The other Swift wrappers that take a phrase or an address already reject this with KeyDerivation.requireNoNUL. The async overload of createWallet(mnemonic:) needs the same check if it does not go through the synchronous one.
Fix
Call try KeyDerivation.requireNoNUL(mnemonic, "Mnemonic") before the C-string conversion, and add a test that a phrase with an embedded NUL throws.
Found by CodeRabbit on #5728. The gap already exists on v5.1-dev and is outside that PR's diff.
Activity