More Info:
Object Storage buckets containing critical logs or archives should have retention rules defined. Retention policies enforce Write Once Read Many (WORM) constraints, preventing object modification or deletion for regulatory complianceRisk Level
MediumAddress
Compliance, SecurityCompliance Standards
- APRA CPS 234 (Australia)
- BSI C5 (Germany)
- Brazil LGPD
- CCPA / CPRA (California)
- CIS Critical Security Controls v8
- CMMC 2.0
- CSA Cloud Controls Matrix v4
- DPDPA
- Digital Operational Resilience Act (EU)
- Essential 8
- HIPAA
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- Reserve Bank of India (RBI) Master Direction – Information Technology Framework
- SOC2
- SWIFT Customer Security Controls Framework
- Sarbanes-Oxley IT General Controls
- UK NCSC Cyber Assessment Framework
Triage and Remediation
- Remediation
Remediation
Using Console
Using Console
To remediate “OCI Storage Buckets Should Have Retention Rules Defined” using the OCI Console, you need to add a retention rule to each non-compliant Object Storage bucket.
Step-by-step remediation in OCI Console
-
Sign in to OCI Console
- Go to: https://cloud.oracle.com
- Log in with your tenancy and user credentials.
-
Navigate to Object Storage
- In the left-side Navigation menu, click Storage.
- Select Buckets.
-
Choose the correct compartment
- At the top of the Buckets page, open the Compartment selector.
- Select the compartment that contains the non-compliant bucket(s).
-
Open the bucket details
- From the list of buckets, click the name of the bucket that needs a retention rule.
-
Go to Retention Rules section
- In the bucket details page, scroll down to find Retention Rules.
- Click Add retention rule (or Create retention rule, wording may vary slightly by region/console version).
-
Configure the retention rule
- Name: Enter a clear, descriptive name (e.g.,
compliance-retention-365d). - Rule Type:
- Choose Time-bound (most common) or Indefinite as per your policy.
- Duration (if time-bound):
- Enter the number of days/years you must retain objects (e.g.,
365days).
- Enter the number of days/years you must retain objects (e.g.,
- Locked vs. Unlocked:
- If your compliance policy requires immutable retention, lock the rule once you’re sure (this prevents shortening or deleting it later).
- If you’re testing or unsure, leave it unlocked at first, but note that some monitoring policies may expect a locked rule.
- Name: Enter a clear, descriptive name (e.g.,
-
Create the rule
- Review the configuration.
- Click Create (or Save) to add the retention rule to the bucket.
-
Repeat for all non-compliant buckets
- Return to Buckets list.
- Repeat steps 4–7 for each bucket flagged by your OCI Security/Monitoring tool.
-
Verify remediation for monitoring
- After a short interval, re-run the Security posture / Cloud Guard / Configuration Assessment (depending on what you use).
- Confirm the finding “OCI Storage Buckets Should Have Retention Rules Defined” is cleared for the updated buckets.
Using CLI
Using CLI
Below are the concise, CLI-focused steps to ensure OCI Object Storage buckets have retention rules defined.
Save the value of
Note bucket names needing retention rules.
If output is empty → no retention rules defined.
Notes:
You should see the new rule with
This remediates the misconfiguration by ensuring all targeted buckets have at least one retention rule defined using OCI CLI.
0. Prerequisites
- OCI CLI installed and configured (
oci setup configdone) - Proper permissions: ability to manage Object Storage buckets/retention rules in the target compartments
1. Get your Object Storage namespace
data as NAMESPACE.2. List buckets (optionally filter by compartment)
3. (Optional) Check if a bucket already has a retention rule
4. Create a retention rule on a bucket
You must choose:RETENTION_DURATION: number of days (e.g., 365)DISPLAY_NAME: a friendly name for the rule
--durationis in days.--time-rule-locked nullmeans the rule is not yet locked; you can later set a lock time to make it immutable.
5. Verify the rule
lifecycle-state = ACTIVE.6. (Optional) Lock the retention rule
Once locked, the rule cannot be shortened or removed, only extended.- Find the
retention-rule-id:
- Set a lock time (ISO 8601). Example: lock now + 1 day:
7. Automate for all non-compliant buckets (script pattern)
Example bash loop for all buckets in a compartment with no retention rules:Using Python
Using Python
Below are step‑by‑step instructions to:
Use the full script for enforcement; use report‑only for pure monitoring.
- Detect OCI Object Storage buckets without retention rules
- Apply a default retention rule using Python (OCI SDK)
1. Prerequisites
-
Install OCI Python SDK
-
Configure OCI CLI config file (SDK reuses it):
~/.oci/configshould have at least: -
Ensure the user has permissions like:
2. Python script outline
This script will:- List all buckets in a compartment
- Get each bucket’s current retention rules
- For buckets without retention rules, create one.
3. How to use this for “Monitoring”
To use this as monitoring plus auto-remediation:- Wrap the script into a function.
- Trigger it periodically via:
- OCI Functions + Events or
- OCI Scheduled Jobs (e.g., a compute instance with cron) or
- Any CI/CD or external scheduler.
- Optionally:
- Log results to OCI Logging or an external system.
- Instead of auto‑creating rules, first only report buckets without rules, then add a second “remediation mode”.
Using Terraform
Using Terraform
terraform plan should show creation of oci_objectstorage_retention_rule.MONITORING_RETENTION_RULE attached to the existing MONITORING_BUCKET with the desired duration.
