Fix/argon2id vault kdf#63
Open
Tobi-8 wants to merge 2 commits into
Open
Conversation
added 2 commits
June 21, 2026 03:10
…ease_skipped topic - Add missing timestamp variable in multi_asset_release.rs - Replace raw symbol_short event publish with event::milestone_release_skipped using documented (campaign, milestone_release_skipped) topic - Add milestone_release_completed summary event after per-asset loop - Add event assertions to native asset skip test - Document both events in docs/events.md
Key changes: - KeyManager::from_password now derives master key via Argon2id (memory-hard KDF) - Per-instance random salt (16 bytes) generated and stored alongside vault - EncryptedVault persists VAULT_SALT in vault file, parsed on load - CLI encrypt/decrypt commands properly round-trip the salt - Salt length (16 bytes) and KDF parameters validated on load - SECURITY.md updated documenting the migration Closes #XX
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.
Branch
fix/argon2id-vault-kdfpushed tohttps://github.com/Tobi-8/OrbitChain-Contracts/tree/fix/argon2id-vault-kdfPR link to create PR: https://github.com/Tobi-8/OrbitChain-Contracts/pull/new/fix/argon2id-vault-kdf
Here's the PR description you can copy and paste:
Replace SHA-256 with Argon2id for vault master-key derivation
Problem
KeyManager::from_passwordderived the AES-256 master key using a single round of SHA-256 with no salt and no work factor. An attacker who obtains an encrypted vault file can recover the password at the cost of ~1 SHA-256 per guess (~10¹⁰ guesses/s on GPU), and two operators with the same password derive identical keys (no salt).Solution
Replaced SHA-256 with Argon2id (memory-hard KDF, de-facto standard) with per-instance random 16-byte salts:
key_manager.rs:from_passwordnow uses Argon2id (19,456 KiB, 2 iterations, 1 lane) with a random salt. Addedfrom_password_with_saltfor loading, andget_salt()for persistence.encrypted_vault.rs:with_passwordcaptures the salt from KeyManager.load_from_filereadsVAULT_SALT=...from the vault file and passes it tofrom_password_with_salt.save_to_filepersists the salt. Salt length (16 bytes) validated on load.main.rs: CLIencryptnow outputsSALT=<hex>alongside the encrypted key.decrypttakes<salt_hex>as a required third argument, decodes it, and usesfrom_password_with_salt.Cargo.toml:argon2 = "0.5"dependency already present.SECURITY.md: Documents the KDF migration.Files changed
crates/tools/src/key_manager.rscrates/tools/src/encrypted_vault.rscrates/tools/src/main.rscrates/tools/Cargo.tomlSECURITY.mdMigration note
Existing vault files encrypted under SHA-256 will fail to load with an explicit "No VAULT_SALT found" error. Re-encrypt by creating a new vault (
keymanager init-vault) and migrating keys.closes #40