Skip to main content

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 compliance

Risk Level

Medium

Address

Compliance, Security

Compliance 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

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

  1. Sign in to OCI Console
  2. Navigate to Object Storage
    • In the left-side Navigation menu, click Storage.
    • Select Buckets.
  3. 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).
  4. Open the bucket details
    • From the list of buckets, click the name of the bucket that needs a retention rule.
  5. 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).
  6. 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., 365 days).
    • 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.
  7. Create the rule
    • Review the configuration.
    • Click Create (or Save) to add the retention rule to the bucket.
  8. Repeat for all non-compliant buckets
    • Return to Buckets list.
    • Repeat steps 4–7 for each bucket flagged by your OCI Security/Monitoring tool.
  9. 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.
If you share whether you’re using Cloud Guard, Security Zones, or a third-party monitoring tool, I can tailor the rule parameters to match that control specifically.
Below are the concise, CLI-focused steps to ensure OCI Object Storage buckets have retention rules defined.

0. Prerequisites

  • OCI CLI installed and configured (oci setup config done)
  • Proper permissions: ability to manage Object Storage buckets/retention rules in the target compartments

1. Get your Object Storage namespace

Save the value of data as NAMESPACE.

2. List buckets (optionally filter by compartment)

Note bucket names needing retention rules.

3. (Optional) Check if a bucket already has a retention rule

If output is empty → no retention rules defined.

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
Notes:
  • --duration is in days.
  • --time-rule-locked null means the rule is not yet locked; you can later set a lock time to make it immutable.

5. Verify the rule

You should see the new rule with lifecycle-state = ACTIVE.

6. (Optional) Lock the retention rule

Once locked, the rule cannot be shortened or removed, only extended.
  1. Find the retention-rule-id:
  1. 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:
This remediates the misconfiguration by ensuring all targeted buckets have at least one retention rule defined using OCI CLI.
Below are step‑by‑step instructions to:
  1. Detect OCI Object Storage buckets without retention rules
  2. Apply a default retention rule using Python (OCI SDK)

1. Prerequisites

  1. Install OCI Python SDK
  2. Configure OCI CLI config file (SDK reuses it):
    ~/.oci/config should have at least:
  3. 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:
  1. Wrap the script into a function.
  2. 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.
  3. 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”.
Example “report‑only” mode snippet:
Use the full script for enforcement; use report‑only for pure monitoring.
Changing or deleting a retention rule may be restricted by OCI once the rule is locked; review OCI WORM constraints before applying stricter settings, as they can become effectively irreversible.To verify, terraform plan should show creation of oci_objectstorage_retention_rule.MONITORING_RETENTION_RULE attached to the existing MONITORING_BUCKET with the desired duration.