Skip to content

feat(query): implemented query Beta - Key Vault Purge Protection Is Enabled for terraform/azure and fixed remediation problems#7838

Merged
cx-artur-ribeiro merged 20 commits into
masterfrom
AST-116653
Dec 12, 2025
Merged

feat(query): implemented query Beta - Key Vault Purge Protection Is Enabled for terraform/azure and fixed remediation problems#7838
cx-artur-ribeiro merged 20 commits into
masterfrom
AST-116653

Conversation

@cx-ricardo-jesus

Copy link
Copy Markdown
Contributor

Reason for Proposed Changes

  • Currently, there is no query for Terraform/Azure that checks if the purge protection is enabled for an Azure Key Vault.
  • Quoting CIS_Microsoft_Azure_Foundations_Benchmark_v5.0.0: "`Key vaults contain object keys, secrets, and certificates. Deletion of a key vault can cause immediate data loss or loss of security functions (authentication, validation, verification, non-repudiation, etc.) supported by the key vault objects. It is recommended that the key vault be made recoverable by enabling the "purge protection" function.
  • Currently, when running the remediate KICS command, an error occurs due to the variable ActualRemediationDoneNumber not being incremented for Beta queries(with the flag experimental set to true).

Proposed Changes

  • Implemented the query that returns a positive result when the field purge_protection_enabled is not defined or not set to true.
  • Regarding the metadata information, I took inspiration from a similar query implemented for the AzureResourceManager platform, which covers an analogous resource for AzureResourceManager, and also checks for the soft delete part.
  • Taking into account the information stated on the previous point, I think the most appropriate CWE is 530 and set the severity to High, taking into account that the similar query mentioned above, also has a HIGH severity.
  • Regarding the remediation fix, basically, changed the Query struct on the remediation.go, to also store a boolean variable called experimental, which is extracted from the results file.
  • Also, added the boolean Experimental variable on the Remediation structure.
  • Basically, now, the remediationSet, which stores a set of Remediation structs, will also store the Experimental bool, which will be true or false, taking into account the value present on the experimental field on the results file.
  • After these changes, the Beta queries will be capable of running the remediations, but, as expected, will not present any result.

I submit this contribution under the Apache-2.0 license.

@cx-ricardo-jesus cx-ricardo-jesus requested a review from a team as a code owner November 10, 2025 11:39
@github-actions github-actions Bot added feature New feature query New query feature terraform Terraform query azure PR related with Azure Cloud labels Nov 10, 2025
@github-actions

github-actions Bot commented Nov 10, 2025

Copy link
Copy Markdown
Contributor

kics-logo

KICS version: v2.1.17

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

@gitguardian

gitguardian Bot commented Nov 10, 2025

Copy link
Copy Markdown

⚠️ GitGuardian has uncovered 1 secret following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secret in your pull request
GitGuardian id GitGuardian status Secret Commit Filename
21271469 Triggered Generic Password b07d6a4 assets/queries/terraform/azure/unrestricted_sql_server_access/test/positive3.tf View secret
🛠 Guidelines to remediate hardcoded secrets
  1. Understand the implications of revoking this secret by investigating where it is used in your code.
  2. Replace and store your secret safely. Learn here the best practices.
  3. Revoke and rotate this secret.
  4. If possible, rewrite git history. Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data.

To avoid such incidents in the future consider


🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@cx-artur-ribeiro cx-artur-ribeiro merged commit 12a2ea9 into master Dec 12, 2025
29 checks passed
@cx-artur-ribeiro cx-artur-ribeiro deleted the AST-116653 branch December 12, 2025 17:45
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.

3 participants