Repository navigation
fix(keys): avoid persisting one-off --hd-path overrides for secure-store identities - #2805
Open
Ranjeet2063 wants to merge 3 commits into
Open
Ranjeet2063 wants to merge 3 commits into
Ranjeet2063 wants to merge 3 commits into
Conversation
…ore identities When reading an unmigrated SecureStore identity that does not yet have its public key cached, a caller might specify an ad-hoc --hd-path override (e.g. `stellar keys address alice --hd-path 3`). Previously, this override was written back to the identity file on disk, permanently mutating the identity's default account for future invocations. Only persist the migrated cache to disk if no override was provided or if the override explicitly matches the identity's configured derivation path. Closes stellar#2777
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The successful lookup path is not tested, default-path normalization is incomplete, and documentation is outdated.
2 open findings
What changed in this PR
This PR prevents one-off --hd-path overrides from being persisted for SecureStore identities.
Changes:
- Restricts cache writes to the configured derivation path.
- Adds regression coverage for temporary overrides.
| File | Description | Review status |
|---|---|---|
cmd/soroban-cli/src/config/locator.rs |
Updates SecureStore caching and adds a unit test. | Changes required for test coverage, path normalization, and documentation. |
🧠 Review effort: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Update doc comments on `read_key_with_secure_store_cache` and `get_secret_key_with_hd_path` to state that only the identity's configured derivation path is cached to disk, leaving one-off overrides in-memory. Address review comments on PR stellar#2805.
… override Compare effective and persisted paths using unwrap_or_default() so None and Some(0) are recognized as the same default derivation path, matching the normalization across the rest of the codebase (e.g. secret.rs). Also ensure the original persisted_hd_path representation is preserved on disk.
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.


What
Avoid persisting ad-hoc
--hd-pathoverrides to disk when reading and caching unmigratedSecureStoreidentities.Why
Closes #2777
In
cmd/soroban-cli/src/config/locator.rs::read_key_with_secure_store_cache, when reading aSecureStoreidentity whose public key has not yet been cached, any--hd-pathpassed to the command (e.g.stellar keys address alice --hd-path 3) was combined with the identity's configured path (effective = hd_path.or(*persisted_hd_path)) and unconditionally written back to disk viaself.write_key(key_or_name, &migrated).This caused one-off CLI queries using
--hd-pathto permanently rewrite the stored identity's default account, affecting all subsequent transactions using that identity.With this change:
--hd-pathis provided and differs from the identity's configured derivation path, the derived public key is used in-memory for the current command but is not written back to disk.if hd_path.is_none() || hd_path == *persisted_hd_path).does_not_persist_hd_path_override_on_one_off_lookupinlocator.rsto verify that temporary--hd-pathoverrides do not mutate the identity file on disk.Known limitations
N/A