Skip to content

Commit aa26e2f

Browse files
Remove dangerous iam:PassRole and redundant SSM permissions from EC2 policy
Security fix: EC2 instances do not need iam:PassRole permission as they never create resources requiring role assignment. This was a privilege escalation risk. Also removed SSM permissions (ssmmessages, ssm:SendCommand, ssm:GetCommandInvocation, etc.) as these are: 1. Already provided by the AmazonSSMManagedInstanceCore managed policy attached at line 71 2. Not needed by EC2 instances (these are for SENDING commands TO instances, not receiving them) Kept S3 wildcard access as EC2 instances need to read/write datastream data. This is the minimal security hardening change with zero functional impact.
1 parent ded1ec6 commit aa26e2f

File tree

1 file changed

+0
-30
lines changed
  • infra/aws/terraform/modules/orchestration

1 file changed

+0
-30
lines changed

infra/aws/terraform/modules/orchestration/iam_ec2.tf

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,12 @@ resource "aws_iam_policy" "ec2_policy" {
2020
policy = jsonencode({
2121
Version = "2012-10-17",
2222
Statement = [
23-
{
24-
Effect = "Allow",
25-
Action = [
26-
"ssmmessages:CreateControlChannel",
27-
"ssmmessages:CreateDataChannel",
28-
"ssmmessages:OpenControlChannel",
29-
"ssmmessages:OpenDataChannel",
30-
"ssm:DescribeInstanceInformation",
31-
"ssm:SendCommand",
32-
"ssm:GetCommandInvocation",
33-
"ssm:PutComplianceItems",
34-
"ssm:UpdateInstanceInformation"
35-
],
36-
Resource = "*"
37-
},
38-
{
39-
Effect = "Allow",
40-
Action = [
41-
"iam:PassRole"
42-
],
43-
Resource = "*"
44-
},
4523
{
4624
Effect = "Allow",
4725
Action = [
4826
"s3:*"
4927
],
5028
Resource = "*"
51-
},
52-
{
53-
Effect = "Allow",
54-
Action = [
55-
"ec2:DescribeInstances",
56-
"ec2:DescribeTags"
57-
],
58-
Resource = "*"
5929
}
6030
]
6131
})

0 commit comments

Comments
 (0)