Skip to content

Fix/argon2id vault kdf#63

Open
Tobi-8 wants to merge 2 commits into
OrbitChainLabs:mainfrom
Tobi-8:fix/argon2id-vault-kdf
Open

Fix/argon2id vault kdf#63
Tobi-8 wants to merge 2 commits into
OrbitChainLabs:mainfrom
Tobi-8:fix/argon2id-vault-kdf

Conversation

@Tobi-8

@Tobi-8 Tobi-8 commented Jun 21, 2026

Copy link
Copy Markdown

Branch fix/argon2id-vault-kdf pushed to https://github.com/Tobi-8/OrbitChain-Contracts/tree/fix/argon2id-vault-kdf

PR 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_password derived 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_password now uses Argon2id (19,456 KiB, 2 iterations, 1 lane) with a random salt. Added from_password_with_salt for loading, and get_salt() for persistence.
  • encrypted_vault.rs: with_password captures the salt from KeyManager. load_from_file reads VAULT_SALT=... from the vault file and passes it to from_password_with_salt. save_to_file persists the salt. Salt length (16 bytes) validated on load.
  • main.rs: CLI encrypt now outputs SALT=<hex> alongside the encrypted key. decrypt takes <salt_hex> as a required third argument, decodes it, and uses from_password_with_salt.
  • Cargo.toml: argon2 = "0.5" dependency already present.
  • SECURITY.md: Documents the KDF migration.

Files changed

  • crates/tools/src/key_manager.rs
  • crates/tools/src/encrypted_vault.rs
  • crates/tools/src/main.rs
  • crates/tools/Cargo.toml
  • SECURITY.md

Migration 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

OrbitChain Developer 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[HIGH] KeyManager::from_password derives AES key with single SHA-256 (broken KDF; no salt, no work factor)

1 participant