fix: enforce derivation path role validation in wallet constructors (PM-20015)#1076
Open
fix: enforce derivation path role validation in wallet constructors (PM-20015)#1076
Conversation
Enforce derivation path role validation in wallet constructors (Least Authority audit finding Issue AN).
DustWallet::from_path() and ShieldedWallet::from_path() now assert that the DerivationPath role matches the expected wallet type (Role::Dust and Role::Zswap respectively). Mismatched roles produce a descriptive panic consistent with DerivationPath::new() error handling convention. Changes: - Add PartialEq derive to Role enum (hd.rs) - Add role validation assert in DustWallet::from_path() (dust.rs) - Add role validation assert in ShieldedWallet::from_path() (shielded.rs) - Add 6 unit tests covering valid/invalid role scenarios - Add change file Addresses Least Authority audit Issue AN (Low severity). JIRA: PM-20015
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.
Summary
Enforce derivation path role validation in wallet constructors to prevent silent key derivation under incorrect BIP-44 paths. Addresses Least Authority audit Issue AN (Low severity).
🎫 Ticket 📐 Engineering
Motivation
The Least Authority security audit (Issue AN, Low severity) identified that
DustWallet::from_path()andShieldedWallet::from_path()accept anyDerivationPathregardless of its role field. ADustWalletconstructed with a shielded-role path silently derives keys under the wrong hierarchical path (m/44'/2400'/0'/3/0instead ofm/44'/2400'/0'/2/0), producing unusable keys whose failure surfaces far from the misconfiguration site.Changes
PartialEqderive to enable idiomatic equality comparisonassert!guard clause infrom_path()rejecting non-Role::Dustpaths, plus 3 unit testsassert!guard clause infrom_path()rejecting non-Role::Zswappaths, plus 3 unit tests📌 Submission Checklist
🔱 Fork Strategy
🗹 TODO before merging