Skip to content

Commit 2ff7f32

Browse files
authored
Merge pull request #136 from cloudgraphdev/fix/CG-1336-aws-pci-iam-check-3
fix(CG-1336): fix PCI IAM check 3
2 parents ed3be7b + 2188b34 commit 2ff7f32

2 files changed

Lines changed: 57 additions & 18 deletions

File tree

src/aws/pci-dss-3.2.1/rules/pci-dss-3.2.1-iam-check-3.ts

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -45,24 +45,32 @@ export default {
4545
resource: 'queryawsIamPolicy[*]',
4646
severity: 'high',
4747
conditions: {
48-
not: {
49-
path: '@.policyContent.statement',
50-
array_any: {
51-
and: [
52-
{
53-
path: '[*].effect',
54-
equal: 'Allow',
55-
},
56-
{
57-
path: '[*].action',
58-
contains: '*',
59-
},
60-
{
61-
path: '[*].resource',
62-
contains: '*',
63-
},
64-
],
48+
or: [
49+
{
50+
path: '@.name',
51+
equal: 'AdministratorAccess',
6552
},
66-
},
53+
{
54+
not: {
55+
path: '@.policyContent.statement',
56+
array_any: {
57+
and: [
58+
{
59+
path: '[*].effect',
60+
equal: 'Allow',
61+
},
62+
{
63+
path: '[*].action',
64+
contains: '*',
65+
},
66+
{
67+
path: '[*].resource',
68+
contains: '*',
69+
},
70+
],
71+
},
72+
},
73+
}
74+
]
6775
},
6876
}

src/aws/pci-dss-3.2.1/tests/pci-dss-3.2.1-iam-checks.test.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ describe('PCI Data Security Standard: 3.2.1', () => {
101101
queryawsIamPolicy: [
102102
{
103103
id: cuid(),
104+
name: 'AdministratorAccess-Amplify',
104105
policyContent: {
105106
statement: [
106107
{
@@ -131,6 +132,7 @@ describe('PCI Data Security Standard: 3.2.1', () => {
131132
queryawsIamPolicy: [
132133
{
133134
id: cuid(),
135+
name: 'AdministratorAccess-Amplify',
134136
policyContent: {
135137
statement: [
136138
{
@@ -157,6 +159,7 @@ describe('PCI Data Security Standard: 3.2.1', () => {
157159
queryawsIamPolicy: [
158160
{
159161
id: cuid(),
162+
name: 'AdministratorAccess-Amplify',
160163
policyContent: {
161164
statement: [
162165
{
@@ -187,6 +190,7 @@ describe('PCI Data Security Standard: 3.2.1', () => {
187190
queryawsIamPolicy: [
188191
{
189192
id: cuid(),
193+
name: 'AdministratorAccess-Amplify',
190194
policyContent: {
191195
statement: [
192196
{
@@ -207,6 +211,33 @@ describe('PCI Data Security Standard: 3.2.1', () => {
207211

208212
expect(processedRule.result).toBe(Result.FAIL)
209213
})
214+
215+
test('Should pass when IAM policies that allow full "*:*" administrative privileges for AdministratorAccess policy', async () => {
216+
const data = {
217+
queryawsIamPolicy: [
218+
{
219+
id: cuid(),
220+
name: 'AdministratorAccess',
221+
policyContent: {
222+
statement: [
223+
{
224+
effect: 'Allow',
225+
action: ['*'],
226+
resource: ['*'],
227+
},
228+
],
229+
},
230+
},
231+
],
232+
}
233+
234+
const [processedRule] = await rulesEngine.processRule(
235+
Aws_PCI_DSS_321_IAM_3 as Rule,
236+
{ ...data } as any
237+
)
238+
239+
expect(processedRule.result).toBe(Result.PASS)
240+
})
210241
})
211242

212243
describe('IAM Check 4: Hardware MFA should be enabled for the root user', () => {

0 commit comments

Comments
 (0)