Skip to content

Conversation

@cx-andre-pereira
Copy link
Contributor

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

Reason for Proposed Changes

Proposed Changes

New queries :

  • 1 Beta - VM Without Admin SSH Public Key Set

    • This query targets the "admin_ssh_key.public_key" field of the "azurerm_linux_virtual_machine" and "azurerm_linux_virtual_machine_scale_set" resources. It will flag if there isn't at least one public_key set inside a admin_ssh_key block. The query takes into account the scenario of the admin_ssh_key block(s) not declaring a public_key even though the field is technically required.

    • The legacy "azurerm_virtual_machine" has the "os_profile_linux_config.ssh_keys" field which seems analog to this but, since there is already a query to enforce "os_profile_linux_config.disable_password_authentication" to be set to true, consequently making the "ssh_keys" field required, i did not find this to be worth including in the query. (said query is the one fixed by this PR - "Azure Instance Using Basic Authentication")

  • 2 Beta - VM With Extension Operations Enabled

  • This query was found to be applicable to all 4 VM resources, but the target field has different names depending on the resource.

  • For "azurerm_windows_virtual_machine" and "azurerm_linux_virtual_machine" the target field is named "allow_extension_operations". For the other 2 "scale_set" resources the target field is "extension_operations_enabled".

  • We must ensure the field is explicitly set to false since enabling extension operations is a security liability; it can lead to processes executing with unnecessary administrative privileges on the vm.

  • Note that this query will likely become outdated relatively soon if a single naming convention is adopted for the 4 resources rather than keeping the 2 distinct field names.

  • 3 Beta - VM With Automatic Updates Disabled

    • This query is applicable only to windows based vm resources. It targets the "enable_automatic_updates" field and the "automatic_updates_enabled" field; the latter is the new name that replaces "enable_automatic_updates" for the "azurerm_windows_virtual_machine". This change was extremely recent as of writing (less than 2 months ago - last version to support old field was 4.48), the "azurerm_windows_virtual_machine_scale_set" still uses the "enable_automatic_updates" field but it wouldn't be surprising if it changed to the new naming scheme soon.

    • Both fields are supported by the implementation. Additionally if the scale-set resource goes through the change the query will still work regardless ensuring future proofing for the query.

    • NOTE - the query targets automatic "updates", not to be confused with the automatic "upgrade" which exists in all resources including legacy ones.

  • 4 Beta - Disk Encryption On Managed Disk Disabled

  • 5 Beta - Key Vault Without HSM Protection

    • This query targets the "key_type" field of "azurerm_key_vault_key" resources to ensure it is set to a value that sets up encryption dependent on a HSM for overall stronger cryptography.
  • 6 Beta - VM Without Encryption At Host

    • The sixth and final query applies to all 4 VM resources once again. For this one all resources set the exact same field: "encryption_at_host_enabled".

    • Although not explicitly stated it seems the default value for the field is false; with this the query ensures that the encryption_at_host_enabled field is set to true. Like other queries in this PR this is meant to improve encryption standards by ensuring all files are encrypted before they leave the physical host machine.

I submit this contribution under the Apache-2.0 license.

@github-actions github-actions bot added query New query feature terraform Terraform query azure PR related with Azure Cloud labels Nov 20, 2025
@github-actions
Copy link
Contributor

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

@cx-andre-pereira cx-andre-pereira marked this pull request as ready for review November 20, 2025 14:34
@cx-andre-pereira cx-andre-pereira requested a review from a team as a code owner November 20, 2025 14:34
@cx-andre-pereira cx-andre-pereira changed the title fix(query): fixes for "Azure Instance Using Basic Authentication" - terraform/azure feat(query): 6 new Beta queries and fixes for "Azure Instance Using Basic Authentication" - terraform/azure Nov 28, 2025
@github-actions github-actions bot added the feature New feature label Nov 28, 2025
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.

1 participant