Plaintext password in a DMS endpoint

Keep DMS endpoint passwords out of templates and parameter defaults.

Description

When supplying PostgreSQL connection details directly, pass the current password through a NoEcho parameter without a default. To use Secrets Manager, omit the username, password, server and port. Set SecretsManagerSecretId and SecretsManagerAccessRoleArn in PostgreSqlSettings.

Potential impact

A password exposed in the template, logs or outputs can give anyone who can reach the database access within the migration account’s permissions.

Remediation

If it is exposed, change the password at the database, update the DMS endpoint credentials and test the connection from the replication instance.

Examples

The example defines a PostgreSQL source on port 5432. Supply the server, database name and username, and securely pass that account’s password in ParentMasterPassword.

Before

yaml
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  DatabaseServer:
    Type: String
  DatabaseName:
    Type: String
  ParentMasterUsername:
    Type: String
Resources:
  DMSEndpoint1:
    Type: AWS::DMS::Endpoint
    Properties:
      EndpointType: source
      EngineName: postgres
      DatabaseName: !Ref DatabaseName
      Password: "asDjskjs73!!"
      Port: 5432
      ServerName: !Ref DatabaseServer
      Username: !Ref ParentMasterUsername
      SslMode: require

After

yaml
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  ParentMasterPassword:
    Type: String
    NoEcho: true
  DatabaseServer:
    Type: String
  DatabaseName:
    Type: String
  ParentMasterUsername:
    Type: String
Resources:
  DMSEndpoint1:
    Type: AWS::DMS::Endpoint
    Properties:
      EndpointType: source
      EngineName: postgres
      DatabaseName: !Ref DatabaseName
      Password: !Ref ParentMasterPassword
      Port: 5432
      ServerName: !Ref DatabaseServer
      Username: !Ref ParentMasterUsername
      SslMode: require

References