fix(crypto): harden secret key material against Debug leakage and zeroize gaps#507
Open
varex83agent wants to merge 1 commit into
Open
fix(crypto): harden secret key material against Debug leakage and zeroize gaps#507varex83agent wants to merge 1 commit into
varex83agent wants to merge 1 commit into
Conversation
…oize gaps Addresses five P0 secret-key-material findings across frost, crypto, and k1util — closing log-leakage holes, wiping in-memory secrets, and fixing one Charon parity divergence in on-disk key permissions. - frost: replace derived `Debug` on `SigningShare`, `KeyPackage` and `ShamirShare` with redacting manual impls so secret scalars/shares can no longer reach logs/panics (mirrors the existing `BlsSignature` style). - frost: explicitly zeroize the ephemeral Schnorr nonce and the reconstructed signing-key scalars in kryptology `round1`/`round2`. `Scalar` deliberately keeps `Copy` (removing it ripples across the crate for no guarantee — the inner `blst_fr` is a `Copy` C struct); rationale documented on the type. - crypto: declare the `zeroize` dep and wrap the raw `ikm`/candidate byte buffers in `Zeroizing`. blst's `SecretKey` is `#[zeroize(drop)]`, so the `BlstSecretKey` intermediates already wipe on drop. - k1util: write the secp256k1 private key with mode `0o600`, matching Charon `app/k1util/k1util.go` Save (v1.7.1); previously used the default umask mode. No wire-format, signature, or DKG-output changes; only Debug output, drop behaviour, and on-disk file mode. Adds unit tests for each redaction and the 0o600 permission (incl. tightening an existing looser file). Co-Authored-By: Bohdan Ohorodnii <35969035+varex83@users.noreply.github.com>
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
Addresses five P0 secret-key-material findings across
frost,crypto, andk1util— closing log-leakage holes, wiping in-memory secrets, and fixing one Charon parity divergence in on-disk key permissions.High-value validator secret key material was held as plain byte arrays / bare stack scalars, printed via derived
Debug, and (in one case) written to disk with world-readable permissions.Changes
Debugleaks FROSTSigningShare/KeyPackagesecret shareDebugfrom derives; added redacting manualimpl fmt::Debug(<redacted>placeholder, public fields preserved onKeyPackage)DebugleaksShamirSharevalueDebugprintingid, redactingvaluek1util::save()writes key world-readable0o600(and tightens an existing looser file), matching Charonapp/k1util/k1util.goSave(v1.7.1,0o600)Scalarnot zeroized on drop;CopyconflictCopy— removing it ripples across the crate for no real guarantee (the innerblst_fris aCopyC struct, so moves bit-copy it regardless). Rationale documented on the type.zeroize()onk/wi/share_scalarinround1andown_share_scalar/share_sum/share_scalar/total_scalarinround2zeroizedep; wrapped rawikm/candidate byte buffers inZeroizing. Confirmed blstSecretKeyis#[zeroize(drop)](0.3.16), soBlstSecretKeyintermediates already auto-wipeParity / safety
No wire-format, signature, or DKG-output changes — only
Debugoutput, drop behaviour, and on-disk file mode. The only intentional parity change is T03 aligning the secp256k1 key file mode to Charon's0o600. Zeroization is framed as best-effort defense-in-depth.Tests
Debugredaction forSigningShare,KeyPackage,ShamirShare;0o600permission on save (incl. tightening an existing looser file).cargo +nightly fmt --all --check✓cargo clippyon frost/crypto/k1util + dependentdkgcrate,-D warnings✓cargo testpasses — including the 107dkgtests, confirming theDebug-derive removals don't break dependents.🤖 Generated with Claude Code