Skip to content

Share AES-GCM sealing of a secret at rest (low priority; two copies) #152

Open

Description

@patdowney

Why this issue

Two places seal a secret with AES-256-GCM, each with its own key handling, and a third use is plausible. This is a low-priority candidate: the two copies differ enough that extraction should wait for a decision about key handling. It comes from dioad/eventbroker#108 (candidate X6, row E14 and decision D5).

What exists today

  • auth/http/browsersession/crypto.go: newGCM(key), encrypt (seal and base64url encode) for cookies, with a fixed keySize of AES-256.
  • eventbroker/pkg/webhook/storage_encryption.go: secretCipher wrapping cipher.AEAD, built once from a 64-hex-character key read from EVENTBROKER_WEBHOOK_SECRET_KEY, used to encrypt webhook secrets at rest. When the variable is unset it returns (nil, nil) and secrets are stored in plaintext with a startup warning.

Proposal (when picked up)

A small seal helper with New(key), Seal, Open, and a versioned envelope so a key can be rotated, and a clear policy for a missing key (fail closed by default, with an explicit opt-out), which is decision D5 in #108. Home: dioad/auth or dioad/util.

Why not now

The two copies solve different problems (a cookie value versus a database column), and the right envelope depends on whether rotation is needed. Revisit when eventbroker settles D5, or when a third use appears.

Related

🤖 Generated with Claude Code

https://claude.ai/code/session_01SS4MAwAn85D1gkEzLtjYaZ

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions