Oracle 23ai SQL Firewall & Unified Audit: Real-Time Threat Prevention & Compliance Runbook

Production guide to configuring Oracle Database 23ai SQL Firewall (DBMS_SQL_FIREWALL) and Unified Audit policies to block unauthorized SQL injection, enforce command allow-lists, and maintain regulatory compliance.

⚡ BLUF (Bottom Line Up Front) Summary

⚠️ Advisory Scope & Terms

Oracle Database 23ai integrates SQL Firewall natively into the kernel to learn, detect, and block unauthorized SQL execution paths and SQL injection attacks in real time. Combining DBMS_SQL_FIREWALL allow-lists with fine-grained Unified Audit policies provides robust enterprise threat prevention and compliance auditing.

Environment & Prerequisites

ComponentVersion / Specification
Database EngineOracle Database 23ai Enterprise / Free
Security FeatureDBMS_SQL_FIREWALL & Oracle Unified Audit
Target ArchitectureMultitenant PDB / Autonomous Database
OS / PlatformOracle Linux 9 (UEK R7) / RHEL 9

Executive Summary: Native Database Security in Oracle 23ai

ecuring enterprise databases against SQL injection, privilege abuse, and credential theft has historically relied on external Web Application Firewalls (WAF) or complex database activity monitoring (DAM) proxies. External proxies often fail to inspect encrypted connections, stored procedure calls, or direct SQL execution within database sessions.

Oracle Database 23ai introduces SQL Firewall (DBMS_SQL_FIREWALL) directly embedded inside the database kernel. SQL Firewall captures SQL statements, connection contexts, and execution paths issued by application users. By training allow-list profiles, SQL Firewall actively blocks unauthorized SQL syntax and abnormal session origins in real time before execution.

This guide delivers a step-by-step production runbook for configuring Oracle 23ai SQL Firewall alongside Unified Audit policies for continuous monitoring and compliance enforcement.


Technical Architecture: Dual Security Perimeter

1
Client / ERP Web Server — Issues SQL via application connection pool or direct session.
2
DBMS_SQL_FIREWALL Engine — Inspects SQL structure, connection context, and IP address against trained allow-list before any execution occurs.
3A
Allowed Path — SQL matches allow-list profile; query executes and is logged to the Unified Audit Trail.
3B
Violation Path — SQL deviates from allow-list; execution is blocked (raises ORA-47600), violation logged to dba_sql_firewall_violations.
4
Unified Audit Trail — All allowed queries, blocked violations, and DBA actions are written to UNIFIED_AUDIT_TRAIL for compliance reporting.

Pre-Check Diagnostic Checklist

Run the following queries connected as SYSDBA or AUDIT_ADMIN to verify SQL Firewall and Unified Audit status:

-- Check SQL Firewall status in current PDB
SELECT status, status_updated_on, exclude_jobs FROM dba_sql_firewall_status;

-- Check active SQL Firewall capture logs
SELECT username, sql_text, sql_signature 
FROM dba_sql_firewall_allowed_sql 
WHERE ROWNUM <= 10;

-- Check Unified Audit configuration
SELECT VALUE FROM v$option WHERE PARAMETER = 'Unified Auditing';

-- Check active audit policies
SELECT policy_name, enabled_option, entity_name 
FROM audit_unified_enabled_policies;

Step-by-Step SQL Firewall & Unified Audit Runbook

Step 0: Initial Safety Checks & Enabling SQL Firewall

SQL Firewall must be enabled at the container level by a user with DBA or ADMINISTER SQL FIREWALL privileges:

-- Connect to target PDB
ALTER SESSION SET CONTAINER = BANNERPDB;

-- Enable SQL Firewall engine
BEGIN
  DBMS_SQL_FIREWALL.ENABLE;
END;
/

-- Verify status
SELECT status, status_updated_on FROM dba_sql_firewall_status;

Step 1: Create Application User Capture & Learning Baseline

Before enforcing blocking rules, place application schemas (e.g., BANPROXY or PSADMIN) into TRAINING/LEARNING mode during standard workload or staging regression runs:

-- Start capture profile for application user
BEGIN
  DBMS_SQL_FIREWALL.CREATE_CAPTURE_INITIAL_SET(
    username => 'BANPROXY',
    top_level_only => TRUE
  );
  
  DBMS_SQL_FIREWALL.START_CAPTURE(
    username => 'BANPROXY'
  );
END;
/

Allow application workflows, batch jobs, and API calls to execute normally for a baseline window (e.g., 24–48 hours) to train the allow-list profile.


Step 2: Stop Capture & Generate Allow-List Rules

Once baseline application activity has been captured, stop training and inspect generated SQL signatures:

-- Stop capture mode
BEGIN
  DBMS_SQL_FIREWALL.STOP_CAPTURE(
    username => 'BANPROXY'
  );
END;
/

-- Review captured SQL statements
SELECT sql_text, sql_signature 
FROM dba_sql_firewall_allowed_sql 
WHERE username = 'BANPROXY';

Generate the enforcement allow-list profile:

-- Create allow-list profile from captured baseline
BEGIN
  DBMS_SQL_FIREWALL.GENERATE_ALLOW_LIST(
    username => 'BANPROXY'
  );
END;
/

Step 3: Enable Enforcement Mode (Observe vs. Block)

Phase 3A: AUDIT-ONLY Mode (Observe Phase)

Enable SQL Firewall in AUDIT_ONLY mode first to log violations without interrupting live application traffic:

BEGIN
  DBMS_SQL_FIREWALL.ENABLE_ALLOW_LIST(
    username => 'BANPROXY',
    enforce => DBMS_SQL_FIREWALL.ENFORCE_SQL,
    block => FALSE
  );
END;
/

Check violation logs in dba_sql_firewall_violations:

SELECT username, sql_text, client_program, ip_address, cause, firewall_action, occurred_at 
FROM dba_sql_firewall_violations 
ORDER BY occurred_at DESC;

Phase 3B: FULL BLOCKING Mode (Active Defense)

Once zero false positives are confirmed, enable active blocking to terminate unauthorized SQL execution:

BEGIN
  DBMS_SQL_FIREWALL.ENABLE_ALLOW_LIST(
    username => 'BANPROXY',
    enforce => DBMS_SQL_FIREWALL.ENFORCE_ALL,
    block => TRUE
  );
END;
/

Step 4: Configure Unified Audit Policy for Compliance

Combine SQL Firewall violation logging with Oracle Unified Audit policies to meet PCI-DSS, FERPA, and SOC 2 audit trail requirements:

-- Create Unified Audit policy for SQL Firewall violations and privileged DBA actions
CREATE AUDIT POLICY sys_firewall_compliance_pol
  ACTIONS COMPONENT = SQL_FIREWALL ALL,
          ACTIONS LOGON, LOGOFF, ALTER SYSTEM, ALTER USER;

-- Enable audit policy for all users
ENABLE AUDIT POLICY sys_firewall_compliance_pol;

Query unified audit records:

SELECT event_timestamp, dbusername, action_name, unified_audit_policies, sql_text 
FROM unified_audit_trail 
WHERE unified_audit_policies LIKE '%SYS_FIREWALL_COMPLIANCE_POL%'
ORDER BY event_timestamp DESC;

Troubleshooting Common SQL Firewall Errors

Error Code Root Cause Remediation Procedure
ORA-47600 SQL Firewall is not enabled in the current PDB, or the operation requires ADMINISTER SQL FIREWALL privilege. Execute EXEC DBMS_SQL_FIREWALL.ENABLE; as SYSDBA or grant ADMINISTER SQL FIREWALL to the calling user.
ORA-47605 SQL Firewall blocked an unauthorized SQL statement or unknown execution path in blocking enforcement mode. Inspect dba_sql_firewall_violations (cause, firewall_action, occurred_at). If the SQL is legitimate, add it to the allow-list using DBMS_SQL_FIREWALL.ADD_ALLOWED_CONTEXT or stop capture, update, and regenerate the allow-list.

📚 Official Documentation & Technical References


Need assistance configuring Oracle 23ai SQL Firewall or tuning Unified Audit trails for your ERP environments? Schedule a Database Security Audit or Contact our Infrastructure Specialists.

⚠️INFORMATIONAL & TECHNICAL ADVISORY DISCLAIMER

The diagnostic methodologies, commands, and runbooks provided on DBPros.Net are published for informational and educational purposes only. They do not constitute customized professional consulting advice. Operating engineers and DBAs are solely responsible for securing pre-flight backups (RMAN, VM snapshots, LVM clones), validating changes in non-production staging environments, and adhering to organizational change-control policies. All content, scripts, and runbooks are provided "AS IS" without warranty of any kind, and DBPros.Net assumes no liability for system downtime, database corruption, data loss, or operational disruption. For complete advisory limitations and legal terms, view our full Terms of Service & Advisory Disclaimer.