[Bug]: Key Vault: "Ensure 'Purge protection' is set to 'Enabled'" never fails because the rule queries properties.enablePurgeProtection

オープン 初心者向け
#199 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
2/5
見積もり時間
1〜3時間
初心者へのやさしさ
78/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
azure, powershell
領域
cloud, security

調査の方向性

rules/findings/azure/keyvault/azure-keyvault-purge-protection-not-enabled.jsonを開き、その条件を復旧可能なKey Vaultルールと比較してください。New-MonkeyVaultObject.ps1が欠落値をどのように正規化するかを確認し、消去保護が無効なvaultに対してルールを実行してください。そのvaultが消去保護ルールに合格するのではなく、不合格になれば完了です。

索引モデルが issue の本文から書いたものです。

説明

bug status/needs-triage

What happened?
Every Key Vault without purge protection is reported as pass for azure_key_vault_purge_protection_disabled (rules/findings/azure/keyvault/azure-keyvault-purge-protection-not-enabled.json).

The rule condition is:

["properties.enablePurgeProtection", "eq", "false"]

properties holds the raw ARM properties of the vault. ARM only accepts true for enablePurgeProtection (Key Vault reference: "Enabling this functionality is irreversible - that is, the property does not accept false as its value"). A vault that never had purge protection enabled has no enablePurgeProtection value at all, and $null -eq $false is false, so the condition never matches.

New-MonkeyVaultObject.ps1 already normalises the value (line 75):

protection = [PSCustomObject]@{
    enablePurgeProtection = If($null -ne $InputObject.Properties.PsObject.Properties.Item('enablePurgeProtection')){$InputObject.Properties.enablePurgeProtection}Else{$false};

How to reproduce it

  1. Use a Key Vault created without purge protection. az keyvault show -n <vault> --query "{purge:properties.enablePurgeProtection, softDelete:properties.enableSoftDelete}" returns "purge": null, "softDelete": true.
  2. Run Invoke-Monkey365 -Instance Azure with the default ruleset.
  3. azure_key_vault_purge_protection_disabled is reported as pass.

Expected behavior
The rule fails for vaults without purge protection.

Suggested fix
Query the normalised value, as the "recoverable" rule already does:

["protection.enablePurgeProtection", "eq", "false"]

From where are you running Monkey365?

  • Resource: Docker container
  • OS: Linux (Ubuntu 24.04)
  • PowerShell Version: 7.6.9
  • Monkey365 Version: 1.0.5 (also 1.0.0, PowerShell Gallery)
  • Others: app-only authentication with access tokens

Additional context
Same pattern as the Key Vault RBAC issue (value read or queried at the wrong level), reported separately.

主要言語
PowerShell
スター
1.4k
フォーク
144
平均マージ
1日 21時間
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

silverhack/monkey365 のほかの issue

silverhack/monkey365 の issue をすべて見る

似ている issue

Cloud の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。