Auditing an RDS DB Instance

This section describes how to audit the security of an RDS DB instance. (Applications connected to this DB instance are deployed on ECS.)

Scenario

Database audit is deployed in bypass mode. The database audit agent is deployed on the database or application server to obtain access traffic, upload traffic data to the audit system, receive audit system configuration commands, and report database monitoring results, implementing security audit on RDS DB instances.
Figure 1 Auditing an RDS DB instance (connected to applications on ECS)

Take the following RDS DB instance as an example. Assume you need to locate and track internal violations and improper operations in the database to meet compliance requirements. This section describes how to enable the database audit function and check audit results.

Table 1 RDS DB instance

Database Type

POSTGRESQL

Database Version

7.4

IP Address

192.168.1.31

Application IP address

(Agent node IP address)

192.168.1.132

Port

8000

OS

LINUX64

Limitations and Constraints

  • Disable SSL for a database before auditing it.
  • The database audit instance and the database to be audited must be in the same region.
  • For connection purposes, ensure the VPC of the database audit instance is the same as that of the agent node.

    For details about how to choose the node, see How Do I Determine Where to Install an Agent?

Step 1: Purchase Database Audit

Configure and purchase the database audit service. For details, see Purchasing Database Audit.

For connection purposes, ensure the VPC of the database audit instance is the same as that of the agent node.

For details about how to choose the node, see How Do I Determine Where to Install an Agent?

Step 2: Add a Database and Enable Audit

After purchasing database audit, add a database to the database audit instance and enable audit for the database.
  1. Log in to the management console.
  2. Go to the database addition page, as shown in Figure 2.
    Figure 2 Accessing the database addition page
  3. In the displayed dialog box, set database parameters described in Table 1.
    Database audit supports UTF-8 and GBK character sets encoding.
    Figure 3 Add Database dialog box
  4. Click OK. The database is added to the database list and its audit status is Disabled.
  5. Locate the row that contains the database and click Enable in the Operation column to enable audit.

Step 3: Add an Agent

  1. In the Agent column of the database, click Add, as shown in Figure 4.

    Figure 4 Adding an agent

  2. In the displayed dialog box, select an addition mode.

    • Mode 1: Create an agent

      If no agent has been added for the database audit instance, you need to create an agent.

      Set Installing Note Type to Application. In the Installing Node IP Address text box, enter the application IP address in Table 1, as shown in Figure 5.
      Figure 5 Adding an agent to an application
    • Mode 2: Select an existing agent

      For details about when you should select this option, see When Should I Select an Existing Agent?

      If an agent has been installed on the application, you can select it to audit the desired database.

      Figure 6 Selecting an existing agent

  3. Click OK.

Step 4: Add a Security Group Rule

Configure TCP (port 8000) and UDP (ports 7000 to 7100) in the security group inbound rule of the database audit instance to allow the agent to communicate with the audit instance.
  • If the inbound rules of the security group have been configured for the installing node, go to Step 5: Install an Agent.
  • If no inbound rule has been configured, perform the following operations.

You can configure security group rules before or after installing an agent.

  1. Obtain the IP address of the agent node.
  2. Click Add Security Group.
  3. In the displayed dialog box, record the security group name (for example, default) of the database audit instance, as shown in Figure 7.

    Figure 7 Adding a security group rule

  4. Click Go to VPC.
  5. Enter the security group name default in the search box in the upper right corner of the list, and click or press Enter. The group information is displayed in the list.
  6. Click the group name default.
  7. Click the Inbound Rules tab. Inbound rules are displayed.
  8. Click Add Rule, as shown in Figure 8.

    Figure 8 Adding assignments

  9. In the Add Inbound Rule dialog box, add TCP (port number 8000) and UDP protocols (port number from 7000 to 7100) for the installing node IP address in Table 1. See Figure 9.

    Figure 9 Add Inbound Rule dialog box

  10. Click OK.

Step 5: Install an Agent

Download the agent package and install it on the required node. A database can be audited only after it is connected to a database audit instance.

Each agent has a unique ID, which is used as the key for connecting to a database audit instance. If you delete an agent and add it back, you need to download and install the agent again.

  1. Log in to the DBSS console.
  2. In the navigation tree on the left, choose Database Audit > Databases.
  3. Select an instance in the Instance drop-down list.
  4. Click next to the database to view details of its agent. In the Operation column of the agent, click Download Agent, as shown in Figure 10.

    The agent installation package will be downloaded.
    Figure 10 Downloading an agent

  5. Use a cross-platform transmission tool (for example, WinSCP) to upload the downloaded agent installation package xxx.tar to the node specified by Installing Node IP Address in Figure 10.
  6. Log in to the node as user root by using a cross-platform remote access tool (for example, PuTTY) via SSH.
  7. Run the following command to access the directory where the agent installation package xxx.tar is stored:

    cd Directory_containing_agent_installation_package

  8. Run the following command to decompress the installation package xxx.tar:

    tar -xvf xxx.tar

  9. Run the following command to go to the directory in which the install.sh script is stored:

    cd Directory of the install.sh script

  10. Run the following command to install the agent:

    sh install.sh

    If the following information is displayed, the agent has been installed successfully:
    1
    2
    3
    4
    5
    start agent
    starting audit agent
    audit agent started
    start success
    install dbss audit agent done!
    

Step 6: Verify the Communication Between the Agent and the Database Audit Instance

Check to ensure the communication between the agent and the database audit instance is normal.

  1. Run an SQL statement or perform an operation on the database (for example, Select 1;) on the node where the agent is installed.
  2. Go to the SQL statement list, as shown in Figure 11.

    Figure 11 Accessing the SQL statement list

  3. The SQL statement list displays the record of database login, as shown in Figure 12.

    If no SQL statement is displayed, check your network connection. For details, see What Should I Do If the Communication Between the Agent and Database Audit Instance Is Abnormal?

    Figure 12 Viewing SQL statements

Step 7: View Audit Results

You can check audit results on the Dashboard page, or generate, preview, or download reports.

  1. Check overview information.

    Go to the Dashboard page, as shown in Figure 13.

    The Dashboard page displays the audit duration, total number of SQL statements and risks, statements and risks today, and today's sessions of an instance.

    You can click the Statements tab to view SQL statement information or the Sessions tab to view session distribution.
    Figure 13 Accessing the dashboard

  2. Generate, download, or preview reports.

    1. Go to the report management page, as shown in Figure 14.
      Figure 14 Accessing the report management page
    2. In the row containing the desired report template, click Generate Report in the Operation column.
    3. In the displayed dialog box, click to set the start time and end time of the report, and select the database for which you want to generate a report.
    4. Click OK.

      The Reports page is displayed. You can view the report status on this page. After a report is generated, you can preview or download it, as shown in Figure 15.

      To preview a report online, use Google Chrome or Mozilla FireFox.

      Figure 15 Previewing or downloading an audit report