IAM User With No Group
- Query id: 06933df4-0ea7-461c-b9b5-104d27390e0e
- Query name: IAM User With No Group
- Platform: CloudFormation
- Severity: Low
- Category: Access Control
- URL: Github
Description¶
A IAM user should belong to a group
Documentation
Code samples¶
Code samples with security vulnerabilities¶
Postitive test num. 1 - yaml file
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
MyUser:
Type: AWS::IAM::User
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
Tags:
- QAUser
UserName: TestUser
Postitive test num. 2 - yaml file
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
emptyGroup:
Type: AWS::IAM::User
Properties:
Groups: []
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
Tags:
- QAUser
UserName: TestUser
Postitive test num. 3 - json file
{
"Resources": {
"MyUser": {
"Type": "AWS::IAM::User",
"Properties": {
"Policies": [
{
"PolicyName": "giveaccesstoqueueonly",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"sqs:*"
],
"Resource": [
"myqueue.Arn"
],
"Effect": "Allow"
},
{
"Effect": "Deny",
"Action": [
"sqs:*"
],
"NotResource": [
"myqueue.Arn"
]
}
]
}
}
],
"Tags": [
"QAUser"
],
"UserName": "TestUser",
"Path": "/",
"LoginProfile": {
"Password": "myP@ssW0rd"
}
}
}
},
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template"
}
Postitive test num. 4 - json file
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template",
"Resources": {
"emptyGroup": {
"Type": "AWS::IAM::User",
"Properties": {
"Groups": [],
"Path": "/",
"LoginProfile": {
"Password": "myP@ssW0rd"
},
"Policies": [
{
"PolicyName": "giveaccesstoqueueonly",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:*"
],
"Resource": [
"myqueue.Arn"
]
},
{
"Effect": "Deny",
"Action": [
"sqs:*"
],
"NotResource": [
"myqueue.Arn"
]
}
]
}
}
],
"Tags": [
"QAUser"
],
"UserName": "TestUser"
}
}
}
}
Code samples without security vulnerabilities¶
Negative test num. 1 - yaml file
AWSTemplateFormatVersion: "2010-09-09"
Description: A sample template
Resources:
addUserToGroup2:
Type: AWS::IAM::User
Properties:
Groups:
- QAGroup
LoginProfile:
Password: myP@ssW0rd
Path: "/"
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
Tags:
- QAUser
UserName: TestUser
Negative test num. 2 - json file
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "A sample template",
"Resources": {
"addUserToGroup2": {
"Type": "AWS::IAM::User",
"Properties": {
"Groups": [
"QAGroup"
],
"LoginProfile": {
"Password": "myP@ssW0rd"
},
"Path": "/",
"Policies": [
{
"PolicyName": "giveaccesstoqueueonly",
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"sqs:*"
],
"Resource": [
"myqueue.Arn"
]
},
{
"Effect": "Deny",
"Action": [
"sqs:*"
],
"NotResource": [
"myqueue.Arn"
]
}
]
}
}
],
"Tags": [
"QAUser"
],
"UserName": "TestUser"
}
}
}
}