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

未关闭 适合新手
#199 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
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 小时
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

silverhack/monkey365 的其他 Issue

查看 silverhack/monkey365 的全部 Issue

相似的 Issue

更多 Cloud Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。