diff --git a/internal/config/config.go b/internal/config/config.go index 086bd26cb..04d190e93 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -737,7 +737,9 @@ type CaptureConfig struct { // EncryptionKey is unset, binding secrets are persisted as plaintext // (legacy behaviour); when set, they are AES-256-GCM encrypted at rest type BindingsConfig struct { - // EncryptionKey is the active key that seals new binding secrets. + // EncryptionKey is the active key that seals new binding secrets. It must + // name the env engine: the State Store resolves it before extension engines + // exist. // Resolved through the secret registry (engine + key) at startup; the // resolved material must be 32 bytes of high-entropy randomness. // A nil/empty ref disables encryption and keeps current behaviour. diff --git a/internal/infrastructure/configuration/validate.go b/internal/infrastructure/configuration/validate.go index 0153004b7..a78228c8b 100644 --- a/internal/infrastructure/configuration/validate.go +++ b/internal/infrastructure/configuration/validate.go @@ -393,6 +393,20 @@ func validateContainers(cfg *config.Config) error { if ref := cfg.Containers.RegistryAuth; ref != (config.SecretRef{}) && (ref.Engine == "" || ref.Key == "") { return fmt.Errorf("%w: containers.registry_auth must name both an engine and a key, got {engine: %q, key: %q}", ErrInvalidInput, ref.Engine, ref.Key) } + return validateBindingKeyEngines(cfg.Bindings) +} + +// validateBindingKeyEngines requires the bindings encryption keys to name the +// env engine. The State Store resolves them at boot, before it serves the +// installed packages an extension engine comes from, so an extension engine +// could never answer. +func validateBindingKeyEngines(b config.BindingsConfig) error { + refs := append([]config.SecretRef{b.EncryptionKey}, b.PreviousEncryptionKeys...) + for _, ref := range refs { + if ref != (config.SecretRef{}) && ref.Engine != "env" { + return fmt.Errorf("%w: bindings encryption keys must use the env engine, got engine %q", ErrInvalidInput, ref.Engine) + } + } return nil }