Home / OCI

OCIHow-toBeginner

OCI Data Safe basics: register a database and run your first security and user assessments

Register an Autonomous Database or Base Database with OCI Data Safe, run a security assessment and a user assessment, read the high-risk findings and set a baseline to catch drift.

Deepak Bhardwaj7 min read

Applies toOCI Data Safe, Autonomous Database Serverless, Oracle Base Database Service, OCI CLI 3.x

Goal

An auditor asks: "Which of your Oracle databases have default passwords, excessive privileges or no auditing?" OCI Data Safe answers that with two assessments:

  • Security Assessment: database configuration. Patches, auditing, encryption, password and profile settings, risky privileges granted to PUBLIC.
  • User Assessment: database users. Who has DBA-level or admin roles, which accounts never expire their password, which ones haven't logged in for months.

This guide registers one database, runs both assessments, reads the results and sets a baseline. Masking, sensitive data discovery and activity auditing build on the same registration but aren't covered here.

Before you start

You need:

  1. An IAM policy for the people running Data Safe. The minimum from Oracle's tutorial:
Allow group Data-Safe-Admins to manage data-safe-family in tenancy

Scope it to a compartment instead of the tenancy if Data Safe resources live in one place.

  1. Network reachability from Data Safe to the database:
Database How Data Safe connects
Autonomous Database with "Secure access from everywhere" Directly; no connectivity option needed
Autonomous Database with a private endpoint A Data Safe private endpoint in the database's VCN
Base Database / Exadata (private IP) A Data Safe private endpoint in the VCN
On-premises or other cloud An on-premises connector, or a private endpoint plus FastConnect/VPN

A Data Safe private endpoint is one per VCN. Its subnet needs security rules that allow it to reach the database listener port (1521 by default, or 1522 for Autonomous Database over TLS). Check the current Data Safe networking docs for your database type before you open ports.

  1. For anything other than Autonomous Database, a database service account for Data Safe. Autonomous Database already includes one.

Create the Data Safe service account (Base Database, Exadata, on-prem)

Connect to the PDB as a privileged user and create the account. Avoid SYSTEM and SYSAUX for its default tablespace:

CREATE USER DATASAFEADMIN IDENTIFIED BY "<14+ chars, upper, lower, digit, special>"
  DEFAULT TABLESPACE USERS TEMPORARY TABLESPACE TEMP;
GRANT CONNECT, RESOURCE TO DATASAFEADMIN;

Download datasafe_privileges.sql from the Data Safe console (the registration wizard links to it) and run it as SYS in the same PDB. For assessments only, grant the ASSESSMENT mode; ALL grants everything Data Safe features need:

@datasafe_privileges.sql DATASAFEADMIN GRANT ASSESSMENT

The script prompts or accepts arguments for username, grant/revoke and mode. Grant only what you plan to use; you can rerun it later to add audit or masking privileges.

Register the target database

The console wizard (Oracle Database → Data Safe → Target databases → Register database) is the easiest path for the first one. To script it, start from the CLI's generated template instead of guessing JSON keys:

oci data-safe target-database create --generate-param-json-input database-details > database-details.json
oci data-safe target-database create --generate-param-json-input credentials      > credentials.json
oci data-safe target-database create --generate-param-json-input connection-option > connection-option.json

For a public-access Autonomous Database the database details look like this (confirm the keys against your generated file):

{
  "databaseType": "AUTONOMOUS_DATABASE",
  "infrastructureType": "ORACLE_CLOUD",
  "autonomousDatabaseId": "ocid1.autonomousdatabase.oc1..aaaa..."
}

Register it:

export C=ocid1.compartment.oc1..aaaa...

TARGET=$(oci data-safe target-database create -c $C \
  --display-name adb-prod-orders \
  --database-details file://database-details.json \
  --query data.id --raw-output)
echo $TARGET

For a Base Database, use DATABASE_CLOUD_SERVICE with the DB system, service name and listener port, add --credentials file://credentials.json with the DATASAFEADMIN user, and add --connection-option file://connection-option.json pointing at the Data Safe private endpoint.

Registration runs asynchronously. Check that it reaches ACTIVE:

oci data-safe target-database list -c $C --all \
  --query 'data.items[].{name:"display-name", state:"lifecycle-state", type:"database-type", id:id}' \
  --output table

Registration fails

Symptom Likely cause Fix
Target stays NEEDS_ATTENTION or creation fails with a connection error Private endpoint can't reach the listener Check NSG/security list rules from the private endpoint subnet to the DB port; check the listener service name
ORA-01017 in the work request Wrong credentials for the service account Reset the password; update with oci data-safe target-database update and new credentials
Assessments run but most checks say "unable to evaluate" Service account missing privileges Rerun datasafe_privileges.sql with ASSESSMENT (or ALL) as SYS in the right PDB
Registration fails on Autonomous Database with private endpoint No Data Safe private endpoint in that VCN Create one in the ADB's VCN and use it as the connection option
"NotAuthorizedOrNotFound" Missing data-safe-family policy for your group in that compartment Add the policy

Run a security assessment

Data Safe usually creates a "latest" assessment for a new target automatically. Find it and refresh it so it's current:

SA=$(oci data-safe security-assessment list -c $C --target-id $TARGET --type LATEST \
  --query 'data[0].id' --raw-output)

oci data-safe security-assessment refresh --security-assessment-id $SA

If nothing comes back (filters and output shape vary slightly by CLI version; check with --output json), create one:

oci data-safe security-assessment create -c $C --target-id $TARGET --display-name adb-prod-orders-sa

List the high-risk findings first:

oci data-safe security-assessment list-findings --security-assessment-id $SA \
  --severity HIGH --all \
  --query 'data[].{key:key, title:title, remarks:remarks}' --output table

Repeat with --severity MEDIUM. Typical high findings and what to do:

Finding area What it usually means Typical fix
Users with default or expired-but-unlocked passwords Sample or old accounts are open Lock or drop them; rotate passwords
Privileges granted to PUBLIC Any user can run powerful packages Revoke after checking application dependencies
Unified auditing / audit policies Key actions aren't audited Enable recommended audit policies
Password profile No lockout, no lifetime, weak verify function Assign a stricter profile to application and human users
Patch level Database is behind on release updates Schedule the RU through your normal patching process

Warning

Don't revoke PUBLIC grants or lock accounts directly in production from the findings list. Applications often depend on them. Test the change in a clone first and roll it out in a change window.

Run a user assessment

UA=$(oci data-safe user-assessment list -c $C --target-id $TARGET \
  --query 'data[0].id' --raw-output)

oci data-safe user-assessment refresh --user-assessment-id $UA

oci data-safe user-assessment list-users --user-assessment-id $UA --all --output json > users.json

In the console, the user assessment view sorts users by risk. Look for:

  • Accounts with DBA, PDB_DBA or admin privileges that aren't named individuals or break-glass accounts.
  • Application schema owners that can log in interactively.
  • Users whose last login is months old. Lock them.
  • Users whose password never expires because they use the DEFAULT profile.

Set a baseline and watch for drift

Once you've fixed what you're going to fix and accepted the rest, save the current result as the baseline. Later refreshes are compared against it, so new risks stand out.

oci data-safe security-assessment set-security-assessment-baseline --security-assessment-id <saved-assessment-ocid>
oci data-safe user-assessment set-user-assessment-baseline --user-assessment-id <saved-assessment-ocid>

Check --help on both commands for the exact arguments in your CLI version; the baseline is set from a saved assessment rather than the "latest" one. The console does the same from Security assessment → Set baseline.

Schedule assessments to run weekly (the console offers a schedule on the latest assessment, and create accepts --schedule), and download the report for the auditor:

oci data-safe security-assessment download-security-assessment-report --help

Prevent it next time

  • Register every new database with Data Safe as part of the build checklist, not after the audit request.
  • Keep the service account's privileges in your database build scripts so new PDBs come up ready.
  • Review new HIGH findings against the baseline weekly; route the comparison to the team that owns the database.
  • Put Data Safe private endpoints in your network templates for every VCN that hosts databases.
  • Re-run the user assessment after every offboarding; leftover database accounts are the most common finding.