Skip to content

P2 E3: clear parser-owned Ed25519 signing-key bytes after configuration load #310

Description

@gnanirahulnutakki

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

  • The parser-owned Ed25519 private-key bytes are explicitly cleared on the success path.
  • The returned key is a distinct full-length copy and remains cryptographically usable.
  • Error behavior and deployment inputs remain unchanged.
  • Focused race tests and repository quality/security gates remain green.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    governancePDP / audit / decision-ledger / tenancysecuritySecurity hardening / isolation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions