mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
fix(aws): exclude member accounts in IAM Root Credentials check (#5813)
This commit is contained in:
@@ -6,7 +6,10 @@ class iam_no_root_access_key(Check):
|
||||
def execute(self) -> Check_Report_AWS:
|
||||
findings = []
|
||||
# Check if the root credentials are managed by AWS Organizations
|
||||
if "RootCredentialsManagement" not in iam_client.organization_features:
|
||||
if (
|
||||
iam_client.organization_features is not None
|
||||
and "RootCredentialsManagement" not in iam_client.organization_features
|
||||
):
|
||||
for user in iam_client.credential_report:
|
||||
if user["user"] == "<root_account>":
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
|
||||
+3
-2
@@ -27,7 +27,8 @@
|
||||
"DependsOn": [],
|
||||
"RelatedTo": [
|
||||
"iam_root_hardware_mfa_enabled",
|
||||
"iam_root_mfa_enabled"
|
||||
"iam_root_mfa_enabled",
|
||||
"iam_no_root_access_key"
|
||||
],
|
||||
"Notes": ""
|
||||
"Notes": "This check skips findings for member accounts as they cannot execute the ListOrganizationsFeatures API call, which is restricted to the management account or delegated administrators."
|
||||
}
|
||||
|
||||
+1
@@ -11,6 +11,7 @@ class iam_root_credentials_management_enabled(Check):
|
||||
if (
|
||||
organizations_client.organization
|
||||
and organizations_client.organization.status == "ACTIVE"
|
||||
and iam_client.organization_features is not None
|
||||
):
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
report.region = iam_client.region
|
||||
|
||||
+4
-1
@@ -8,7 +8,10 @@ class iam_root_hardware_mfa_enabled(Check):
|
||||
# This check is only available in Commercial Partition
|
||||
if iam_client.audited_partition == "aws":
|
||||
# Check if the root credentials are managed by AWS Organizations
|
||||
if "RootCredentialsManagement" not in iam_client.organization_features:
|
||||
if (
|
||||
iam_client.organization_features is not None
|
||||
and "RootCredentialsManagement" not in iam_client.organization_features
|
||||
):
|
||||
if iam_client.account_summary:
|
||||
virtual_mfa = False
|
||||
report = Check_Report_AWS(self.metadata())
|
||||
|
||||
@@ -6,7 +6,10 @@ class iam_root_mfa_enabled(Check):
|
||||
def execute(self) -> Check_Report_AWS:
|
||||
findings = []
|
||||
# Check if the root credentials are managed by AWS Organizations
|
||||
if "RootCredentialsManagement" not in iam_client.organization_features:
|
||||
if (
|
||||
iam_client.organization_features is not None
|
||||
and "RootCredentialsManagement" not in iam_client.organization_features
|
||||
):
|
||||
if iam_client.credential_report:
|
||||
for user in iam_client.credential_report:
|
||||
if user["user"] == "<root_account>":
|
||||
|
||||
@@ -982,6 +982,21 @@ class IAM(AWSService):
|
||||
logger.warning(
|
||||
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
elif (
|
||||
error.response["Error"]["Code"]
|
||||
== "OrganizationNotInAllFeaturesModeException"
|
||||
):
|
||||
logger.warning(
|
||||
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
elif (
|
||||
error.response["Error"]["Code"]
|
||||
== "AccountNotManagementOrDelegatedAdministratorException"
|
||||
):
|
||||
logger.warning(
|
||||
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
)
|
||||
self.organization_features = None
|
||||
else:
|
||||
logger.error(
|
||||
f"{self.region} -- {error.__class__.__name__}[{error.__traceback__.tb_lineno}]: {error}"
|
||||
|
||||
Reference in New Issue
Block a user