Suggestions on GaussDB Security Configuration
Security is a responsibility shared between Huawei Cloud and yourself. Huawei Cloud ensures the security of cloud services for a secure cloud. As a tenant, you should utilize the security capabilities provided by cloud services to protect data and use the cloud securely. For details, see Shared Responsibilities.
This section provides actionable guidance for enhancing the overall security of GaussDB. You can continuously evaluate the security of your GaussDB instances and enhance their overall defensive capabilities by combining different security capabilities provided by GaussDB. By doing this, data stored in GaussDB can be protected from leakage and tampering both at rest and in transit.
You can make security configurations from the following dimensions to match your workloads.
- Maximum Number of Connections
- Security Authentication
- Client Authentication Configuration
- User Password Security
- Database Audit
- WAL Archiving
- Backup Management
- Restoration Management
- Multi-AZ Instance Deployment
- Critical Operation Protection
- Encrypted Transmission
- Database Connection Security Configuration
Maximum Number of Connections
Excessive GaussDB connections can consume excessive server resources, leading to sluggish operation responses. You can adjust the maximum allowed connections using the max_connections parameter. For details, see Connection Settings.
max_connections: the maximum number of concurrent connections to the database. This parameter affects the concurrency capability of the cluster.
Security Authentication
To ensure user experience and prevent accounts from being cracked, you can configure the following parameters to limit the number of login attempts before an account is locked and how long it is locked for:
- failed_login_attempts: the maximum number of failed login attempts permitted
- password_lock_time: the number of days before a locked account is automatically unlocked
If an account is identified as stolen or the account is used to access a database without proper authorization, administrators can manually lock the account. Administrators can manually unlock the account if the account becomes normal again.
For example, run the following commands to manually lock and unlock the user, joe:
- Manually lock the account.
1 2
gaussdb=# ALTER USER joe ACCOUNT LOCK; ALTER ROLE
- Manually unlock the account.
1 2
gaussdb=# ALTER USER joe ACCOUNT UNLOCK; ALTER ROLE
- Manually lock the account.
Client Authentication Configuration
- Default configurations for a centralized instance (assuming that the subnet CIDR block of the instance is 192.168.0.0)
1 2 3 4
TYPE DATABASE USER ADDRESS METHOD host all all 0.0.0.0/0 sha256 host all all 192.168.0.0/16 sha256 host replication all 192.168.0.0/16 sha256
- The first record allows all users from any IPv4 client to access all databases using the SHA-256 authentication method.
- The second record allows all users from IPv4 clients within the current instance's subnet to access all databases using SHA-256.
- The third record allows all users from IPv4 clients within the current instance's subnet to request a replication connection using SHA-256.
- Default configurations for a distributed instance
In most cases, the default configurations are sufficient for typical remote connection requirements. However, if you require more granular control over client access or the existing authentication settings do not meet your operational requirements, you can customize client authentication configurations.
For robust security, adjust the default configurations to fit your specific application requirements and adopt fine-grained authentication control to precisely manage client access.
User Password Security
GaussDB enhances user account security in the following ways:
- User passwords are stored in the system catalog pg_authid. To prevent password leakage, GaussDB encrypts user passwords before storing them. The cryptographic algorithm is determined by the configuration parameter password_encryption_type.
- All passwords in GaussDB must have a validity period. You can configure the password_effect_time parameter to set a validity period for each database user password.
Permission Management
- A VPC provides an isolated virtual network for GaussDB instances. You can configure and manage the network as required. A subnet provides dedicated network resources that are logically isolated from other networks for security. If you need to assign different permissions (also known as privileges) to different employees in your enterprise to access your DB instance resources, IAM is a good choice. For details, see Permission Management.
- To ensure database security and reliability, configure security groups before using a DB instance. For details, see Configuring Security Group Rules.
- Run the following SQL statement to check whether the PUBLIC role has the CREATE privilege in public schema. If yes, any user can create and modify tables or database objects in public schema.
SELECT CAST(has_schema_privilege('public','public','CREATE') AS TEXT);
- If TRUE is returned, run the following SQL statement to revoke the privilege:
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
- If TRUE is returned, run the following SQL statement to revoke the privilege:
- All users are assigned the PUBLIC role. If all privileges of an object are granted to the PUBLIC role, any user can inherit all the privileges of the object, which violates the principle of least privilege. For security reasons, this role should have only minimal privileges. Run the following SQL statement to check whether all privileges have been granted to the PUBLIC role:
SELECT relname,relacl FROM pg_class WHERE (CAST(relacl AS TEXT) LIKE '%,=arwdDxt/%}' OR CAST(relacl AS TEXT) LIKE '{=arwdDxt/%}') AND (CAST(relacl AS TEXT) LIKE '%,=APmiv/%}' OR CAST(relacl AS TEXT) LIKE '{=APmiv/%}');
- The pg_authid system catalog in the pg_catalog schema contains information about all roles in a database. To prevent sensitive information from being disclosed or modified, the PUBLIC role is not allowed to have any access to this system catalog. Run the following SQL statement to check whether privileges on the pg_authid system catalog have been granted:
SELECT relname,relacl FROM pg_class WHERE relname = 'pg_authid' AND CAST(relacl AS TEXT) LIKE '%,=%}';
- Regular users are non-administrator users who perform common service operations. Regular users should not have administrative privileges beyond their normal scope of responsibilities. For example, they should not have the privileges needed to create roles, create databases, audit, monitor, perform O&M operations, or manage security policies. To ensure the principle of least privilege is enforced for regular users, unnecessary administrative privileges should be revoked while meeting normal business requirements.
- The SECURITY DEFINER function is executed with the privileges of the creator. Improper use of SECURITY DEFINER may cause the function executor to perform unauthorized operations with the privileges of the creator. For this reason, ensure that this function is not misused. For security purposes, the PUBLIC role is not allowed to execute functions of the SECURITY DEFINER type. Run the following SQL statement to check whether the PUBLIC role has access to any SECURITY DEFINER functions:
SELECT a.proname, b.nspname FROM pg_proc a, pg_namespace b where a.pronamespace=b.oid and b.nspname <> 'pg_catalog' and a.prosecdef='t';
- If the returned result set is not empty, run the following SQL statement to check whether it has the EXECUTE privilege:
SELECT CAST(has_function_privilege('public', 'function_name([arg_type][, ...])', 'EXECUTE') AS TEXT);
- If TRUE is returned, the role has the privilege. In this case, run the following SQL statement to revoke the privilege:
REVOKE EXECUTE ON FUNCTION function_name([arg_type][, ...]) FROM PUBLIC;
- If TRUE is returned, the role has the privilege. In this case, run the following SQL statement to revoke the privilege:
- If the returned result set is not empty, run the following SQL statement to check whether it has the EXECUTE privilege:
- The SECURITY INVOKER function is executed with the privileges of the invoker. Improper use of SECURITY INVOKER may cause the function creator to perform unauthorized operations with the privileges of the executor. Before invoking a function not created by yourself, check the function content to prevent the function creator from performing unauthorized operations with your privileges.
Database Audit
- GaussDB can log operations performed on your DB instances. However, only operations supported by Cloud Trace Service (CTS) can be recorded. Before making changes, review the list of supported operations. For details, see Key Operations Supported by CTS.
- Ensure that auditing is enabled for the creation, deletion, and modification of database objects. For details, see Database Audit.
- You can integrate GaussDB with Log Tank Service (LTS) to view audit logs for your GaussDB instances. Once configured, all detailed logs requested by your instance are uploaded to LTS. You can quickly view and process logs on the LTS console. For details about how to interconnect with LTS, see Interconnecting with LTS and Querying Database Audit Logs.
- Access logs provide all log details required by instances and are stored in LTS.
- Once configured, there is a delay of approximately 10 minutes before this function takes effect.
- Enabling this function may incur additional charges.
- If you have configured audit log injection to LTS, all audit policies are uploaded by default.
- If audit logging is already enabled for your instance, LTS will reuse this audit policy. You will be billed for both audit logging and the ingestion of audit logs to LTS. Your original audit logging charges stop only after you disable the original audit logging.
- For stability, if the original audit logging is already enabled for your instance when you configure audit log ingestion to LTS, keep the original audit logging on until you have confirmed that the audit log ingestion is working properly.
WAL Archiving
The Write Ahead Log (WAL) is another term for the transaction log, which is also referred to as the Xlog. It records changes made to the database before they are written to the main storage, ensuring data consistency and durability in case of failures. The wal_level parameter specifies the level of information to be written into a WAL. To enable read-only queries on a standby node, you need to set the wal_level parameter to hot_standby on the primary node and set hot_standby to on on the standby node.
Backup Management
GaussDB provides instance backup and restoration to ensure data reliability. Backups are stored in unencrypted form. To prevent data loss caused by misoperations or service exceptions, you can:
- Configure automated backups and create manual backups. For details, see Working with Backups. When you create a GaussDB instance, the instance-level automated backup policy is enabled by default. After your instance is created, you can modify the automated backup policy as needed.
- Configure an automated backup policy to periodically back up databases. For details, see Configuring an Automated Backup Policy.
- Export backup information.
Restoration Management
GaussDB supports point-in-time recovery (PITR) using existing automated backups. During a restoration, the system downloads the most recent full backup created before the specified time from Object Storage Service (OBS) to the target instance and restores data from that backup. PITR helps you recover from data loss or corruption more securely. For details, see Restoring a GaussDB Instance to a Specific Point in Time.
Multi-AZ Instance Deployment
GaussDB supports cross-AZ high availability. When purchasing an instance, you can select a primary AZ and a standby AZ in different AZs. The primary and standby nodes are deployed in separate AZs to enable cross-AZ failover and ensure high availability.
Critical Operation Protection
The GaussDB console supports critical operation protection. When this function is enabled, the system requires identity verification before you can perform critical operations (for example, deleting an instance) to better protect your data and configurations. To enable this function, enable multi-factor authentication (MFA) on Identity and Access Management (IAM). For details, see Critical Operation Protection.
Encrypted Transmission
The server supports SSL connections by default. When connecting over TCP/IP, use SSL to encrypt all data transmitted between the client and server. This helps prevent data leakage and tampering and ensures data integrity. For details, see SSL Connection.
Database Connection Security Configuration
- Avoid public network access via direct EIP binding.
Do not expose GaussDB to the Internet or place it in a demilitarized zone (DMZ). Instead, deploy your GaussDB instance in the Huawei Cloud private network and protect it with route tables or firewall rules. Do not bind an EIP directly to your instance, as this increases the risk of unauthorized access and DDoS attacks. If your instance already has an EIP, unbind it. If you must use an EIP, configure security group rules so only trusted source IP addresses can connect to the database.
- Avoid using the default port number.
Using a well-known default port can make your database easier to discover and target. To reduce exposure, change the database port of your GaussDB instance from the default value. For details, see Changing the Database Port of a GaussDB Instance.
What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot