--- policy: /ce/ca/aws/cognito/identity-pool-unauthenticated-identities logic: /ce/ca/aws/cognito/identity-pool-unauthenticated-identities/prod.logic.yaml executionTime: 2026-04-25T12:02:19.104388464Z generationMs: 48 executionMs: 1861 rows: - id: test1 match: true status: expected: DISAPPEARED actual: DISAPPEARED conditionIndex: expected: 99 actual: 99 conditionText: expected: isDisappeared(CA10A1__disappearanceTime__c) actual: isDisappeared(CA10A1__disappearanceTime__c) runtimeError: {} - id: test2 match: true status: expected: INCOMPLIANT actual: INCOMPLIANT conditionIndex: expected: 199 actual: 199 conditionText: expected: extract('CA10A1__allowUnauthenticatedIdentities__c') == 'true' actual: extract('CA10A1__allowUnauthenticatedIdentities__c') == 'true' runtimeError: {} - id: test3 match: true status: expected: COMPLIANT actual: COMPLIANT conditionIndex: expected: 299 actual: 299 conditionText: expected: extract('CA10A1__allowUnauthenticatedIdentities__c') == 'false' actual: extract('CA10A1__allowUnauthenticatedIdentities__c') == 'false' runtimeError: {} - id: test4 match: true status: expected: UNDETERMINED actual: UNDETERMINED conditionIndex: expected: 300 actual: 300 conditionText: expected: otherwise actual: otherwise runtimeError: {} usedFiles: - path: /ce/ca/aws/cognito/identity-pool-unauthenticated-identities/policy.yaml md5Hash: E3357605FD52CBF2F7F7C0248C50B9B8 content: | --- names: full: "AWS Cognito Identity Pool allows unauthenticated identities" contextual: "Identity Pool allows unauthenticated identities" description: > Ensure that Amazon Cognito identity pools do not allow unauthenticated identities. When guest access is enabled, Amazon Cognito can issue temporary AWS credentials to users who have not authenticated with a trusted identity provider, increasing the risk of unintended access to downstream AWS resources. type: "COMPLIANCE_POLICY" categories: - "SECURITY" frameworkMappings: - "/frameworks/cloudaware/resource-security/secure-access" - "/frameworks/aws-fsbp-v1.0.0/cognito/02" similarPolicies: awsSecurityHub: - name: "[Cognito.2] Cognito identity pools should not allow unauthenticated identities" url: "https://docs.aws.amazon.com/securityhub/latest/userguide/cognito-controls.html#cognito-2" - path: /ce/ca/aws/cognito/identity-pool-unauthenticated-identities/prod.logic.yaml md5Hash: 64179898E57D5DC09922269AC7D81647 content: | --- inputType: "CA10A1__CaAwsCognitoIdentityPool__c" importExtracts: - file: "/types/CA10A1__CaAwsCognitoIdentityPool__c/object.extracts.yaml" testData: - file: "test-data.json" conditions: - status: "INCOMPLIANT" currentStateMessage: "The Cognito identity pool allows unauthenticated identities." remediationMessage: "Disable unauthenticated identities for the Cognito identity pool." check: IS_EQUAL: left: EXTRACT: "CA10A1__allowUnauthenticatedIdentities__c" right: TEXT: "true" - status: "COMPLIANT" currentStateMessage: "The Cognito identity pool does not allow unauthenticated identities." check: IS_EQUAL: left: EXTRACT: "CA10A1__allowUnauthenticatedIdentities__c" right: TEXT: "false" otherwise: status: "UNDETERMINED" currentStateMessage: "Unexpected value was found in the Cognito identity pool unauthenticated identities setting." - path: /ce/ca/aws/cognito/identity-pool-unauthenticated-identities/test-data.json md5Hash: A33E2E5D005F3FDCDEDE98E3AB3036BD content: | [ { "expectedResult": { "status": "DISAPPEARED", "conditionIndex": "99", "conditionText": "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": "2026-04-15T12:00:00Z", "CA10A1__allowUnauthenticatedIdentities__c": "false", "Id": "test1" }, { "expectedResult": { "status": "INCOMPLIANT", "conditionIndex": "199", "conditionText": "extract('CA10A1__allowUnauthenticatedIdentities__c') == 'true'", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": null, "CA10A1__allowUnauthenticatedIdentities__c": "true", "Id": "test2" }, { "expectedResult": { "status": "COMPLIANT", "conditionIndex": "299", "conditionText": "extract('CA10A1__allowUnauthenticatedIdentities__c') == 'false'", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": null, "CA10A1__allowUnauthenticatedIdentities__c": "false", "Id": "test3" }, { "expectedResult": { "status": "UNDETERMINED", "conditionIndex": "300", "conditionText": "otherwise", "runtimeError": null }, "context": { "snapshotTime": "2026-04-16T12:00:00Z" }, "CA10A1__disappearanceTime__c": null, "CA10A1__allowUnauthenticatedIdentities__c": "unexpected", "Id": "test4" } ] - path: /types/CA10A1__CaAwsCognitoIdentityPool__c/object.extracts.yaml md5Hash: 40CDE354F90428C792575A718C58F2CA content: | --- extracts: # Values: true | false. Not nullable. Retrieved via cognito-identity:DescribeIdentityPool - name: CA10A1__allowUnauthenticatedIdentities__c value: FIELD: path: CA10A1__allowUnauthenticatedIdentities__c undeterminedIf: isEmpty: "Allow Unauthenticated Identities should not be empty. Possibly corrupted data." script: |- CREATE TEMP FUNCTION mock_ExpectedResult() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "Id" : "test1", "expectedResult" : { "status" : "DISAPPEARED", "conditionIndex" : "99", "conditionText" : "isDisappeared(CA10A1__disappearanceTime__c)", "runtimeError" : null } }, { "Id" : "test2", "expectedResult" : { "status" : "INCOMPLIANT", "conditionIndex" : "199", "conditionText" : "extract('CA10A1__allowUnauthenticatedIdentities__c') == 'true'", "runtimeError" : null } }, { "Id" : "test3", "expectedResult" : { "status" : "COMPLIANT", "conditionIndex" : "299", "conditionText" : "extract('CA10A1__allowUnauthenticatedIdentities__c') == 'false'", "runtimeError" : null } }, { "Id" : "test4", "expectedResult" : { "status" : "UNDETERMINED", "conditionIndex" : "300", "conditionText" : "otherwise", "runtimeError" : null } } ]; """; CREATE TEMP FUNCTION mock_CA10A1__CaAwsCognitoIdentityPool__c() RETURNS ARRAY >> DETERMINISTIC LANGUAGE js AS r""" return [ { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__disappearanceTime__c" : new Date("2026-04-15T12:00:00Z"), "CA10A1__allowUnauthenticatedIdentities__c" : "false", "Id" : "test1" }, { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__allowUnauthenticatedIdentities__c" : "true", "Id" : "test2" }, { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__allowUnauthenticatedIdentities__c" : "false", "Id" : "test3" }, { "context" : { "snapshotTime" : new Date("2026-04-16T12:00:00Z") }, "CA10A1__allowUnauthenticatedIdentities__c" : "unexpected", "Id" : "test4" } ]; """; CREATE TEMP FUNCTION process_CA10A1__CaAwsCognitoIdentityPool__c( obj STRUCT< CA10A1__disappearanceTime__c TIMESTAMP, CA10A1__allowUnauthenticatedIdentities__c STRING, Id STRING >, snapshotTime TIMESTAMP ) RETURNS STRUCT DETERMINISTIC LANGUAGE js AS r""" var TextLib = new function () { this.normalize = function(arg) { return arg == null ? '' : arg.replace(/\s+/g, ' ').trim().toLowerCase(); }; this.isEmpty = function(arg) { return this.normalize(arg) == ''; }; this.isNotEmpty = function(arg) { return this.normalize(arg) != ''; }; this.equal = function(left, right) { return this.normalize(left) == this.normalize(right); }; this.notEqual = function(left, right) { return this.normalize(left) != this.normalize(right); }; this.startsWith = function(arg, substring) { return this.normalize(arg).startsWith(this.normalize(substring)); }; this.endsWith = function(arg, substring) { return this.normalize(arg).endsWith(this.normalize(substring)); }; this.contains = function(arg, substring) { return this.normalize(arg).includes(this.normalize(substring)); }; this.containsAll = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.every(sub => normalizedArg.includes(this.normalize(sub))); }; this.containsAny = function(arg, substrings) { if (substrings == null || substrings.length === 0) return false; let normalizedArg = this.normalize(arg); return substrings.some(sub => normalizedArg.includes(this.normalize(sub))); }; }(); var references1 = []; // condition[0], conditionIndex:[0..99] references1.push('Deleted From AWS [CA10A1__disappearanceTime__c]: ' + obj.CA10A1__disappearanceTime__c); if (obj.CA10A1__disappearanceTime__c != null) { return {status: 'DISAPPEARED', conditionIndex: 99, conditionText: "isDisappeared(CA10A1__disappearanceTime__c)", currentStateMessage: "Object is deleted in the source", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } // condition[1], conditionIndex:[100..199] function fieldChecked4() { if (TextLib.isEmpty(obj.CA10A1__allowUnauthenticatedIdentities__c)) { throw new Error("UNDETERMINED condition:101", {cause: {status: 'UNDETERMINED', conditionIndex: 101, conditionText: "CA10A1__allowUnauthenticatedIdentities__c.isEmpty()", currentStateMessage: "Allow Unauthenticated Identities should not be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__allowUnauthenticatedIdentities__c; } function extract3() { if (!this.out) { this.out = fieldChecked4(); } return this.out; }; references1.push('Allow Unauthenticated Identities [obj.CA10A1__allowUnauthenticatedIdentities__c]: ' + obj.CA10A1__allowUnauthenticatedIdentities__c); try { if (TextLib.equal(extract3.call(extract3), 'true')) { return {status: 'INCOMPLIANT', conditionIndex: 199, conditionText: "extract('CA10A1__allowUnauthenticatedIdentities__c') == 'true'", currentStateMessage: "The Cognito identity pool allows unauthenticated identities.", currentStateReferences: references1.join('\n'), remediation: "Disable unauthenticated identities for the Cognito identity pool.", runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } // condition[2], conditionIndex:[200..299] function fieldChecked7() { if (TextLib.isEmpty(obj.CA10A1__allowUnauthenticatedIdentities__c)) { throw new Error("UNDETERMINED condition:201", {cause: {status: 'UNDETERMINED', conditionIndex: 201, conditionText: "CA10A1__allowUnauthenticatedIdentities__c.isEmpty()", currentStateMessage: "Allow Unauthenticated Identities should not be empty. Possibly corrupted data.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}}); } return obj.CA10A1__allowUnauthenticatedIdentities__c; } function extract6() { if (!this.out) { this.out = fieldChecked7(); } return this.out; }; try { if (TextLib.equal(extract6.call(extract6), 'false')) { return {status: 'COMPLIANT', conditionIndex: 299, conditionText: "extract('CA10A1__allowUnauthenticatedIdentities__c') == 'false'", currentStateMessage: "The Cognito identity pool does not allow unauthenticated identities.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; } } catch (err) { if (err.cause && err.cause.status) { return err.cause; } else { throw err; } } return {status: 'UNDETERMINED', conditionIndex: 300, conditionText: "otherwise", currentStateMessage: "Unexpected value was found in the Cognito identity pool unauthenticated identities setting.", currentStateReferences: references1.join('\n'), remediation: null, runtimeError: null}; """; SELECT expectedResult.Id as Id, IF ( IFNULL(expectedResult.expectedResult.status, '') = IFNULL(sObject.result.status, '') AND IFNULL(expectedResult.expectedResult.conditionIndex, -1) = IFNULL(sObject.result.conditionIndex, -1) AND IFNULL(expectedResult.expectedResult.conditionText, '') = IFNULL(sObject.result.conditionText, '') AND IFNULL(expectedResult.expectedResult.runtimeError, '') = IFNULL(sObject.result.runtimeError, ''), "MATCH", "FAIL" ) as match, expectedResult.expectedResult.status as expectedStatus, sObject.result.status as actualStatus, expectedResult.expectedResult.conditionIndex as expectedConditionIndex, sObject.result.conditionIndex as actualConditionIndex, expectedResult.expectedResult.conditionText as expectedConditionText, sObject.result.conditionText as actualConditionText, expectedResult.expectedResult.runtimeError as expectedRuntimeError, sObject.result.runtimeError as actualRuntimeError FROM UNNEST(mock_ExpectedResult()) expectedResult LEFT JOIN ( SELECT sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__allowUnauthenticatedIdentities__c AS CA10A1__allowUnauthenticatedIdentities__c, sObject.Id AS Id, process_CA10A1__CaAwsCognitoIdentityPool__c( STRUCT( sObject.CA10A1__disappearanceTime__c AS CA10A1__disappearanceTime__c, sObject.CA10A1__allowUnauthenticatedIdentities__c AS CA10A1__allowUnauthenticatedIdentities__c, sObject.Id AS Id ), sObject.context.snapshotTime ) as result FROM UNNEST(mock_CA10A1__CaAwsCognitoIdentityPool__c()) AS sObject ) sObject ON sObject.Id = expectedResult.Id;