Problem
loadSessionPrivateKey clears the mounted PEM bytes and its caller clears the returned key, but Go PKCS8 parsing creates a separate Ed25519 private-key allocation. The loader copies that parsed key for ownership transfer and leaves the parser-owned bytes for garbage collection.
Parent: #21.
Required fix
- Copy the validated parsed Ed25519 private key into the returned owned slice.
- Clear the parser-owned private-key slice before returning.
- Preserve existing fail-closed PEM, PKCS8, key type, key length, read-only regular-file, size, and public/private match validation.
- Add a focused regression that proves the returned copy remains usable and independent after the internal source is cleared.
Acceptance criteria
Security and cost
This narrows the in-process lifetime of one redundant signing-key copy. Go does not guarantee complete secret erasure across compiler/runtime copies, so this is defense in depth rather than a memory-forensics guarantee. It adds no network, cloud, storage, or recurring cost.
Primary sources
Problem
loadSessionPrivateKeyclears the mounted PEM bytes and its caller clears the returned key, but Go PKCS8 parsing creates a separate Ed25519 private-key allocation. The loader copies that parsed key for ownership transfer and leaves the parser-owned bytes for garbage collection.Parent: #21.
Required fix
Acceptance criteria
Security and cost
This narrows the in-process lifetime of one redundant signing-key copy. Go does not guarantee complete secret erasure across compiler/runtime copies, so this is defense in depth rather than a memory-forensics guarantee. It adds no network, cloud, storage, or recurring cost.
Primary sources