Skip to content

No key management — developers will store raw private keys in plaintext #11

@OkeyAmy

Description

@OkeyAmy

The Problem

The keygen CLI command generates an Ed25519 keypair, prints the private key in hex to stdout, and says "store this securely." That is the entire key management story.

There is no encrypted keystore. No passphrase protection. No key listing. No key rotation. Developers will do what developers always do: pipe the output to a file, put the file in their home directory, forget about the permissions, and eventually commit it to git.

This is not a theoretical concern. It is what happens every single time a tool outputs raw key material to a terminal.

Where It Breaks

drs-sdk/src/cli/commands/keygen.ts — the command calls crypto.getRandomValues(), derives the public key, encodes both as hex, and prints them. The private key is never encrypted, never stored in a protected format, never associated with metadata (creation date, purpose, rotation schedule).

What Must Change

  1. Add an encrypted keystore. The private key gets encrypted at rest with a passphrase-derived key. Argon2id for the KDF, XChaCha20-Poly1305 for the cipher. This is the same pattern used by age, ssh-keygen, and Signet's keystore.
  2. The keystore file must be chmod 600 on creation. If the platform doesn't support file permissions, warn loudly.
  3. keygen should write to the keystore by default, not to stdout. Add `--stdout` flag for the rare case where raw output is needed, with a warning.
  4. Add key list, key export (public only), and key delete subcommands.
  5. Never print the private key without the user explicitly asking for it.

Severity

HIGH for adoption and operational security. The crypto primitives are correct — the key generation is fine. But generating a good key and then storing it badly is the same as having a bad key.

Metadata

Metadata

Assignees

No one assigned

    Labels

    highHigh severitysecuritySecurity vulnerability or hardening

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions