Skip to content

Commit b060c72

Browse files
authored
Merge pull request #125 from cloudgraphdev/fix/CG-1242-aws-cis-1.16-exclude-AdministratorAccess
Fix/cg 1242 aws cis 1.16 exclude administrator access
2 parents 8c909f4 + 0f6157f commit b060c72

2 files changed

Lines changed: 39 additions & 22 deletions

File tree

src/aws/cis-1.4.0/rules/aws-cis-1.4.0-1.16.ts

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ export default {
6565
queryawsIamPolicy {
6666
id
6767
arn
68+
name
6869
accountId
6970
__typename
7071
policyContent {
@@ -79,24 +80,32 @@ export default {
7980
resource: 'queryawsIamPolicy[*]',
8081
severity: 'high',
8182
conditions: {
82-
not: {
83-
path: '@.policyContent.statement',
84-
array_any: {
85-
and: [
86-
{
87-
path: '[*].effect',
88-
equal: 'Allow',
89-
},
90-
{
91-
path: '[*].action',
92-
contains: '*',
93-
},
94-
{
95-
path: '[*].resource',
96-
contains: '*',
83+
or: [
84+
{
85+
path: '@.name',
86+
equal: 'AdministratorAccess',
87+
},
88+
{
89+
not: {
90+
path: '@.policyContent.statement',
91+
array_any: {
92+
and: [
93+
{
94+
path: '[*].effect',
95+
equal: 'Allow',
96+
},
97+
{
98+
path: '[*].action',
99+
contains: '*',
100+
},
101+
{
102+
path: '[*].resource',
103+
contains: '*',
104+
},
105+
],
97106
},
98-
],
107+
},
99108
},
100-
},
109+
]
101110
},
102111
}

src/aws/cis-1.4.0/tests/aws-cis-1.4.0-1.x.test.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ export interface PolicyContent {
4848
}
4949
export interface QueryawsIamPolicy {
5050
id: string
51+
name: string
5152
policyContent: PolicyContent
5253
}
5354

@@ -703,6 +704,7 @@ describe('CIS Amazon Web Services Foundations: 1.4.0', () => {
703704

704705
describe('AWS CIS 1.16 Ensure IAM policies that allow full "*:*" administrative privileges are not attached', () => {
705706
const getTestRuleFixture = (
707+
name: string,
706708
effect: string,
707709
action: string[],
708710
resource: string[]
@@ -711,6 +713,7 @@ describe('CIS Amazon Web Services Foundations: 1.4.0', () => {
711713
queryawsIamPolicy: [
712714
{
713715
id: cuid(),
716+
name,
714717
policyContent: {
715718
statement: [
716719
{
@@ -741,7 +744,7 @@ describe('CIS Amazon Web Services Foundations: 1.4.0', () => {
741744
}
742745

743746
test('No Security Issue when IAM policies not allow full "*:*" administrative privileges', async () => {
744-
const data: CIS1xQueryResponse = getTestRuleFixture('Allow', [
747+
const data: CIS1xQueryResponse = getTestRuleFixture('AdministratorAccess-Amplify', 'Allow', [
745748
'secretsmanager:DeleteSecret',
746749
'secretsmanager:GetSecretValue',
747750
'secretsmanager:UpdateSecret',
@@ -750,23 +753,28 @@ describe('CIS Amazon Web Services Foundations: 1.4.0', () => {
750753
})
751754

752755
test('No Security Issue when IAM policies that have a statement with "Effect": "Allow" with "Action": "*" over restricted "Resource"', async () => {
753-
const data: CIS1xQueryResponse = getTestRuleFixture('Allow', ['*'], ['arn:aws:secretsmanager:*:*:secret:A4B*'])
756+
const data: CIS1xQueryResponse = getTestRuleFixture('AdministratorAccess-Amplify', 'Allow', ['*'], ['arn:aws:secretsmanager:*:*:secret:A4B*'])
754757
await testRule(data, Result.PASS)
755758
})
756759

757760
test('No Security Issue when IAM policies that have a statement with "Effect": "Allow" with restricted "Action" over "Resource": "*"', async () => {
758-
const data: CIS1xQueryResponse = getTestRuleFixture('Allow', [
761+
const data: CIS1xQueryResponse = getTestRuleFixture('AdministratorAccess-Amplify', 'Allow', [
759762
'secretsmanager:DeleteSecret',
760763
'secretsmanager:GetSecretValue',
761764
'secretsmanager:UpdateSecret',
762765
], ['*'])
763766
await testRule(data, Result.PASS)
764767
})
765768

766-
test('No Security Issue when IAM policies that allow full "*:*" administrative privileges', async () => {
767-
const data: CIS1xQueryResponse = getTestRuleFixture('Allow', ['*'], ['*'])
769+
test('Security Issue when IAM policies that allow full "*:*" administrative privileges for non AdministratorAccess policy', async () => {
770+
const data: CIS1xQueryResponse = getTestRuleFixture('AdministratorAccess-Amplify', 'Allow', ['*'], ['*'])
768771
await testRule(data, Result.FAIL)
769772
})
773+
774+
test('No Security Issue when IAM policies that allow full "*:*" administrative privileges for AdministratorAccess policy', async () => {
775+
const data: CIS1xQueryResponse = getTestRuleFixture('AdministratorAccess', 'Allow', ['*'], ['*'])
776+
await testRule(data, Result.PASS)
777+
})
770778
})
771779

772780
describe('AWS CIS 1.17 Ensure a support role has been created to manage incidents with AWS Support', () => {

0 commit comments

Comments
 (0)