IAM Group Without Users
- Query id: 8f957abd-9703-413d-87d3-c578950a753c
- Query name: IAM Group Without Users
- Platform: CloudFormation
- Severity: Medium
- Category: Access Control
- CWE: 284
- URL: Github
Description¶
IAM Group should have at least one user associated
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Positive test num. 1 - yaml file
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template 2
Resources:
myuseeer:
Type: AWS::IAM::Group
Properties:
Path: "/"
LoginProfile:
Password: myP@ssW0rd
Policies:
- PolicyName: giveaccesstoqueueonly
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- sqs:*
Resource:
- !GetAtt myqueue.Arn
- Effect: Deny
Action:
- sqs:*
NotResource:
- !GetAtt myqueue.Arn
IamUserAdminSample22:
Type: AWS::IAM::User
Condition: IsSampleIamUser
Properties:
UserName: sample-iam-user-admin
Groups:
- !Ref 'myu2ser'
Positive test num. 2 - json file
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template",
"Resources": {
"myuseeer2": {
"Type": "AWS::IAM::Group",
"Properties": {
"Policies": [
{
"PolicyName": "giveaccesstoqueueonly",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:*"
],
"Resource": [
"myqueue.Arn"
]
},
{
"Action": [
"sqs:*"
],
"NotResource": [
"myqueue.Arn"
],
"Effect": "Deny"
}
]
}
}
],
"Path": "/",
"LoginProfile": {
"Password": "myP@ssW0rd"
}
}
},
"IamUserAdminSample222": {
"Type": "AWS::IAM::User",
"Condition": "IsSampleIamUser",
"Properties": {
"UserName": "sample-iam-user-admin",
"Groups": [
"myu2ser"
]
}
}
}
}
Code samples without security vulnerabilities¶
Negative test num. 1 - yaml file
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
myuser:
Type: AWS::IAM::Group
Properties:
Path: "/"
LoginProfile:
Password: myP@ssW0rd
Policies:
- PolicyName: giveaccesstoqueueonly
PolicyDocument:
Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- sqs:*
Resource:
- !GetAtt myqueue.Arn
- Effect: Deny
Action:
- sqs:*
NotResource:
- !GetAtt myqueue.Arn
IamUserAdminSample:
Type: AWS::IAM::User
Condition: IsSampleIamUser
Properties:
UserName: sample-iam-user-admin
Groups:
- !Ref 'myuser'
Negative test num. 2 - json file
{
"Description": "A sample template",
"Resources": {
"myuserr": {
"Type": "AWS::IAM::Group",
"Properties": {
"Policies": [
{
"PolicyName": "giveaccesstoqueueonly",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:*"
],
"Resource": [
"myqueue.Arn"
]
},
{
"NotResource": [
"myqueue.Arn"
],
"Effect": "Deny",
"Action": [
"sqs:*"
]
}
]
}
}
],
"Path": "/",
"LoginProfile": {
"Password": "myP@ssW0rd"
}
}
},
"IamUserAdminSample": {
"Type": "AWS::IAM::User",
"Condition": "IsSampleIamUser",
"Properties": {
"UserName": "sample-iam-user-admin",
"Groups": [
"myuserr"
]
}
}
},
"AWSTemplateFormatVersion": "2010-09-09"
}