Skip to content

DataService 09 of 1310 controls

Amazon RDS security hardening

Harden Amazon RDS: KMS encryption, private instances, locked-down snapshot sharing, managed credentials, enforced TLS, deletion protection and backups.

Published on 12 min readTags:#data-protection#encryption#databases
On this page

Amazon Relational Database Service (RDS) runs managed MySQL, PostgreSQL, MariaDB, Oracle, SQL Server and Db2 databases, and Aurora shares most of its control plane. AWS patches the host and the engine, but everything that decides who can reach the data is yours: network exposure, credentials, encryption keys and what happens to snapshots. The failure patterns are well documented. Databases created with "Publicly accessible" set to yes end up on the internet and receive password spraying within hours. Snapshots get shared publicly by mistake: in 2022, Mitiga found thousands of RDS snapshots shared with every AWS account over a single month, many containing customer PII and credentials. Master passwords end up in Terraform state, CI variables and .env files, where leaked-credential campaigns pick them up. And an attacker with control plane access does not need the database password at all: they can share a snapshot with their own account, restore it, or delete the instance and its automated backups. At defaults, the API creates instances without deletion protection, without IAM authentication, without log exports, and on older engine versions without forced TLS. This page builds the baseline: encrypted storage with a key you control, private networking, locked-down snapshots, managed credentials, enforced TLS, deletion protection, immutable backups and engine logs you can alert on.

Baseline controls

10 controlsCIS numbers refer to the CIS AWS Foundations Benchmark v7.1.0 unless another CIS benchmark is named; Security Hub CSPM IDs are listed where a control exists.
  1. 01Storage encrypted with a customer managed KMS key

    Encryption can only be set at creation, and a CMK makes snapshots shareable on your terms.

    How to check: aws rds describe-db-instances --query 'DBInstances[?!StorageEncrypted].DBInstanceArn'
    Mapping: RDS.3, RDS.27, CIS 3.2.1
  2. 02No publicly accessible instances

    A public endpoint exposes the database login to password spraying from the internet.

    How to check: aws rds describe-db-instances --query 'DBInstances[?PubliclyAccessible].DBInstanceArn'
    Mapping: RDS.2, RDS.46, CIS 3.2.3
  3. 03Snapshots private and encrypted

    A public snapshot hands a full copy of the database to every AWS account.

    How to check: aws rds describe-db-snapshot-attributes --db-snapshot-identifier <snapshot-id>
    Mapping: RDS.1, RDS.4
  4. 04Master password managed by Secrets Manager

    Nobody ever sees or stores the master password, and RDS rotates it automatically.

    How to check: aws rds describe-db-instances --query 'DBInstances[].MasterUserSecret'
  5. 05IAM database authentication for applications

    Short-lived tokens replace long-lived database passwords in application config.

    How to check: aws rds describe-db-instances --query 'DBInstances[].IAMDatabaseAuthenticationEnabled'
    Mapping: RDS.10, RDS.12, CIS AWS Database 2.0.0 3.13
  6. 06TLS required through the parameter group

    Without enforcement, clients silently fall back to unencrypted connections.

    How to check: aws rds describe-db-parameters --db-parameter-group-name app-pg16 --source user
    Mapping: RDS.38, RDS.39, RDS.41, RDS.44, CIS Database 3.6
  7. 07Deletion protection on production databases

    One API call with stolen credentials should not be able to delete a database.

    How to check: aws rds describe-db-instances --query 'DBInstances[].DeletionProtection'
    Mapping: RDS.7, RDS.8, CIS 3.2.5
  8. 08Automated backups and an AWS Backup plan

    Backups in a locked vault survive an attacker who deletes the instance and its snapshots.

    How to check: aws backup list-protected-resources
    Mapping: RDS.11, RDS.26, CIS Database 3.10
  9. 09Database logs exported to CloudWatch Logs

    Failed logins and privilege changes are only visible in the engine logs.

    How to check: aws rds describe-db-instances --query 'DBInstances[].EnabledCloudwatchLogsExports'
    Mapping: RDS.9, CIS Database 3.9
  10. 10Automatic minor version upgrades on

    Engine security patches ship as minor versions.

    How to check: aws rds describe-db-instances --query 'DBInstances[].AutoMinorVersionUpgrade'
    Mapping: RDS.13, CIS 3.2.2

Encrypt storage with a customer managed key

RDS encryption at rest covers the storage volume, automated backups, snapshots, read replicas and logs (RDS.3 for instances, RDS.27 for clusters, CIS 3.2.1). It is free and has negligible performance impact, but it has one hard constraint: you can only enable it when you create the instance. To encrypt an existing unencrypted instance, copy a snapshot with a KMS key and restore from the copy:

aws rds create-db-snapshot \
  --db-instance-identifier app-db \
  --db-snapshot-identifier app-db-pre-encryption

aws rds copy-db-snapshot \
  --source-db-snapshot-identifier app-db-pre-encryption \
  --target-db-snapshot-identifier app-db-encrypted \
  --kms-key-id arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab

aws rds restore-db-instance-from-db-snapshot \
  --db-instance-identifier app-db-v2 \
  --db-snapshot-identifier app-db-encrypted \
  --db-subnet-group-name private-db-subnets \
  --no-publicly-accessible \
  --deletion-protection

Plan the cut-over: the restored instance has a new endpoint, and writes made after the snapshot need to be replayed or the application paused.

Use a customer managed key, not aws/rds. Snapshots encrypted with the AWS managed key cannot be shared with another account, which blocks you from copying backups to an isolated recovery account. A customer managed key also lets you scope usage with kms:ViaService set to rds.<region>.amazonaws.com and revoke access by changing one key policy. Key policy design is on the KMS page.

Enforce across the organization

Deny creation of unencrypted databases with an SCP:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyUnencryptedRds",
      "Effect": "Deny",
      "Action": ["rds:CreateDBInstance", "rds:CreateDBCluster"],
      "Resource": "*",
      "Condition": { "Bool": { "rds:StorageEncrypted": "false" } }
    }
  ]
}

Aurora member instances inherit encryption from their cluster, so CreateDBInstance calls that join an existing cluster may not carry the condition key; test this against your provisioning path before attaching it. The AWS Config rules rds-storage-encrypted and rds-cluster-encrypted-at-rest back up the SCP with detection.

Keep databases off the internet

A DB instance is reachable from the internet only when three things line up: PubliclyAccessible is true, it sits in a subnet with a route to an internet gateway, and its security group allows the source. Break all three, not just one (RDS.2, CIS 3.2.3, and RDS.46 for public subnets):

aws rds modify-db-instance \
  --db-instance-identifier app-db \
  --no-publicly-accessible \
  --apply-immediately
  • Put databases in a DB subnet group made of private subnets with no internet gateway route.
  • Security groups should reference the application's security group as the source, never 0.0.0.0/0 and rarely a CIDR.
  • For human access, use Session Manager port forwarding to the database through a private EC2 instance, or a VPN into the VPC, instead of opening the database. The VPC page covers subnet design and endpoints.

Two smaller hardening items help when something does get exposed: a custom master username instead of admin or postgres (RDS.25 for instances, RDS.24 for clusters) and a non-default port (RDS.23). They do not replace network controls; they only remove the easiest guesses from automated scanners.

Enforce across the organization

RDS exposes the rds:PubliclyAccessible condition key, so an SCP can refuse public instances at creation and modification time:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenyPublicRds",
      "Effect": "Deny",
      "Action": [
        "rds:CreateDBInstance",
        "rds:ModifyDBInstance",
        "rds:RestoreDBInstanceFromDBSnapshot",
        "rds:RestoreDBInstanceToPointInTime"
      ],
      "Resource": "*",
      "Condition": { "Bool": { "rds:PubliclyAccessible": "true" } }
    }
  ]
}

Test it against your provisioning tools before attaching it broadly, and keep detection as the backstop: AWS Config rules rds-instance-public-access-check and rds-instance-subnet-igw-check feed Security Hub CSPM RDS.2 and RDS.46. Route those findings to the account owner with a short remediation SLA.

Lock down snapshot sharing

Snapshot sharing is the RDS feature attackers love most, because it moves an entire database out of your account with one control plane call and no network traffic you can see. RDS lets you share manual snapshots with specific accounts or make them public by adding all to the restore attribute (RDS.1 flags public snapshots).

Find and fix public snapshots:

for s in $(aws rds describe-db-snapshots --snapshot-type manual \
  --query 'DBSnapshots[].DBSnapshotIdentifier' --output text); do
  aws rds describe-db-snapshot-attributes --db-snapshot-identifier "$s" \
    --query "DBSnapshotAttributesResult.DBSnapshotAttributes[?AttributeName=='restore'].AttributeValues" \
    --output text | grep -q all && echo "PUBLIC: $s"
done

aws rds modify-db-snapshot-attribute \
  --db-snapshot-identifier app-db-manual-2026-11-01 \
  --attribute-name restore \
  --values-to-remove all

Run the same check with describe-db-cluster-snapshots and modify-db-cluster-snapshot-attribute for Aurora and Multi-AZ clusters.

Encryption is your strongest guardrail here: an encrypted snapshot cannot be made public, and sharing an encrypted snapshot with another account only helps that account if your key policy also lets it use the key. That is why RDS.4 (snapshots encrypted at rest) matters as much as RDS.1. An attacker who shares a snapshot with their own account still needs kms:CreateGrant or kms:Decrypt on your customer managed key, which they will not have if the key policy names only your principals.

Enforce across the organization

Deny snapshot sharing outside a dedicated backup role with an SCP:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "DenySnapshotSharing",
      "Effect": "Deny",
      "Action": [
        "rds:ModifyDBSnapshotAttribute",
        "rds:ModifyDBClusterSnapshotAttribute"
      ],
      "Resource": "*",
      "Condition": {
        "ArnNotLike": {
          "aws:PrincipalArn": "arn:aws:iam::*:role/BackupCrossAccountCopy"
        }
      }
    }
  ]
}

If you use AWS Backup for cross-account copies (below), you rarely need manual snapshot sharing at all.

Credentials and authentication

Let RDS manage the master password in Secrets Manager

The master user is the most privileged account in the database, and its password usually leaks through infrastructure code. With --manage-master-user-password, RDS generates the password, stores it in Secrets Manager, and rotates it every seven days by default. Nobody has to type it, and Terraform state never contains it:

aws rds modify-db-instance \
  --db-instance-identifier app-db \
  --manage-master-user-password \
  --master-user-secret-kms-key-id arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab \
  --apply-immediately

Use a customer managed key for the secret so access to the credential and access to the data can be controlled separately; you cannot change that key later. Read access to the secret then becomes an IAM decision you can audit in CloudTrail. Limitations as of November 2026: the integration is not supported with Blue/Green Deployments, RDS Custom, or creating read replicas from a source that uses it (except RDS for SQL Server and Db2).

Enforce it at creation with the rds:ManageMasterUserPassword condition key:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "RequireManagedMasterPassword",
      "Effect": "Deny",
      "Action": [
        "rds:CreateDBInstance",
        "rds:CreateDBCluster",
        "rds:RestoreDBInstanceFromS3",
        "rds:RestoreDBClusterFromS3"
      ],
      "Resource": "*",
      "Condition": { "Bool": { "rds:ManageMasterUserPassword": "false" } }
    }
  ]
}

AWS notes that a principal can still turn the integration off later with ModifyDBInstance; add the modify actions to the deny only if you accept that it also blocks other modifications on instances that never had the integration enabled. There is no Security Hub CSPM control for this setting, so track it with the describe-db-instances query in the baseline table.

IAM database authentication

For application users on MySQL, MariaDB and PostgreSQL, IAM database authentication replaces passwords with tokens signed by AWS Signature Version 4 that are valid for 15 minutes (RDS.10 for instances, RDS.12 for clusters). Enable it, create the database user, and grant rds-db:connect:

aws rds modify-db-instance \
  --db-instance-identifier app-db \
  --enable-iam-database-authentication \
  --apply-immediately
-- PostgreSQL
CREATE USER app_backend;
GRANT rds_iam TO app_backend;
{
  "Effect": "Allow",
  "Action": "rds-db:connect",
  "Resource": "arn:aws:rds-db:eu-west-1:111122223333:dbuser:db-ABCDEFGHIJKL01234/app_backend"
}

The resource uses the instance's DbiResourceId, not its name. Know the trade-offs before you roll it out everywhere: on PostgreSQL, granting rds_iam to a user (including the master user) makes IAM the only way that user can log in; IAM authentication needs 300 to 1000 MiB of extra memory on the instance; and CloudTrail does not log token generation, so your audit trail for these logins is the database log, not CloudTrail. Keep the master user on Secrets Manager and use IAM authentication for application and human roles.

Enforce TLS with parameter groups

RDS supports TLS on every engine, but whether it is required depends on a parameter. Clients such as psql and JDBC default to sslmode=prefer, which silently connects without TLS if the server allows it. Require TLS on the server:

EngineParameterValueControl
RDS for PostgreSQLrds.force_ssl1RDS.38
RDS for MySQLrequire_secure_transportONRDS.39
RDS for MariaDBrequire_secure_transportONRDS.44
RDS for SQL Serverrds.force_ssl1RDS.41

rds.force_ssl already defaults to 1 on RDS for PostgreSQL 15 and later, but older major versions default to 0, and a custom parameter group copied from an old one can carry the old value. Default parameter groups cannot be modified, so create a custom one:

aws rds create-db-parameter-group \
  --db-parameter-group-name app-pg16 \
  --db-parameter-group-family postgres16 \
  --description "App baseline, TLS required"

aws rds modify-db-parameter-group \
  --db-parameter-group-name app-pg16 \
  --parameters "ParameterName=rds.force_ssl,ParameterValue=1,ApplyMethod=pending-reboot"

aws rds modify-db-instance \
  --db-instance-identifier app-db \
  --db-parameter-group-name app-pg16 \
  --apply-immediately

Attaching a new parameter group requires a reboot. On clients, use sslmode=verify-full with the RDS certificate bundle so the connection is not only encrypted but also authenticated against the instance endpoint. RDS Proxy has its own setting (RDS.43, --require-tls). Aurora clusters use cluster parameter groups with the same parameter names.

Deletion protection

Deletion protection makes DeleteDBInstance and DeleteDBCluster fail until someone explicitly turns it off (RDS.8 for instances, RDS.7 for clusters). The console turns it on for production templates, but the API and most infrastructure-as-code modules default to off:

aws rds modify-db-instance \
  --db-instance-identifier app-db \
  --deletion-protection \
  --apply-immediately

On its own it only adds one step for an attacker, since ModifyDBInstance can turn it off. Make that step expensive with an SCP that denies rds:DeleteDBInstance and rds:DeleteDBCluster outside a break-glass role, and alert on any ModifyDBInstance call whose request parameters set deletionProtection to false.

When an instance is deleted, also watch the --delete-automated-backups flag: it removes the automated backups along with the instance. That is why the next section puts copies somewhere the workload account cannot reach.

Backups with AWS Backup

Automated backups give you point-in-time restore within the retention period (RDS.11 requires them; RDS.50 checks cluster retention). Set retention to at least 7 days and confirm it was not set to 0 on a dev-turned-prod instance:

aws rds modify-db-instance \
  --db-instance-identifier app-db \
  --backup-retention-period 14 \
  --apply-immediately

Automated backups live in the same account and die with the instance or a hostile DeleteDBInstance. AWS Backup fills the gap (RDS.26 checks that instances are covered by a backup plan): define a backup plan with a copy rule to a vault in a separate backup account, and lock that vault with AWS Backup Vault Lock in compliance mode so recovery points cannot be deleted before their retention ends, even by the root user of that account.

aws backup put-backup-vault-lock-configuration \
  --backup-vault-name rds-prod-vault \
  --min-retention-days 35 \
  --max-retention-days 365 \
  --changeable-for-days 3

After the changeable-for-days grace period, the lock becomes immutable. Test a restore from the backup account at least quarterly; a backup you have never restored is a hope, not a control.

Patch with automatic minor version upgrades

Security fixes for database engines usually ship as minor versions. With automatic minor version upgrades enabled (RDS.13, CIS 3.2.2; RDS.35 for clusters), RDS applies them in your maintenance window. Major versions need a planned upgrade; track end-of-standard-support dates, because RDS Extended Support keeps unsupported versions running for a fee and makes it easy to postpone upgrades indefinitely.

Logging and detection

Export database logs to CloudWatch Logs

CloudTrail only sees the RDS control plane. Logins, failed authentication, privilege changes and queries live in the engine logs, which you must export (RDS.9; engine-specific controls RDS.36, RDS.40, RDS.42, and RDS.34 and RDS.37 for Aurora):

aws rds modify-db-instance \
  --db-instance-identifier app-db \
  --cloudwatch-logs-export-configuration '{"EnableLogTypes":["postgresql","upgrade"]}' \
  --apply-immediately

For PostgreSQL, set log_connections and log_disconnections to 1 in the parameter group and consider the pgaudit extension for statement-level auditing. For MySQL and MariaDB, export the audit log after enabling the MariaDB Audit Plugin option, plus error. For Oracle, export alert, audit and listener; for SQL Server, export error and agent.

Database Activity Streams

Where you need tamper-resistant auditing that DBAs cannot switch off, use Database Activity Streams. On RDS they are available for Oracle and SQL Server (Aurora PostgreSQL and Aurora MySQL also support them); they push activity to a Kinesis data stream encrypted with your KMS key, always asynchronously on RDS. You define the audit policy in the engine, and once the stream is running a DBA cannot alter the audit policy or remove audit logs.

aws rds start-activity-stream \
  --resource-arn arn:aws:rds:eu-west-1:111122223333:db:app-oracle \
  --mode async \
  --kms-key-id arn:aws:kms:eu-west-1:111122223333:key/1234abcd-12ab-34cd-56ef-1234567890ab \
  --apply-immediately

What to alert on

Control plane events in CloudTrail worth an alert, via EventBridge:

{
  "source": ["aws.rds"],
  "detail-type": ["AWS API Call via CloudTrail"],
  "detail": {
    "eventName": [
      "ModifyDBSnapshotAttribute",
      "ModifyDBClusterSnapshotAttribute",
      "CopyDBSnapshot",
      "DeleteDBInstance",
      "DeleteDBCluster",
      "StopActivityStream",
      "ModifyDBInstance"
    ]
  }
}

Filter ModifyDBInstance downstream on the risky parameters (publiclyAccessible, deletionProtection, masterUserPassword, backupRetentionPeriod) rather than alerting on every change. A ModifyDBInstance that resets the master password followed by a connection from a new IP is a classic takeover sequence.

GuardDuty RDS Protection analyzes login activity on Aurora and supported RDS engines and raises findings such as CredentialAccess:RDS/AnomalousBehavior.SuccessfulLogin, CredentialAccess:RDS/AnomalousBehavior.SuccessfulBruteForce and CredentialAccess:RDS/MaliciousIPCaller.SuccessfulLogin. Enable it organization-wide as described on the GuardDuty page. RDS event subscriptions (RDS.19 to RDS.22) add notifications for failovers, parameter group and security group changes. Security Hub CSPM evaluates the RDS controls above continuously, see the Security Hub page.

Common mistakes

  • Planning to "turn on encryption later". RDS cannot encrypt an existing instance in place. Every unencrypted instance is a snapshot, copy and restore project with downtime, so block unencrypted creation from day one.
  • Encrypting with aws/rds. It satisfies the control, but snapshots encrypted with the AWS managed key cannot be shared with your backup account, and you cannot restrict who uses the key.
  • Relying on sslmode=prefer. The default client mode encrypts only when it is convenient. Force TLS on the server and verify the certificate on the client.
  • Deletion protection without a deny on delete. Anyone who can call ModifyDBInstance can turn it off in the same minute. Pair it with an SCP and an alert.
  • Backups in the same account only. Automated backups and manual snapshots do not survive an attacker who owns the account. Copy to a locked vault in a separate account.
  • Master password in infrastructure code. A password passed to create-db-instance ends up in state files and pipeline logs. Use managed master passwords and keep the master user out of application config.
  • Exporting no engine logs. Without them, GuardDuty findings are your only view of who logged in. Export at least connection and error logs on every production instance.

References

Written by

Florian Amette

Security engineer writing practical, benchmark-aligned hardening baselines for AWS services, from the organization and identities to data, networks and workloads.

Related services

All services