Description
On supported RDS for MariaDB, MySQL and PostgreSQL instances, an IAM token is valid for starting new connections for 15 minutes. An established session stays open after the token expires.
Potential impact
A long-lived database password shared across systems can be reused if any copy is exposed.
Remediation
Check engine-version and application support, then set EnableIAMDatabaseAuthentication: true. Configure the database user for IAM authentication and grant the application rds-db:connect for that user. Manage database privileges and audit logs separately. For Aurora, apply the setting to the cluster.
Examples
The examples assume an encrypted RDS for MySQL source in another Region. Set SourceDBInstanceIdentifier to its ARN and SourceRegion to its Region. Supply a supported instance class and define MyKey as a KMS key available in the replica’s Region.
Before
AWSTemplateFormatVersion: 2010-09-09
Description: IAM authentication for an encrypted RDS read replica
Parameters:
SourceDBInstanceIdentifier:
Type: String
DBInstanceType:
Type: String
SourceRegion:
Type: String
Resources:
MyDBSmall:
Type: "AWS::RDS::DBInstance"
Properties:
DBInstanceClass: !Ref DBInstanceType
SourceDBInstanceIdentifier: !Ref SourceDBInstanceIdentifier
SourceRegion: !Ref SourceRegion
DeletionProtection: false
KmsKeyId: !Ref MyKey
EnableIAMDatabaseAuthentication: false
After
AWSTemplateFormatVersion: 2010-09-09
Description: IAM authentication for an encrypted RDS read replica
Parameters:
SourceDBInstanceIdentifier:
Type: String
DBInstanceType:
Type: String
SourceRegion:
Type: String
Resources:
MyDBSmall:
Type: "AWS::RDS::DBInstance"
Properties:
DBInstanceClass: !Ref DBInstanceType
SourceDBInstanceIdentifier: !Ref SourceDBInstanceIdentifier
SourceRegion: !Ref SourceRegion
DeletionProtection: false
KmsKeyId: !Ref MyKey
EnableIAMDatabaseAuthentication: true
For a read-only replica, configure the IAM database user on the source. Once the change replicates, have the application generate a fresh token for the replica endpoint and open a TLS connection.