AWS IAM role has a large permissions gap

Description

To mitigate the impact of credential exposure or compromise, IAM policies should be scoped down to the least level of privilege needed to perform their responsibilities. This rule identifies when a role’s policy’s permissions are more broad than what is regularly used. Datadog considers a permissions gap to be large when the number of unused permissions is greater than 40% of the total permissions count.

Rationale

By comparing what actions an IAM role performed in the last 15 days with what the role’s policies permit, we can identify a permissions gap. This gap should be removed to mitigate the impact of a potential compromise.

Remediation

Datadog recommends reducing the permissions attached to an IAM role to the minimum necessary for it to fulfill its function. You can use AWS Access Advisor to identify effective permissions used by your instances, and use AWS IAM Access Analyzer to generate an IAM policy based on past CloudTrail events.

CloudTrail logs can be filtered in multiple ways that can impact rule detection.

  1. CloudTrail logs forwarded to Datadog using the Datadog Forwarder Lambda function can be filtered through the ExcludeAtMatch parameter as detailed in the log filtering section of the Datadog forwarder page. Check the Datadog Forwarder Lambda function settings for any unused permissions being excluded. If the unused permissions are part of the exclusion filters, remove the entries excluding the logs containing these permissions.
  2. Please check AWS for any configured event selectors. Individual trails can be configured to filter out events based on Event Selectors. Please ensure forwarded logs don’t have Event Selectors enabled.