Add enterprise AKS and workload security controls - #293
Conversation
Signed-off-by: ritiksah141 <ritiksah141@gmail.com>
Dependency Review✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.OpenSSF Scorecard
Scanned Files
|
There was a problem hiding this comment.
Good structure and solid failure-path coverage. Two blockers and two nits before merge.
1. policy_required set too broad (blocker)
scanner/rules/_aks_enterprise_common.py:197
Eight controls (privileged, host_network, host_pid, host_ipc, host_path, secret_protection, network_policy_namespaces, latest_image) return [] when OPENSHIELD_AKS_SECURITY_POLICY is not set, even though none of them need org-specific values. Each already handles policy=None safely downstream. Only four controls genuinely need a configured policy: api_restrictions, cluster_admin, untrusted_registry, and mutable_image. Remove the other eight from the set so workload rules run without a policy file.
2. Docker Hub short-form images cause false-positive AZ-AKS-019 findings (blocker)
scanner/rules/_aks_enterprise_common.py:1581
Images without a registry hostname (nginx, redis:7) fail the trusted-registry check even when docker.io/ is in trusted_registry_prefixes, because nginx.startswith(docker.io/) is False. Normalize short-form names before the prefix match.
3. Approved IP list rebuilt per cluster (efficiency)
scanner/rules/_aks_enterprise_common.py:1400
approved = [ipaddress.ip_network(item) for item in policy.approved_authorized_ip_ranges] is inside the per-cluster loop. Hoist it above for evidence in evidence_items.
4. Stale rule count in docs/learn/index.html (trivial)
Heading says 95 Azure security rules but the paragraph body still reads 80 dynamic rules.
Signed-off-by: ritiksah141 <ritiksah141@gmail.com>
|
Addressed the requested code changes and added regression coverage. I left the docs/learn/index.html rule count unchanged because the assignee handling docs/learn will update it. |
cool make sence now its good to go for me approving it |
There was a problem hiding this comment.
Thanks for taking on this AKS security pack. There is a lot of good structure here, especially around preserving unknown and partial evidence. Before we merge it, I need us to close three gaps that could produce incorrect results in a real multi-cluster environment:
-
Cluster evidence can be attached to the wrong AKS resource. The collector selects kubeconfig contexts using only
cluster.name. AKS names are scoped to a resource group, so two clusters in one subscription can share a name, and kubeconfig context names can also be customized. In that situation, both ARM resources may be evaluated through the same Kubernetes context. Please introduce an explicit, unambiguous resource-ID-to-context mapping, validate it, and treat missing or ambiguous mappings as UNKNOWN. Add a regression test with duplicate cluster names in different resource groups. -
The cluster-admin allowlist loses the ServiceAccount namespace. ServiceAccounts are namespace-scoped, but AZ-AKS-018 compares only
Kind:name. AllowingServiceAccount:builderwould therefore allow abuilderaccount from every namespace. Please use a namespace-aware identity such asServiceAccount:<namespace>:<name>, reject ambiguous policy entries, and test two same-named ServiceAccounts in different namespaces. Group and User identities can keep the appropriate non-namespaced form. -
Projected Secret volumes are not collected.
_workload()checks ordinary Secret volumes and environment references, but missesvolume.projected.sources[].secret.name. A workload using only a projected Secret can therefore be treated as not applicable when KMS is disabled. Please collect those references and add a regression test.
The GitHub checks are green. My focused local run could not collect because this checkout is missing azure.mgmt.authorization; that environment limitation is separate from the production evidence cases above.
Please let me know once these cases are covered and I will re-review promptly.
Signed-off-by: ritiksah141 <ritiksah141@gmail.com>
|
@m-khan-97, Addressed the tenant-scale review blockers in 9d6acb2. AKS contexts now use a validated resource-ID mapping, ServiceAccount allowlists are namespace-scoped, and projected Secret volumes are collected. Added regression coverage for each case. All local tests and vulnerability checks pass. |
Summary
Implements the complete enterprise AKS and container workload security backlog from issue #255 with fifteen evidence-rich controls covering API exposure, Kubernetes network policy, Defender for Containers, secret protection, privileged and host access, cluster administration, and image supply chain policy.
What changed
AZ-AKS-007to require a private API server or organization-approved authorized IP ranges.AZ-AKS-008to require Azure, Calico, or Cilium network policy enforcement.AZ-AKS-009to detect eligible namespaces without a NetworkPolicy.AZ-AKS-010to require Microsoft Defender for Containers.AZ-AKS-011to detect native Kubernetes Secret references without Azure Key Vault KMS protection.AZ-AKS-012to require automatic rotation when the Key Vault Secrets Store CSI provider is enabled.AZ-AKS-013throughAZ-AKS-017as separate controls for privileged containers, hostNetwork, hostPID, hostIPC, and hostPath volumes.AZ-AKS-018to detect cluster-admin bindings outside the approved subject allowlist.AZ-AKS-019throughAZ-AKS-021as separate controls for untrusted registries, latest or implicit latest tags, and mutable non-digest image references.OPENSHIELD_AKS_SECURITY_POLICYand Kubernetes access throughOPENSHIELD_AKS_KUBECONFIG.N/A-*CIS decisions where no direct benchmark mapping exists./website.False-finding safeguards
Verification
Type of change
Testing
Checklist
Signed-off-bytrailerAZ-AKS-007throughAZ-AKS-021TBD-*framework mappings were introduceddevRelated issue
Closes #255
Files to review
scanner/aks_security.pyandscanner/azure_client.py- failure-aware ARM, Defender, and Kubernetes evidence collection.scanner/rules/_aks_enterprise_common.pyandscanner/rules/az_aks_007.pythroughscanner/rules/az_aks_021.py- strict policy evaluation and the fifteen independent controls.tests/test_aks_security_collector.py,tests/test_rules_aks_enterprise.py, andtests/test_azure_client_aks.py- positive, secure, empty, malformed, partial, unsupported, and failure coverage.playbooks/cli/fix_az_aks_007.shthroughplaybooks/cli/fix_az_aks_021.sh- individual review-gated remediation entry points.compliance/frameworks/*.json- verified CIS, NIST CSF, ISO 27001, and SOC 2 mappings.config/aks-security-policy.example.json,docs/aks-security-rules.md,docs/rules-reference.md, andCHANGELOG.md- policy schema, behavior, permissions, limitations, and release documentation.