More nuanced handling of aws-iam-no-policy-wildcards with suffixes #1639
Replies: 1 comment
-
I'll add a closely-related issue which I hit again today and was previously reported as https://github.com/aquasecurity/tfsec/issues/1014 where policies are written using a resource of Here are two examples: statement {
resources = ["*"]
actions = [
"backup:TagResource",
]
condition {
test = "StringLike"
variable = "aws:RequestTag/Environment"
values = [var.global_tags["Environment"]]
}
condition {
test = "StringLike"
variable = "aws:RequestTag/Project"
values = [var.global_tags["Project"]]
}
} actions = [
"ssm:StartSession",
]
resources = [
"arn:aws:ec2:*:*:instance/*",
]
condition {
test = "StringLike"
variable = "ssm:resourceTag/Project"
values = ["ExampleProject"]
}
condition {
test = "StringLike"
variable = "ssm:resourceTag/Environment"
values = [local.default_tags["Environment"]]
}
condition {
test = "BoolIfExists"
variable = "ssm:SessionDocumentAccessCheck"
values = ["true"]
} I think in both cases it would be relatively easy to shoot yourself in the foot if your conditions were quite broad but the same is also true, arguably more likely, if the devops team is trained to toss I think the list of solutions is pretty similar — the one I like the most is having a general rule that the severity goes down if there's a condition (or prefix/suffix in the original case), possibly more than once in the event of multiple constraints: e.g. CRITICAL -> HIGH (prefix/suffix rather than |
Beta Was this translation helpful? Give feedback.
-
I've run into a number of cases where the
aws-iam-no-policy-wildcards
is technically correct but doesn't warrant the default HIGH blocking e.g. CI runs because the policies in question had a wildcard suffix. Some examples:"arn:aws:secretsmanager:${var.region}:${data.aws_caller_identity.current.account_id}:secret:manufacturer_key*"
"arn:aws:ssm:${data.aws_region.current.name}:${data.aws_caller_identity.current.account_id}:parameter${local.ssm_parameter_prefix}*"
Describe*
"arn:aws:ssm:*:*:session/${aws:username}-*"
Some ideas:
??????
# tfsec:ignore:aws-iam-no-policy-wildcard-suffix
won't mask an error if some change later causes that value to evaluate to a simple*
.Describe*
/List*
since those are generally safe and that would put the higher priority focus on things which are more likely to have side-effects.Beta Was this translation helpful? Give feedback.
All reactions