feat(oci): add identity_storage_service_level_admins_scoped check for CIS 3.1 1.15 compliance#10568
feat(oci): add identity_storage_service_level_admins_scoped check for CIS 3.1 1.15 compliance#10568rchotacode wants to merge 11 commits intoprowler-cloud:masterfrom
identity_storage_service_level_admins_scoped check for CIS 3.1 1.15 compliance#10568Conversation
|
✅ Conflict Markers Resolved All conflict markers have been successfully resolved in this pull request. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #10568 +/- ##
===========================================
- Coverage 93.52% 59.41% -34.11%
===========================================
Files 225 88 -137
Lines 31579 2910 -28669
===========================================
- Hits 29534 1729 -27805
+ Misses 2045 1181 -864
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
...identity_storage_service_level_admins_scoped/identity_storage_service_level_admins_scoped.py
Fixed
Show fixed
Hide fixed
| f"MANAGE {global_storage_policy}" in statement_upper | ||
| for global_storage_policy in storage_policies | ||
| ): | ||
| if "WHERE" not in statement_upper: |
There was a problem hiding this comment.
This logic is still too permissive for CIS 3.1 control 1.15.
The control does not require any WHERE clause; it requires a condition that excludes delete access for the storage resource being managed. Right now a statement such as where request.region="iad" or where target.bucket.name="x" would pass, even though it still allows deletion.
Please update the check so it only treats a statement as compliant when it explicitly excludes the relevant delete permission for that resource, for example request.permission!='VOLUME_DELETE', request.permission!='FILE_SYSTEM_DELETE', request.permission!='OBJECT_DELETE', etc. This is the core requirement of CIS 1.15: service-level admins may manage the service, but they must not be able to delete the resources they manage.
There was a problem hiding this comment.
I originally implemented this behavior, but looking at the CIS 1.15 examples it seems service level admins refer to unrestricted manage access to storage services. Other CIS benchmarks also seem to flag it as such. I would think that target.bucket.name="x" would be a resource level of control, not a service.
These are the example policies adjusted to fit within the control within its definition document:
Example policies for global/tenant level for block volume service-administrators:
Allow group VolumeUsers to manage volumes in tenancy where request.permission!='VOLUME_DELETE'
Allow group VolumeUsers to manage volume-backups in tenancy where request.permission!='VOLUME_BACKUP_DELETE
Example policies for global/tenant level for file storage system service-administrators:
Allow group FileUsers to manage file-systems in tenancy where request.permission!='FILE_SYSTEM_DELETE'
Allow group FileUsers to manage mount-targets in tenancy where request.permission!='MOUNT_TARGET_DELETE'
Allow group FileUsers to manage export-sets in tenancy where request.permission!='EXPORT_SET_DELETE'
Example policies for global/tenant level for object storage system service-administrators:
Allow group BucketUsers to manage objects in tenancy where request.permission!='OBJECT_DELETE'
Allow group BucketUsers to manage buckets in tenancy where request.permission!='BUCKET_DELETE'
Each of these allows manage for a file service storage, but doesn't restrict the permissions at all without the request.permission!='X_DELETE'. In addition, the reference here https://docs.oracle.com/en/solutions/oci-best-practices/protect-data-rest1.html#GUID-EBE9212C-78B0-4795-9FB5-59DB0E91E106 linked in the control says that the permissions should be give "to only the users who need these privileges," which implies that some users should still be able to have delete permissions. I interpreted this as meaning that the CIS benchmark was to limit unrestricted delete permissions given to admins over all storage services.
| has_violation = True | ||
| offending_statements.append(statement) | ||
| break | ||
| if "MANAGE ALL-RESOURCES" in statement_upper: |
There was a problem hiding this comment.
I would also revisit the manage all-resources handling here.
For CIS 1.15, broad statements should not pass just because they contain a WHERE. The implementation should only pass when it can prove that delete is excluded for the storage resources covered by the statement. Otherwise this can create false PASS results for policies that remain non-compliant with the benchmark.
...identity_storage_service_level_admins_scoped/identity_storage_service_level_admins_scoped.py
Outdated
Show resolved
Hide resolved
| ], | ||
| "Remediation": { | ||
| "Code": { | ||
| "CLI": "oci iam policy update --policy-id <policy-ocid> --statements '[\"Allow group <GroupName> to manage objects where request.permission!='OBJECT_DELETE'\"]'", |
There was a problem hiding this comment.
Please align the metadata remediation examples with the CIS 1.15 wording and examples.
A couple of things to fix here:
- the examples should be framed around excluding delete permissions for the managed storage resource
request.permissionshould be used consistently- the Terraform example currently uses
request.PERMISSIONS, which does not match the benchmark examples - if possible, include examples that mirror the control more closely for the different storage resources (
VOLUME_DELETE,FILE_SYSTEM_DELETE,OBJECT_DELETE, etc.), not just a single generic example
Since this metadata is what users will read for remediation, it should map directly to the benchmark language.
There was a problem hiding this comment.
This new check still needs real unit test coverage.
At the moment the test file is empty, so we are not validating the CIS-specific behavior of the parser. Please add tests for at least:
- FAIL:
manage <storage-resource>with no delete exclusion - PASS:
manage <storage-resource>with the correctrequest.permission!='*_DELETE'condition - FAIL: a statement with an unrelated
WHEREclause that does not exclude delete - inactive policies
Tenant Admin Policy
This is especially important here because the correctness of the check depends on parsing OCI policy statements exactly as required by CIS 1.15.
Context
CIS 3.1 include 1.15 which requires service level storage admins to be scoped to remove deletion permissions.
Feat #10567
Description
Policies such as
manage file-systems resourcesenable deletion at the service level. According to OCI CIS 3.1 1.15, these policies should not be service level or have the conditionwhere request.permission!='*SERVICE*_DELETE'.Steps to review
Running prowler oraclecloud --check identity_storage_service_level_admins_scoped
Checklist
Community Checklist
SDK/CLI
UI
API
License
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.