feat(terraform): add CKV_AWS_394 for unconstrained aws_availability_zones data source - #7658
Open
madhavvishnubhatta wants to merge 1 commit into
Conversation
…ones data source Add a data-block check that fails an aws_availability_zones data source unless it pins zone identity via exclude_names, exclude_zone_ids, or an identity-based filter (zone-name / zone-id). Attribute-only constraints such as state or opt-in-status, and grouping filters like group-name, do not prevent a newly-added AZ from appearing and therefore fail. This mirrors the WhoAMI check (CKV_AWS_386), which flags an under-constrained aws_ami data source, and targets the root cause rather than downstream count/for_each usage. Users with a verified downstream mitigation can suppress per-block via
madhavvishnubhatta
requested a deployment
to
scan-security
August 24, 2026 15:55 — with
GitHub Actions
Waiting
madhavvishnubhatta
marked this pull request as draft
August 24, 2026 15:55
madhavvishnubhatta
marked this pull request as ready for review
August 24, 2026 16:01
madhavvishnubhatta
marked this pull request as draft
August 24, 2026 16:02
madhavvishnubhatta
marked this pull request as ready for review
August 25, 2026 09:18
Contributor
|
Hello @madhavvishnubhatta , thank you for the contribution. Please pull latest dev and push it so we can re-run the tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
Description
Adds a new check, CKV_AWS_394, that flags a Terraform
aws_availability_zonesdata source when it does not constrain which zones are returned. An unconstrained data source (e.g.data "aws_availability_zones" "available" {}) returns every AZ in the region, so configuration that relied on a fixed AZ count silently changes behavior when AWS adds a new AZ to the region — with no code change on the user's side.This is the same class of risk as the existing WhoAMI check (CKV_AWS_386), which flags an under-constrained
aws_amidata source, so there is precedent for scanningdatablocks this way. The check targets the root cause (the unconstrained data source) rather than downstreamcount/for_eachusage.Fixes #7657
New/Edited policies
Description
The check fails an
aws_availability_zonesdata block unless it pins zoneidentity. Identity-pinning arguments are:
exclude_namesexclude_zone_idsfilteronzone-nameorzone-idArguments that constrain zone attributes rather than identity do NOT prevent
a newly-added zone from appearing and therefore do NOT satisfy the check on
their own:
state,all_availability_zones, afilteronopt-in-status,and grouping filters such as
group-name/group-long-name(a new AZ joinsthe existing group and still appears).
Docs:
Fix
Constrain the data source so its result set is deterministic, e.g.:
or filter on zone identity:
Users with a verified downstream mitigation (e.g. a length-guarded
count/for_each) can suppress per-block:Checklist: