Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

@cx-andre-pereira cx-andre-pereira commented Nov 7, 2025

Reason for Proposed Changes

  • Currently there is no query to ensure that resources of type "azurerm_storage_account" configure a value of 7 to 365 on their "blob_properties.container_delete_retention_policy.days" field.

  • Quoting CIS_Microsoft_Azure_Foundations_Benchmark_v5.0.0 page 489: "Containers can be deleted incorrectly. An attacker or malicious user may do this deliberately in order to cause disruption. Deleting a container results in immediate data loss. Enabling this configuration for Azure storage accounts ensures that even if containers are deleted from the storage account, the containers are recoverable for a specific period of time, which is defined in the "Retention policies," ranging from 7 to 365 days."

  • Through the Terraform documentation for the resource we can see a "container_delete_retention_policy" block left empty will assume the default value of 7 for the missing "days" field. With this all we have to do is ensure the "delete_retention_policy" block is defined and that the value associated with the "days" field, if set, is higher than 6.

Proposed Changes

  • Implemented the missing query.

  • The query will flag any "azurerm_storage_account" resource that does not set the "blob_properties" block, or does set it but does not set a "container_delete_retention_policy" block within. Additionally it will flag if the "days" field is set to a value lower than 6.

  • Note that a check to ensure the days field is "valid" as in between 1 and 365 was not done since those would be found in the "terraform plan" stage. (was tested)

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions bot added feature New feature query New query feature labels Nov 7, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Nov 7, 2025

kics-logo

KICS version: v2.1.13

Category Results
CRITICAL CRITICAL 0
HIGH HIGH 0
MEDIUM MEDIUM 0
LOW LOW 0
INFO INFO 0
TRACE TRACE 0
TOTAL TOTAL 0
Metric Values
Files scanned placeholder 1
Files parsed placeholder 1
Files failed to scan placeholder 0
Total executed queries placeholder 47
Queries failed to execute placeholder 0
Execution time placeholder 0

@github-actions github-actions bot added terraform Terraform query azure PR related with Azure Cloud labels Nov 7, 2025
@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review November 7, 2025 14:55
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner November 7, 2025 14:55
Copy link
Contributor

@cx-eduardo-semanas cx-eduardo-semanas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, great job

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

azure PR related with Azure Cloud feature New feature query New query feature terraform Terraform query

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants