Security auditing is an effective method of enforcing strong internal controls that can enable you to monitor business operations to find activities that may deviate from company policy and meet various regulatory compliance requirements. Security auditing allows you to record the activity on the database for future examination and is one part of an overall database security strategy.
In this series of posts, we look at the security auditing options available for Amazon Relational Database Service (Amazon RDS) for Oracle. In Part 1, we explained the relevance of security auditing and how to use Amazon RDS for Oracle security auditing features. This post takes a closer look at how Database Activity Streams (DAS) for Amazon RDS for Oracle allows you to stream your security audit data.
What is DAS and what does it provide?
Database Activity Streams is a feature that provides a real-time data stream of all database activity. When combined with partner applications, it helps you monitor, audit, and protect your databases from unauthorized access as well as meet compliance and regulatory requirements. It reduces the work required to satisfy the compliance goals and facilitates migration to managed database services in AWS. Real-time data provided by DAS is integrated into existing monitoring and alert infrastructure, allowing you to use your existing processes, tools, reports, and know-how.
Beyond external security threats, managed databases need to provide protection against insider attacks. Database administrators (DBAs) typically have elevated levels of access, and auditing inappropriate or unapproved actions of DBAs is a necessity—and, for many, a regulatory requirement. DAS protects you from these internal threats by implementing a protection model that DBAs can’t disable. Database activity is securely transmitted outside the scope of access by internal users, thereby guarding the data from internal threats.
When you enable Database Activity Streams, an agent process is installed in the database host machine. All SQL statements that are run in the database engine are sent to this agent process. SQL statements are sent in an encrypted form via Amazon Kinesis Data Streams to partner products, consumed in your own applications, or captured with Amazon Kinesis Data Firehose for real-time analytics. DAS supports all Amazon RDS supported instance types, with the exception of T2 and T3 micro and small instances. Please note that the memory optimized db.r5 classes, which use the naming pattern db.r5.instance_size.tpcthreads_per_core.memratio, aren’t supported.
Benefits and uses
Database Activity Streams provides a near-real-time stream of all SELECT, DML, DDL, DCL, and TCL run in your DB instance. The audit data is collected via unified database auditing (as discussed in Part 1). Your database audit records are encrypted and asynchronously pushed to a Kinesis data stream provisioned on behalf of your RDS for Oracle DB instance.
You can manage the permissions to enable and disable DAS via AWS Identity and Access Management (IAM). This enables the separation of duties between security and compliance personnel and DBAs. You can also integrate with third-party database activity monitoring tools for a more complete centralized audit solution. DAS is available for Oracle 19c Standard Edition or Enterprise Edition.
The Kinesis data stream is created automatically when this feature is enabled via the AWS Command Line Interface (AWS CLI), API, or the AWS Management Console. You can also configure AWS services such as Kinesis Data Firehose and AWS Lambda to consume the stream and store the data. Database Activity Streams is a free feature, but Kinesis Data Streams charges for data streams. As of this writing, when DAS is enabled, a new data stream is created. Reusing an existing data stream isn’t supported currently. If you have hundreds of RDS instances, we recommend streaming to a Firehose delivery stream and tagging each stream with an instance identifier when consolidating.
With DAS, the collecting, searching, and processing of the database audit logs takes place outside of the source database. This has the benefit of moving security audit analysis away from the source database. You still experience some resource consumption from enabling the native Oracle feature unified auditing.
We suggest implementing this solution for the following use cases:
Auditing for compliance
Building a data lake of audit records from various sources, including relational databases, thereby optimizing and streamlining the long-term storage of audit data
Integrating with security products for near-real-time incident monitoring
Although DAS isn’t the most efficient option, you can use it to capture all changes to a particular or group of tables and stream the data to data warehouse database
Protection against ransomware by streaming data across Regions or accounts
Operating model: DBA and DAS administrator
Because DAS is a service external to the Oracle instance, you can choose to separate the audit administration duties. The administration of DAS can be a different individual from RDS database administration. You might consider this to minimize the probability of fraudulent activity. Database engineers can be responsible for managing the activities related to the smooth functioning of the database to serve the application. The DAS administrator can monitor all database and data activities in a secure fashion without the risk of audited events being changed.
Prerequisites and costs
DAS requires the use of Oracle unified auditing. This is an Oracle feature in both Standard Edition 2 and Enterprise Edition. No extra Oracle licensed option is required to use DAS. Although DAS is fee to use, you may generate costs from the following:
Kinesis data streams (one per database)
A customer key in AWS Key Management Service (AWS KMS)
Additional storage space required to host these services
Enable Database Activity Streams
You can enable DAS via several different setups:
Grant access to partner applications for Kinesis Data Streams and KMS key to monitor the database activity
Connect Kinesis Data Streams to Kinesis Data Firehose to save activities to Amazon Simple Storage Service (Amazon S3) for long-term retention
Connect to Lambda to analyze or monitor your database activities
When enabling DAS, be mindful of the following:
DAS is currently supported for Oracle Database 19c using version 22.214.171.124.ru-2019-07.rur-2019-07.r1 and higher.
Oracle Multitenant is not supported.
Amazon RDS for Oracle Read Replicas are not supported.
In an RDS for Oracle DB instance, you create and manage audit policies yourself. Unlike Amazon Aurora, Amazon RDS for Oracle doesn’t capture database activities by default.
You should consider performance of enabling DAS. Unified auditing has a low overhead, as stated by Oracle:
“For typical use cases of auditing privileged users or auditing key database operations, the performance impact is so low that it cannot even be measured due to low audit volume spread throughout the week. You could begin to see performance impact of 1% when the audit load increases to a few hundred audit events/second. For most use cases, you are not going to see overhead beyond this, but for cases where organizations want to audit application usage, it is best to tune the audit policies.”
You can enable DAS at database creation time or change a current database on the Actions menu on the RDS console.
Because the audit stream is encrypted, you have to specify a KMS key upon starting DAS. Starting DAS clears existing audit data. Make sure you have this data backed up if needed. The permissions to modify unified auditing are locked down when DAS is started, so you can’t purge unified audit trail records or change unified auditing privileges.
When you enable DAS, you automatically create a Kinesis data stream that allows Oracle unified auditing events from the database to be sent asynchronously encrypted to the data stream. DAS manages the unified auditing for you with a policy called RDS_DAS_PROTECTION_POLICY. This policy makes sure that modification of the audit trail and use of audit commands is always audited. The system privileges audited are as follows:
These audited events can then be consumed by targets such as Kinesis Data Firehose or Amazon S3. For more information, see Monitoring Amazon RDS for Oracle using Database Activity Streams.
You can process the database activity stream with the AWS SDK. In the following example, we use the AWS SDK for Python (Boto3) to take the encrypted stream and decrypt it to display in JSON format:
The output from the stream contains some internal messages; these include heartbeats and management on the unified audit stream by the database activity stream. You should strip out these messages when looking at the stream for database commands that have been run on the database by the application. For more information about the format of the messages, see Examples of an audit log for an activity stream.
If there is a problem with Kinesis Data Streams, the audit data is buffered on disk up to 90% usage. After 90% usage, we can’t track the changes with DAS except for the date timestamp where there is a gap in the audit stream. When Kinesis Data Streams becomes available, the buffered data is replayed by DAS.
If you encounter slow performance with Kinesis Data Streams, that may affect DAS. DAS uses the disk as a buffer and activates a feature in the Kinesis Data Streams to read data from disk at its upload speed so that data doesn’t accumulate on the for RDS for Oracle source database.
The stream doesn’t separate out the different messages by type. If this is a requirement, you can use Lambda with the SDK for Python. For more information, see Filter Amazon Aurora database activity stream data for segregation and monitoring.
In this post, we took a deep dive into monitoring Amazon RDS for Oracle using Database Activity Streams. For an overall look at security auditing on Amazon RDS for Oracle, refer to Part 1 of this series. We welcome your comments.
About the Authors
Tom Harper is the Manager of EMEA Relational Databases Specialist Team, based in Manchester, UK. He works in the Enterprise space to support innovation in the database domain. His team helps customers adopt the best migration strategy and design database architectures on AWS with relational managed solutions.
Sundar Raghavan is a Principal Database Specialist Solutions Architect at Amazon Web Services (AWS) and specializes in relational databases. Among his customers are clients across multiple industries in support of Oracle, PostgreSQL, and migration from Oracle to PostgreSQL on AWS. Previously, Sundar served as a database and data platform architect at Oracle, Cloudera/Horton Works. He enjoys reading, watching movies, playing chess and being outside when he is not working.
Read MoreAWS Database Blog