Skip to content

feat: add rule AZ-KV-006 - Key Vault using legacy access policies instead of RBAC - #235

Merged
Vishnu2707 merged 2 commits into
openshield-org:devfrom
dipeshrayg:feat/az-kv-006
Aug 8, 2026
Merged

feat: add rule AZ-KV-006 - Key Vault using legacy access policies instead of RBAC#235
Vishnu2707 merged 2 commits into
openshield-org:devfrom
dipeshrayg:feat/az-kv-006

Conversation

@dipeshrayg

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds scan rule AZ-KV-006, which flags Azure Key Vaults still authorizing access through legacy vault access policies instead of Azure RBAC.

Type of change

  • New scan rule
  • Remediation playbook
  • Compliance mapping

Rule details

  • Rule ID: AZ-KV-006
  • Severity: MEDIUM
  • Category: Key Vault
  • Frameworks mapped: CIS (see note below) / NIST / ISO 27001 / SOC 2

Testing

  • Tested against a real Azure free trial subscription — not done; I don't currently have one provisioned. Happy to do this before merge if required.
  • Returns correct JSON output — verified via tests/test_rules_keyvault.py (compliant, non-compliant, and missing-property cases, mocked AzureClient), 18/18 passing locally
  • All seven CI checks pass — unverified locally (this sandbox is missing several project dependencies, e.g. the azure SDK packages, unrelated to this change), but tests/test_cis_benchmark_mapping.py (duplicate-control-id and rule/mapping-agreement checks) passes for this rule specifically
  • No hardcoded credentials or secrets

Related issue

Closes #234

Note on the CIS mapping

The official CIS Azure Foundations Benchmark control for "Enable Role Based Access Control for Azure Key Vault" is 8.6. In this repo, 8.6 is already assigned to AZ-KV-004 (purge protection) — an unrelated check, and looks like a pre-existing mapping error. I didn't want to unilaterally reassign another rule's control ID in this PR, so AZ-KV-006 is mapped to TBD-KV-006 for now, following the same TBD-* placeholder convention already used elsewhere in cis_azure_benchmark.json (e.g. TBD-IDN-010). Flagged in issue #234 for a maintainer decision.

Checklist

  • Every commit includes a DCO Signed-off-by trailer (git commit -s)
  • My code follows the rule template in CONTRIBUTING.md
  • I added or updated the matching CLI playbook
  • I added or updated all four compliance framework mappings
  • I have not committed any real Azure credentials
  • My branch name follows the convention: feat/description

…tead of RBAC

Adds a scan rule that flags Key Vaults where enable_rbac_authorization
is false or unset, i.e. still relying on legacy vault access policies
instead of Azure RBAC for data-plane authorization.

Includes a remediation playbook, compliant/non-compliant/missing-property
test cases, and compliance framework mappings (CIS, NIST CSF, ISO27001,
SOC2). The CIS mapping is left as TBD-KV-006 pending maintainer input:
the real CIS 8.6 control for this check is already assigned to
AZ-KV-004 in this repo, a pre-existing mismatch this PR doesn't resolve
unilaterally.

Closes openshield-org#234

Signed-off-by: Dipesh Ray <dipesh.ray.g@gmail.com>
@TFT444

TFT444 commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

@dipeshrayg Thanks for working on AZ-KV-006. The rule and test coverage look good, but the PR is not ready to merge yet:

  • The PR targets main instead of dev. This has pulled 100 historical commits and 74 unrelated files into the PR.
  • GitHub currently reports merge conflicts. Please retarget the PR to dev and resolve them.
  • In the playbook, use ${1:-} and ${2:-} so missing arguments show the usage message instead of failing because of set -u.
  • Display the RBAC migration warning before changing the vault. Existing role assignments must be prepared first to prevent loss of access.
  • Please confirm the TBD-KV-006 CIS mapping with a maintainer.
  • Semgrep passed, but the complete CI suite has not run. Please ensure all required checks pass after fixing the branch.

Once these points are addressed, we can review it again.

@dipeshrayg
dipeshrayg changed the base branch from main to dev August 8, 2026 08:57
- Use ${1:-} / ${2:-} for RESOURCE_GROUP and VAULT_NAME so missing
  arguments fall through to the usage message instead of aborting on
  the set -u unbound-variable check.
- Move the RBAC migration warning before the az keyvault update call,
  so it's seen before the vault is changed, not after.

Addresses review on openshield-org#235.

Signed-off-by: Dipesh Ray <dipesh.ray.g@gmail.com>
@TFT444 TFT444 assigned TFT444 and dipeshrayg and unassigned TFT444 Aug 8, 2026

@Vishnu2707 Vishnu2707 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we don't check authorization model anywhere else in the KV rules. Code and tests look good to me, good job @dipeshrayg . Only thing pending on our end is sorting out the CIS 8.6 collision with AZ-KV-004, we'll get that resolved and update the mapping. Approving this for now.

@TFT444 - can u have a look at the collision.

@Vishnu2707
Vishnu2707 merged commit f1a7e45 into openshield-org:dev Aug 8, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(scanner): add rule AZ-KV-006 — Key Vault using legacy access policies instead of Azure RBAC

3 participants