From 4863ae849682ee9ea54248f59888c255da3b182f Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Fri, 13 Nov 2026 06:26:21 +0100 Subject: [PATCH 1/3] feat(email): create the send-only SMTP credential for the SES relay Company Email relays outbound mail through Amazon SES. Declare its SMTP identity platform-side: an IAM user whose only permission is ses:SendRawEmail on the company mail domain's identity in eu-central-1, with the sender limited to that domain, and an access key whose provider- derived SES SMTP password a PushSecret copies to OpenBao. The shared store gets an exact-key grant for that one record, and nobody reads it. Delete is omitted from every policy, so a prune cannot revoke outbound mail; rotation declares a new key first. Part of devantler-tech/platform#5481. Co-Authored-By: Claude Opus 5.5 --- .../infrastructure/vault-config/job.yaml | 8 ++++ .../apps/aws/access-key-email-smtp.yaml | 28 +++++++++++++ .../hetzner/apps/aws/kustomization.yaml | 5 +++ .../apps/aws/policy-email-smtp-send.yaml | 40 +++++++++++++++++++ .../apps/aws/push-secret-email-smtp.yaml | 32 +++++++++++++++ .../hetzner/apps/aws/user-email-smtp.yaml | 23 +++++++++++ .../user-policy-attachment-email-smtp.yaml | 22 ++++++++++ 7 files changed, 158 insertions(+) create mode 100644 k8s/providers/hetzner/apps/aws/access-key-email-smtp.yaml create mode 100644 k8s/providers/hetzner/apps/aws/policy-email-smtp-send.yaml create mode 100644 k8s/providers/hetzner/apps/aws/push-secret-email-smtp.yaml create mode 100644 k8s/providers/hetzner/apps/aws/user-email-smtp.yaml create mode 100644 k8s/providers/hetzner/apps/aws/user-policy-attachment-email-smtp.yaml diff --git a/k8s/bases/infrastructure/vault-config/job.yaml b/k8s/bases/infrastructure/vault-config/job.yaml index 5d6922bb8c..dfb403d15d 100644 --- a/k8s/bases/infrastructure/vault-config/job.yaml +++ b/k8s/bases/infrastructure/vault-config/job.yaml @@ -1081,6 +1081,11 @@ spec: path "secret/data/infrastructure/email/agent" { capabilities = ["create", "update", "read"] } + # The SES relay's SMTP credential, pushed from the AccessKey's + # connection Secret (platform#5481). Exact key only. + path "secret/data/infrastructure/email/ses-smtp" { + capabilities = ["create", "update", "read"] + } path "secret/data/apps/actual-budget/*" { capabilities = ["create", "update", "read"] } @@ -1135,6 +1140,9 @@ spec: path "secret/metadata/infrastructure/email/agent" { capabilities = ["create", "update", "read"] } + path "secret/metadata/infrastructure/email/ses-smtp" { + capabilities = ["create", "update", "read"] + } path "secret/metadata/apps/actual-budget/*" { capabilities = ["create", "update", "read"] } diff --git a/k8s/providers/hetzner/apps/aws/access-key-email-smtp.yaml b/k8s/providers/hetzner/apps/aws/access-key-email-smtp.yaml new file mode 100644 index 0000000000..4a09ba3064 --- /dev/null +++ b/k8s/providers/hetzner/apps/aws/access-key-email-smtp.yaml @@ -0,0 +1,28 @@ +# The SMTP credential of company Email's SES relay. The provider publishes the +# key ID as `username` and the SES SMTP password derived for its own region +# (eu-central-1) as `attribute.ses_smtp_password_v4`. The connection Secret +# stays in this namespace; push-secret-email-smtp.yaml copies those two values +# to OpenBao, and nobody reads them. The password is only available when the +# key is created, so the OpenBao copy is the durable one. Rotate by declaring a +# new key, then remove this one with Delete added to its policies. +apiVersion: iam.aws.m.upbound.io/v1beta1 +kind: AccessKey +metadata: + name: email-smtp + namespace: aws + labels: + app.kubernetes.io/managed-by: ksail +spec: + managementPolicies: + - Observe + - Create + - Update + - LateInitialize + forProvider: + userRef: + name: email-smtp + writeConnectionSecretToRef: + name: email-smtp-credentials + providerConfigRef: + kind: ProviderConfig + name: default diff --git a/k8s/providers/hetzner/apps/aws/kustomization.yaml b/k8s/providers/hetzner/apps/aws/kustomization.yaml index c2cc48f624..63088156af 100644 --- a/k8s/providers/hetzner/apps/aws/kustomization.yaml +++ b/k8s/providers/hetzner/apps/aws/kustomization.yaml @@ -11,6 +11,11 @@ resources: - provider-config.yaml - policy-eks-ci-smoke-boundary.yaml - role-eks-ci.yaml + - user-email-smtp.yaml + - policy-email-smtp-send.yaml + - user-policy-attachment-email-smtp.yaml + - access-key-email-smtp.yaml + - push-secret-email-smtp.yaml - external-secret.yaml - oci-repository.yaml - flux-kustomization.yaml diff --git a/k8s/providers/hetzner/apps/aws/policy-email-smtp-send.yaml b/k8s/providers/hetzner/apps/aws/policy-email-smtp-send.yaml new file mode 100644 index 0000000000..fda4ed6b23 --- /dev/null +++ b/k8s/providers/hetzner/apps/aws/policy-email-smtp-send.yaml @@ -0,0 +1,40 @@ +# The only permission of Company Email's SMTP identity: relay raw mail through +# the company mail domain's SES identity in eu-central-1, with a sender on that +# domain. It cannot read, configure or verify anything in SES. +apiVersion: iam.aws.m.upbound.io/v1beta1 +kind: Policy +metadata: + name: email-smtp-send + namespace: aws + labels: + app.kubernetes.io/managed-by: ksail +spec: + managementPolicies: + - Observe + - Create + - Update + - LateInitialize + forProvider: + description: >- + Lets company Email's SMTP identity relay mail through the company mail + domain's SES identity, with a sender on that domain only. + policy: | + { + "Version": "2012-10-17", + "Statement": [ + { + "Sid": "RelayCompanyMail", + "Effect": "Allow", + "Action": "ses:SendRawEmail", + "Resource": "arn:aws:ses:eu-central-1:939001610192:identity/devantler.tech", + "Condition": { + "StringLike": { + "ses:FromAddress": "*@devantler.tech" + } + } + } + ] + } + providerConfigRef: + kind: ProviderConfig + name: default diff --git a/k8s/providers/hetzner/apps/aws/push-secret-email-smtp.yaml b/k8s/providers/hetzner/apps/aws/push-secret-email-smtp.yaml new file mode 100644 index 0000000000..6991cbd5ce --- /dev/null +++ b/k8s/providers/hetzner/apps/aws/push-secret-email-smtp.yaml @@ -0,0 +1,32 @@ +# Copies company Email's SES SMTP credential into OpenBao, where the Email +# server reads it. Platform-applied, so it may use the shared store, which holds +# an exact-key grant for this one record. Replace keeps OpenBao equal to the +# current key; a missing or incomplete connection Secret writes nothing. +apiVersion: external-secrets.io/v1alpha1 +kind: PushSecret +metadata: + name: email-smtp-credentials + namespace: aws + labels: + app.kubernetes.io/managed-by: ksail +spec: + updatePolicy: Replace + deletionPolicy: None + refreshInterval: 1h + secretStoreRefs: + - name: openbao + kind: ClusterSecretStore + selector: + secret: + name: email-smtp-credentials + data: + - match: + secretKey: username + remoteRef: + remoteKey: infrastructure/email/ses-smtp + property: username + - match: + secretKey: attribute.ses_smtp_password_v4 + remoteRef: + remoteKey: infrastructure/email/ses-smtp + property: password diff --git a/k8s/providers/hetzner/apps/aws/user-email-smtp.yaml b/k8s/providers/hetzner/apps/aws/user-email-smtp.yaml new file mode 100644 index 0000000000..d0cafca762 --- /dev/null +++ b/k8s/providers/hetzner/apps/aws/user-email-smtp.yaml @@ -0,0 +1,23 @@ +# Company Email's send-only SMTP identity for the Amazon SES relay +# (platform#5481). Platform-owned for the same reason as the EKS CI role: the +# public aws tenant must not be able to widen what this credential may do. +# Delete is omitted so a prune cannot remove the identity outbound mail uses; +# revoke by replacing its access key instead. +apiVersion: iam.aws.m.upbound.io/v1beta1 +kind: User +metadata: + name: email-smtp + namespace: aws + labels: + app.kubernetes.io/managed-by: ksail +spec: + managementPolicies: + - Observe + - Create + - Update + - LateInitialize + forProvider: + path: /email/ + providerConfigRef: + kind: ProviderConfig + name: default diff --git a/k8s/providers/hetzner/apps/aws/user-policy-attachment-email-smtp.yaml b/k8s/providers/hetzner/apps/aws/user-policy-attachment-email-smtp.yaml new file mode 100644 index 0000000000..a97fd33893 --- /dev/null +++ b/k8s/providers/hetzner/apps/aws/user-policy-attachment-email-smtp.yaml @@ -0,0 +1,22 @@ +# Attaches the send-only policy to company Email's SMTP identity. +apiVersion: iam.aws.m.upbound.io/v1beta1 +kind: UserPolicyAttachment +metadata: + name: email-smtp-send + namespace: aws + labels: + app.kubernetes.io/managed-by: ksail +spec: + managementPolicies: + - Observe + - Create + - Update + - LateInitialize + forProvider: + userRef: + name: email-smtp + policyArnRef: + name: email-smtp-send + providerConfigRef: + kind: ProviderConfig + name: default From 6890e5fa77334722f08cfc8ed2e46e455b03c57d Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Fri, 13 Nov 2026 06:45:39 +0100 Subject: [PATCH 2/3] test(email): admit the SES relay credential's exact OpenBao grant The mail credential guard allowed exactly the three mailbox credentials. Add the relay's SMTP credential as a fourth exact data and metadata grant, and pin its PushSecret: one connection Secret, Replace without deletion, and only the username and SMTP password of that key. Part of devantler-tech/platform#5481. Co-Authored-By: Claude Opus 5.5 --- .../arc-staging/mail_integration_test.go | 24 ++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/scripts/tests/arc-staging/mail_integration_test.go b/scripts/tests/arc-staging/mail_integration_test.go index b264497370..3dc8ed7651 100644 --- a/scripts/tests/arc-staging/mail_integration_test.go +++ b/scripts/tests/arc-staging/mail_integration_test.go @@ -37,10 +37,12 @@ func TestPrivateMailCredentialsHaveExactSeedAndReadAuthorization(t *testing.T) { } _, policy := captureBaoWrite(t, "bao", "policy", "write", "vault-seed-write") entries := regexp.MustCompile(`(?s)path\s+"(secret/(?:data|metadata)/infrastructure/email/[^\"]+)"\s*\{\s*capabilities\s*=\s*(\[[^\]]+\])\s*\}`).FindAllStringSubmatch(policy, -1) + // The three mailbox credentials, plus the SES relay's SMTP credential that a + // platform-applied PushSecret copies from its AccessKey (platform#5481). want := map[string]bool{} for _, kind := range []string{"data", "metadata"} { - for _, account := range []string{"admin", "maintainer", "agent"} { - want["secret/"+kind+"/infrastructure/email/"+account] = true + for _, credential := range []string{"admin", "maintainer", "agent", "ses-smtp"} { + want["secret/"+kind+"/infrastructure/email/"+credential] = true } } if len(entries) != len(want) { @@ -48,7 +50,7 @@ func TestPrivateMailCredentialsHaveExactSeedAndReadAuthorization(t *testing.T) { } for _, entry := range entries { if !want[entry[1]] { - t.Fatal("mail credential authorization is duplicated or broader than its three entries") + t.Fatal("mail credential authorization is duplicated or broader than its four entries") } delete(want, entry[1]) var capabilities []string @@ -81,6 +83,22 @@ func TestPrivateMailCredentialsHaveExactSeedAndReadAuthorization(t *testing.T) { equal(t, mailField[string](t, seed, "spec", "updatePolicy"), "IfNotExists") equal(t, mailField[string](t, seed, "spec", "deletionPolicy"), "None") } + // The relay credential follows its AccessKey, so it replaces rather than + // seeds, and it writes only the username and SMTP password of that one key. + relay := readYAML(t, "k8s/providers/hetzner/apps/aws/push-secret-email-smtp.yaml") + equal(t, mailField[string](t, relay, "metadata", "namespace"), "aws") + equal(t, mailField[string](t, relay, "spec", "selector", "secret", "name"), "email-smtp-credentials") + equal(t, mailField[string](t, relay, "spec", "updatePolicy"), "Replace") + equal(t, mailField[string](t, relay, "spec", "deletionPolicy"), "None") + relayData := mailField[[]any](t, relay, "spec", "data") + equal(t, len(relayData), 2) + pushed := map[string]string{} + for _, entry := range relayData { + equal(t, mailField[string](t, entry, "match", "remoteRef", "remoteKey"), "infrastructure/email/ses-smtp") + pushed[mailField[string](t, entry, "match", "secretKey")] = mailField[string](t, entry, "match", "remoteRef", "property") + } + equal(t, pushed["username"], "username") + equal(t, pushed["attribute.ses_smtp_password_v4"], "password") } // Match the first node rule exactly as declared, including catch-all precedence. From 5295f0e65a5ff06d084693ce0bf3631a66f069d2 Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Fri, 13 Nov 2026 06:58:14 +0100 Subject: [PATCH 3/3] chore(security): approve the SES SMTP identity's authorization surface Approve the four new entries of the rendered authorization ledger: the SMTP IAM user, its send-only policy and attachment, and its access key. The policy allows only ses:SendRawEmail on the company mail domain's identity in eu-central-1 with a sender on that domain. Part of devantler-tech/platform#5481. Co-Authored-By: Claude Opus 5.5 --- scripts/validate-eks-ci-role-policy/approved-surface.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/scripts/validate-eks-ci-role-policy/approved-surface.txt b/scripts/validate-eks-ci-role-policy/approved-surface.txt index 0470d2740f..b3164d1935 100644 --- a/scripts/validate-eks-ci-role-policy/approved-surface.txt +++ b/scripts/validate-eks-ci-role-policy/approved-surface.txt @@ -124,10 +124,18 @@ helm.toolkit.fluxcd.io/v2|HelmRelease|vertical-pod-autoscaler|vertical-pod-autos helm.toolkit.fluxcd.io/v2|HelmRelease|whoami|whoami 22eb185e9f69bbddf8dc27bd2a852b07b3bbaf791d25ada894eeb8e954f99bed +iam.aws.m.upbound.io/v1beta1|AccessKey|aws|email-smtp 22ff8010a4298f2b19a2829a65c383f27fd737b2aed7b096f22814ad73a2f240 + iam.aws.m.upbound.io/v1beta1|Policy|aws|eks-ci-smoke-boundary 019210611429956763cab81a883bc6cf1faf53caf89b5e9274e8ec69cad01b66 +iam.aws.m.upbound.io/v1beta1|Policy|aws|email-smtp-send 38284030cdef086fa0a51443feba839b2f6fcf27bf1cc177fa2fa15d314ceb30 + iam.aws.m.upbound.io/v1beta1|Role|aws|eks-ci c40205b3f48d193e8be1a39abda738865b954c90733039a49854f0bac5844306 +iam.aws.m.upbound.io/v1beta1|UserPolicyAttachment|aws|email-smtp-send 06c8f5c0aa8f7b593878b9869c5af7375a1ef2f429182cb904e76e0dae966e1c + +iam.aws.m.upbound.io/v1beta1|User|aws|email-smtp 19ce46105be088b444658d4d594f6059308f079440336af06af912d60aeb5704 + kro.run/v1alpha1|ResourceGraphDefinition||tenant.kro.run 72f3f972cecdf3ca2e315deb4224bd28c1df1244fc7973a88eb7f4fc03ac1d05 kro.run/v1alpha1|Tenant|flux-system|business-site 5854dbac8e7f4ff52f5d858ee7e673e82cd758f0c770c3203b9409c8dc15aba2