Skip to content

Infrastructure Modification check ignores conditions set on policy #278

@ghost

Description

It appears that the checks for Infrastructure Modification report actions even when conditions apply - while, on the other hand, the checks for e.g. Data Exfiltration and Privilege Escalation do not flag actions when conditions apply.

This causes false negatives when we have a policy that, for example, allows ec2.RunInstances but includes a condition that ec2:Owner must be a certain account; such a policy has been crafted deliberately, but Cloudsplaining still flags it as allowing Infrastructure Modification.

To reproduce, consider this policy:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Action": [
        "ec2:RunInstances"
      ],
      "Condition": {
        "StringEquals": {
            "ec2:Owner": "ValidOwnerId"
          }
      },
      "Resource": "*",
      "Effect": "Allow"
    },
    {
        "Effect": "Allow",
        "Action": "s3:GetObject",
        "Condition": {
            "StringEquals": {
                "ec2:Owner": "ValidOwnerId"
              }
          },
        "Resource": "*"
    },
    {
        "Effect": "Allow",
        "Action": "glue:updatedevendpoint",
        "Condition": {
            "StringEquals": {
                "ec2:Owner": "ValidOwnerId"
              }
          },
        "Resource": "*"
    }
  ]
}

If we remove those Condition blocks, Cloudsplaining identifies 3 issues:
cs-detects-issues

After adding the Conditions, Data Exfiltration and Privilege Escalation disappear, but Infrastructure Modification remains:
cs-detects-im

Expected Behaviour: The presence of Conditions causes Cloudsplaining to suppress Infrastructure Modification warnings.

Actual Behaviour: Cloudsplaining reports Infrastructure Modification even though Conditions exist on the policy.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions