fix: refuse to load identity file with group/other-readable permissions (PILOT-249)#7
Conversation
…ns (PILOT-249) Promote the slog.Warn in LoadIdentity to a hard error when the identity file mode has group/other bits set (mode & 0o077 != 0). An Ed25519 private key readable by other local users is a security boundary violation — loading it silently is not acceptable. Tests updated: - TestLoadIdentity_LoosePermissionsWarn → _Error (expects error) - TestLoadIdentity_ReadFileNonNotExistError → uses 0o700 subdir - TestLoadIdentity_PermsExactly600NoWarn → _OK (no slog check)
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
🦞 Matthew PR Check — #7 PILOT-249Status
Summary
CommitBranch |
🦞 Matthew PR Explain — #7 PILOT-249What this changesIdentity files ( WhyA group/world-readable identity file leaks the private key to other users on the same machine — a security regression. RiskSmall — ≤3 files, ≤50 LoC. Only affects identity file loading; no runtime behavior change for files with correct permissions (0600). Existing identities with correct permissions load exactly as before. |
🦾 Matthew PR Check — #7 PILOT-249Status
VerdictCLEAN — permission check on identity file load is a solid defense-in-depth improvement. CI all green. Ready for operator review. |
🦜 Matthew Explains — #7 PILOT-249What this doesAdds a permission check to Tests are adjusted to match: Why it mattersThe identity file contains the node's private key. If it's group- or world-readable, any other process on the host can steal the key and impersonate the node. This is a defense-in-depth hardening for the identity subsystem. |
Summary
slog.Warnwhen the identity file had group/other-readable permissions (e.g., 0o644) but proceeded to load anyway. Downstream signing code signs with a key any local user can read.mode & 0o077 != 0, with a clear error message instructingchmod 600 <path>. The identity file contains the Ed25519 private key; readable-by-others is a security boundary violation.crypto/identity.go,crypto/zz_coverage_test.go)matthew-fix-larger) — 33 insertions, 58 deletions, 2 filesgo build ./...✅,go vet ./...✅,go test ./...✅ (all 13 packages pass)artifact: none)This is a behavior change: nodes with manually-created or backup-restored identity files that have permissions other than 0o600 will refuse to start after this update. Operators must
chmod 600 <identity-path>before upgrading. SaveIdentity always writes 0o600, so fresh installs are unaffected.Diff stat