Skip to content

Commit 87808f7

Browse files
comruminocloudpossebotaknysh
authored
Fixed potential self-escalation from iam:PassRole (#215)
* Fixed potential self-escalation from iam:PassRole by moving it from AllowOperations to a new statement named AllowPassRole that restricts resources to aws_iam_role.ec2 and aws_iam_role.service * Auto Format Co-authored-by: cloudpossebot <[email protected]> Co-authored-by: Andriy Knysh <[email protected]>
1 parent 92a3ade commit 87808f7

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

main.tf

+15-1
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,6 @@ data "aws_iam_policy_document" "default" {
255255
"elasticloadbalancing:RegisterTargets",
256256
"elasticloadbalancing:DeregisterTargets",
257257
"iam:ListRoles",
258-
"iam:PassRole",
259258
"logs:CreateLogGroup",
260259
"logs:PutRetentionPolicy",
261260
"rds:DescribeDBEngineVersions",
@@ -281,6 +280,21 @@ data "aws_iam_policy_document" "default" {
281280
effect = "Allow"
282281
}
283282

283+
statement {
284+
sid = "AllowPassRole"
285+
286+
actions = [
287+
"iam:PassRole"
288+
]
289+
290+
resources = [
291+
join("", aws_iam_role.ec2.*.arn),
292+
join("", aws_iam_role.service.*.arn)
293+
]
294+
295+
effect = "Allow"
296+
}
297+
284298
statement {
285299
sid = "AllowS3OperationsOnElasticBeanstalkBuckets"
286300

0 commit comments

Comments
 (0)