Skip to content

fix(deployment): scope the Datadog Forwarder's kms:Decrypt to its own keys - #106

Open
jpr5 wants to merge 1 commit into
mainfrom
security/forwarder-kms-scope
Open

jpr5 wants to merge 1 commit into
mainfrom
security/forwarder-kms-scope

Conversation

@jpr5

@jpr5 jpr5 commented Dec 1, 2026

Copy link
Copy Markdown

What

The Datadog Forwarder template (5.4.11) gives its role kms:Decrypt on "*" when KmsKeyList is empty. We never set it, so all three kite forwarder roles can decrypt every customer-managed key in account 604598162673, including the Intelligence licence key (alias/copilotkit-license-encryption). That key uses the default key policy, so IAM alone decides access.

The forwarder needs no customer-managed key. It reads its API key secret, which uses the AWS-managed aws/secretsmanager key, and its own bucket, which uses aws/s3. This PR sets KmsKeyList to the key ARNs behind those two aliases. Two AwsCustomResource DescribeKey lookups resolve the ARNs at deploy time, so each account and region gets its own keys and no ARNs are hardcoded. If secretsKmsKeyArn is set, that key is added too.

RED (live, read-only)

Each forwarder role has an inline ForwarderRolePolicy0 with {"Action":["kms:Decrypt"],"Resource":"*","Effect":"Allow"}. Result of aws iam simulate-principal-policy --action-names kms:Decrypt --resource-arns arn:aws:kms:us-east-1:604598162673:key/10321f7b-1581-4540-9d49-d818523098ff:

kite-community-DatadogForwarder-1TZRA-ForwarderRole-IsYyJxQoxxxN  allowed  (ForwarderRolePolicy0)
kite-prod-DatadogForwarder-1AKRL5RDU5-ForwarderRole-1NusIWsS8ppY   allowed  (ForwarderRolePolicy0)
kite-staging-DatadogForwarder-EKX137R-ForwarderRole-7mOm4VRlKMHX   allowed  (ForwarderRolePolicy0)

Synth diff

From cdk synth kite-prod -c appName=kite -c environment=prod -c sharedCluster=true, before and after this change. These are the forwarder nested stack's parameters:

@@ -2,6 +2,25 @@
   "DdApiKeySecretArn": {
     "Ref": "DatadogApiKeySecretArn"
   },
+  "KmsKeyList": {
+    "Fn::Join": [
+      ",",
+      [
+        {
+          "Fn::GetAtt": [
+            "AwsManagedKmsKeySecretsManagerA9C3BDC8",
+            "KeyMetadata.Arn"
+          ]
+        },
+        {
+          "Fn::GetAtt": [
+            "AwsManagedKmsKeyS3F8765863",
+            "KeyMetadata.Arn"
+          ]
+        }
+      ]
+    ]
+  },
   "DdSite": "datadoghq.com",
   "DdTags": "service:kite,application:kite,env:prod",
   "FunctionName": "kite-prod-datadog-forwarder"

New resources: AwsManagedKmsKeySecretsManager, AwsManagedKmsKeyS3 (each with its CustomResourcePolicy allowing kms:DescribeKey), and the shared AwsCustomResource provider function and role. No resources are removed.

In us-west-2, the two aliases currently resolve to key/eb1e900a-… (aws/secretsmanager) and key/ff92dfcd-… (aws/s3). I ran simulate-custom-policy on the scoped statement before deploying:

licence key 10321f7b-…   implicitDeny
eb1e900a-… (aws/secretsmanager)   allowed
ff92dfcd-… (aws/s3)   allowed

Checks

  • pnpm --dir deployment/aws build (tsc): pass
  • pnpm --dir deployment/aws test: 28/28 pass. Two new tests failed before the change and pass after it.

GREEN (after deploy)

  • simulate-principal-policy for each forwarder role shows implicitDeny on the licence key and allowed on the two AWS-managed keys.
  • The forwarder Lambdas still ship logs: CloudWatch Invocations and Errors stay unchanged. The baseline is about 2,885 invocations and 0 errors per forwarder per 24h.

Deploy

Deploy all three stacks (staging, community, prod) after review; owner Tyler.

Nothing has been deployed.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Q4kRRs8251kXTRWNeNywkH

… keys

The Datadog Forwarder template grants kms:Decrypt on "*" when its
KmsKeyList parameter is empty, so the forwarder role could decrypt every
customer-managed key in the account. Pass the key ARNs behind the
AWS-managed aws/secretsmanager and aws/s3 aliases, resolved per account
and region at deploy time, plus secretsKmsKeyArn when it is set.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant