Description
Pass the MongoDB account password to MongoDbSettings.Password without a default. An !Ref still exposes a password written into the parameter’s Default in the template.
Potential impact
Anyone who obtains the password and can reach the source may read MongoDB data within the migration account’s permissions.
Remediation
For a directly supplied password, use NoEcho: true and keep it out of logs and outputs. To use Secrets Manager, omit the username, password, server and port. Set SecretsManagerSecretId and SecretsManagerAccessRoleArn in MongoDbSettings. Change an exposed password in MongoDB, update DMS and test the connection.
Examples
Both examples authenticate an existing user against admin. Supply the source server and username, and pass the current password in MasterMongoDBPassword. Changing this parameter does not change the MongoDB account password.
Before
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
MongoDBServer:
Type: String
ParentMasterUsername:
Type: String
MasterMongoDBPassword:
Type: String
Default: "as@3djdkDjskjs73!!"
Resources:
NewAmpApp1:
Type: AWS::DMS::Endpoint
Properties:
EngineName: mongodb
EndpointType: source
SslMode: require
MongoDbSettings:
AuthType: password
AuthSource: admin
Password: !Ref MasterMongoDBPassword
Port: 27017
ServerName: !Ref MongoDBServer
Username: !Ref ParentMasterUsername
After
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
MongoDBServer:
Type: String
ParentMasterUsername:
Type: String
MasterMongoDBPassword:
Type: String
NoEcho: true
Resources:
NewAmpApp1:
Type: AWS::DMS::Endpoint
Properties:
EngineName: mongodb
EndpointType: source
SslMode: require
MongoDbSettings:
AuthType: password
AuthSource: admin
Password: !Ref MasterMongoDBPassword
Port: 27017
ServerName: !Ref MongoDBServer
Username: !Ref ParentMasterUsername