Skip to content

Overly broad IAM Permission Scope for Datadog Forwarders #995

@aatif912

Description

@aatif912

Issue Description

Security concerns regarding the IAM permissions used in the Datadog serverless forwarders and would like guidance on implementing security best practices while maintaining full functionality.

Background

During a security assessment of infrastructure using the community terraform module (terraform-aws-datadog-forwarders), it was discovered that several permissions that appear overly broad from a security perspective. The terraform module is based on official templates, so I want to understand the reasoning behind these permissions and get guidance on potential improvements.

Current Permission Concerns

KMS Decrypt Permissions

Current State in Main Template (template.yaml:670):

- Action:
    - kms:Decrypt
  Resource: "*"
  Effect: Allow

Concern: This allows decryption of ANY KMS-encrypted data in the AWS account, including:

  • RDS snapshots
  • EBS volumes
  • Secrets Manager secrets
  • S3 objects
  • Any other KMS-encrypted resources

Observed Inconsistency: Specialized templates use more restrictive approaches:

Questions for the Team

  1. KMS Permissions: Is the broad kms:Decrypt on "*" truly necessary for the main log forwarder? Could it be scoped to specific keys like in the RDS/VPC templates?

  2. Service Conditions: Would adding service conditions (like kms:ViaService) provide sufficient security while maintaining functionality?

    "Condition": {
      "StringEquals": {
        "kms:ViaService": [
          "lambda.*.amazonaws.com",
          "secretsmanager.*.amazonaws.com", 
          "s3.*.amazonaws.com"
        ]
      }
    }
  3. Regional Restrictions: Would regional conditions help reduce cross-region exposure?

  4. Documentation: Could you provide guidance on the minimum required permissions for each forwarder type?

Proposed Solutions

Based on RDS/VPC templates, I propose:

Option 1: KMS Key-Specific (Recommended)

{
  "Action": ["kms:Decrypt"],
  "Resource": "arn:aws:kms:*:*:key/${KMSKeyId}",
  "Condition": {
    "StringEquals": {
      "kms:ViaService": ["lambda.*.amazonaws.com", "secretsmanager.*.amazonaws.com", "s3.*.amazonaws.com"]
    }
  }
}

Option 2: Enhanced Service Conditions

{
  "Action": ["kms:Decrypt"],
  "Resource": "*",
  "Condition": {
    "StringEquals": {
      "kms:ViaService": ["lambda.*.amazonaws.com", "secretsmanager.*.amazonaws.com", "s3.*.amazonaws.com"]
    }
  }
}

Environment Details

  • Repository: DataDog/datadog-serverless-functions
  • Affected Templates:
    • aws/logs_monitoring/template.yaml
    • Community terraform module policies based on these templates

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions