Skip to content

route53_public_hosted_zones_cloudwatch_logging_enabled passes for every zone if there is one with enabled logging #7173

@xelaris

Description

@xelaris

Steps to Reproduce

  1. Create two hosted zones in Route53 (without query logging set up)
  2. Run prowler aws --checks route53_public_hosted_zones_cloudwatch_logging_enabled
  3. route53_public_hosted_zones_cloudwatch_logging_enabled fails for both zones
  4. Set up query logging for only one of the zones
  5. Run prowler aws --checks route53_public_hosted_zones_cloudwatch_logging_enabled

Expected behavior

route53_public_hosted_zones_cloudwatch_logging_enabled should pass for the zone with the logging configuration and fail for the zone without the logging configuration

Actual Result with Screenshots or Logs

route53_public_hosted_zones_cloudwatch_logging_enabled passes for both zones

How did you install Prowler?

From brew (brew install prowler)

Environment Resource

Workstation

OS used

MacOS

Prowler version

5.3.0

Pip version

25.0

Context

It seems the issue hides in _list_query_logging_configs in route53_service.py:

for hosted_zone in self.hosted_zones.values():
list_query_logging_configs_paginator = self.client.get_paginator(
"list_query_logging_configs"
)
for page in list_query_logging_configs_paginator.paginate():
for logging_config in page["QueryLoggingConfigs"]:
self.hosted_zones[hosted_zone.id].logging_config = (
LoggingConfig(
cloudwatch_log_group_arn=logging_config[
"CloudWatchLogsLogGroupArn"
]
)
)

The code reads like this:

for every hosted zone
  for every query logging config
    use the configuration as the query logging config for the hosted zone

I think it needs to be something like this:

for every hosted zone
  for every query logging config
    **if the HostedZoneId of the config matches the hosted zone**
      use the configuration as the query logging config for the hosted zone 

Metadata

Metadata

Labels

bugprovider/awsIssues/PRs related with the AWS providerseverity/mediumResults in some unexpected or undesired behavior.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions