More Info:
Database user passwords should be rotated periodically (every 90 days). Regular password changes limit the impact of credential theft or brute-force attacks.Risk Level
HighAddress
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
- HITRUST CSF
- ISO/IEC 27017
- ISO/IEC 27018
- ISO/IEC 27701
- KSA PDPL
- MAS Technology Risk Management (Singapore)
- MITRE ATT&CK (Cloud)
- NIS2 Directive
- NIST CSF
- NIST SP 800-171
- NYDFS 23 NYCRR 500
- PCI
- 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
Here’s how to remediate “OCI Database Passwords Should Be Rotated Periodically” for databases monitored via OCI Database Management using the OCI Console.You need to do two things:
4. Configure Secret Rotation:
- Rotate the password in the actual database
- Update the monitoring credential in OCI (preferably using an OCI Vault secret with rotation)
1. Rotate the password in the database itself
Use your normal database procedure to change the password for the user that OCI uses for monitoring (often a low‑privileged monitoring user).For example (generic approach):- Connect to the DB as a privileged user (e.g., SYS or admin).
- Run a password change:
- For Oracle DB:
- For Oracle DB:
- Confirm login works with the new password.
2. Store the credential in OCI Vault (recommended)
- In OCI Console, go to Identity & Security → Vault.
- Select your Vault (or create one if needed).
- Under the vault, go to Secrets → Create Secret:
- Name: e.g.
db-monitoring-password-<dbname>. - Secret type: Plaintext.
- Secret content: the new DB user password.
- Click Create Secret.
- Name: e.g.
4. Configure Secret Rotation:
- In the secret’s details page, choose Configure Rotation.
- Set:
- Rotation interval (e.g., 30 days, 60 days).
- A rotation function (OCI Function) if you want fully automatic rotation (function changes DB password and updates secret).
- Save.
3. Update Database Monitoring credentials in OCI
A. For managed Oracle Databases (Database Management)
- In OCI Console, go to Observability & Management → Database Management → Managed Databases.
- Click your database that is being monitored.
- In the DB Management page, look for Administration → Credentials (or Database Credentials tab, depending on UI).
- Find the credential used for monitoring (often labeled as “DB Management credential”, “Monitoring credential”, or similar).
- Click Edit / Update Credential (or Create Credential if none exists):
- User name: the monitoring user in the database.
- Password source:
- Preferred: select Vault Secret and choose the secret you created above.
- Alternative: directly provide the new password (less secure; you’ll need to edit this manually each rotation).
- Save/Update the credential.
- Open Performance Hub or Metrics; confirm data is loading.
- If there’s a Test Connection button for the credential, use it.
B. For External Databases (if applicable)
If you have External Databases added to Database Management:- Go to Observability & Management → Database Management → External Databases.
- Select the specific external DB.
- Go to Associated Credentials / Database Credentials.
- Update the monitoring credential the same way:
- Set the username.
- Use the Vault secret (recommended) or direct password.
- Save and verify connectivity.
4. Establish a rotation process (policy)
- If using Vault with automated rotation:
- Ensure the rotation function updates both:
- The DB user password in the database.
- The secret value in OCI Vault.
- Ensure the rotation function updates both:
- If rotating manually:
- Create a schedule (e.g., every 60–90 days):
- Change DB password.
- Update Vault secret (or OCI console credential) immediately.
- Validate Database Management connectivity.
- Create a schedule (e.g., every 60–90 days):
Using CLI
Using CLI
Here’s how to remediate “OCI Database Passwords Should Be Rotated Periodically” for databases monitored by OCI Database Management, using the OCI CLI.Assumptions:
You’ll see credential names/IDs (e.g.,
Verify the user can log in with the new password.
If your environment uses a different field name/flag, check:
If you share the exact output of
- Your database is already onboarded to OCI Database Management (Database Monitoring).
- You have a database user (monitoring user) whose credentials are stored in OCI Database Management.
- You can use the OCI CLI with appropriate permissions.
1. Identify the managed database and current DB credential
- List all managed databases:
-
Note the
idof the target database (call itMANAGED_DB_ID). - List existing DB credentials for that managed database:
DB_MONITORING_USER).2. Rotate the password inside the database
You must first change the password in the actual database (this is NOT done by OCI):Example (Oracle DB, run as DBA via SQL*Plus or similar):3. Update the password stored in OCI (Database Management credential)
Now update the credential that Database Management uses, via CLI:- Put the new password into a local file (avoid shell history):
- Update the database credential (replace placeholders):
MANAGED_DB_ID– from step 1.CRED_NAME– name of the existing credential (or use its ID).DB_USER– database username (e.g.monitoring_user).
- Clean up the temporary file:
4. Verify Database Monitoring is still working
- Test a Database Management connection:
- In the OCI Console (Database Management → Databases → [your DB]) confirm:
- Metrics are being collected.
- Performance/monitoring pages load without authentication errors.
5. Automate periodic rotation (optional but recommended)
- Store DB credentials in OCI Vault (recommended).
- Create a script that:
- Generates a new strong password.
- Connects to DB and runs
ALTER USER ... IDENTIFIED BY .... - Updates the Vault secret (if used).
- Calls
oci db-management database-credentials updatewith the new password.
- Run the script on a schedule (cron, OCI DevOps pipeline, or external scheduler).
If you share the exact output of
oci db-management database-credentials update --help, I can give you a fully concrete command tailored to your environment.Using Python
Using Python
Below is a practical way to monitor and rotate Oracle Database passwords in OCI using Python. This assumes you’re using OCI Database (DB System/Autonomous) and want to automate checks and rotation.
Notes:
1. High-level approach
- Store DB passwords in OCI Vault (never hardcode them).
- Use Python + OCI SDK to:
- Read the current password from Vault.
- Connect to the database and check when passwords were last changed.
- If older than your policy (e.g., 90 days), generate a new password.
- Run
ALTER USERin the DB to rotate the password. - Update the password in OCI Vault.
- Run this Python script on a schedule (e.g., OCI Scheduled Task / Cron on Compute / Function).
2. Prerequisites
- OCI SDK for Python
- OCI config
Create~/.oci/configor use instance principal. Example profile:
-
Vault setup
- Create a Vault, Key, and Secret in OCI.
- Store the DB user password as a secret (e.g.,
db-admin-password-secret). - Give the script principal (user/instance) permissions to
SECRET-READandSECRET-UPDATE.
-
DB connectivity
- Have connection details: host/port/service_name or wallet for Autonomous.
- Open security lists/NSG for the machine running the script.
3. Core Python logic
Below is an example script that:- Reads current password from OCI Vault
- Connects to DB as a user (e.g.,
ADMIN) - Checks password age using
DBA_USERS - Rotates password if older than
MAX_AGE_DAYS - Updates password in Vault
- For Autonomous DB, you often use
ADMINand connect via wallet. Replace host/port/service with wallettnsnames.oraand usedsn="db_alias"(after configuringTNS_ADMIN). - Ensure DB user has privileges (
ALTER USERvia admin account).
4. Integrate with Monitoring
To align with “OCI Database Passwords Should Be Rotated Periodically”:-
Schedule the script:
- On a Compute instance using
cron, or - As an OCI Function triggered by OCI Events + Scheduled or DevOps build pipeline.
- On a Compute instance using
-
Optional: send metrics/alerts:
- After checking age, publish a custom metric to OCI Monitoring for
"password_age_days". - Set an OCI alarm to notify (email/Slack) when age > threshold.
- After checking age, publish a custom metric to OCI Monitoring for
5. Minimal Monitoring-Only Variant
If you only want monitoring (detect, not rotate):- Remove the
ALTER USERandupdate_secret_valueparts. - Just:
- Query
DBA_USERS.password_change_time - Publish to OCI Monitoring or log to OCI Logging
- Trigger Alarms if age > limit.
- Query
Using Terraform
Using Terraform
Terraform cannot rotate OCI database user passwords or set a per-user rotation schedule on
oci_database_db_system (or related resources); this is a runtime/operational task not exposed as a configurable argument in the OCI provider.To remediate:- Use the OCI Console or SQL*Plus/SQL Developer to:
- Enforce password aging in the Oracle database profile (e.g.,
ALTER PROFILE DEFAULT LIMIT PASSWORD_LIFE_TIME 90;). - Rotate application and admin user passwords manually or via an external secret manager/automation tool (e.g., OCI Vault + scripts), outside of Terraform.
- Enforce password aging in the Oracle database profile (e.g.,
terraform plan will not show any password-rotation-related changes because no such arguments exist on the Terraform resources.
