Exposed Amplify app Basic Auth password

A plaintext Amplify app Basic Auth password can expose credentials through the template.

Description

Amplify’s BasicAuthConfig.Password protects access to the site. Reference it from Secrets Manager instead of putting it in the template or a parameter default.

Potential impact

An exposed username and password can grant access to the site and any other environment where they are reused.

Remediation

Replace an exposed password and update the Amplify app resource. Changing the stored secret alone does not update the app. Verify the new sign-in on the protected site.

Examples

RepositoryUrl and GitHubTokenSecretId configure the GitHub connection. The secret needs an issued GitHub token under token. The second example generates a separate site password.

Before

yaml
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  RepositoryUrl:
    Type: String
  GitHubTokenSecretId:
    Type: String
Resources:
  NewAmpApp1:
    Type: AWS::Amplify::App
    Properties:
      Name: NewAmpApp
      Repository: !Ref RepositoryUrl
      AccessToken: !Sub '{{resolve:secretsmanager:${GitHubTokenSecretId}:SecretString:token}}'
      BasicAuthConfig:
        EnableBasicAuth: true
        Password: "@skdsjdk0234!AB"
        Username: admin

After

yaml
AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  RepositoryUrl:
    Type: String
  GitHubTokenSecretId:
    Type: String
Resources:
  NewAmpApp1:
    Type: AWS::Amplify::App
    Properties:
      Name: NewAmpApp
      Repository: !Ref RepositoryUrl
      AccessToken: !Sub '{{resolve:secretsmanager:${GitHubTokenSecretId}:SecretString:token}}'
      BasicAuthConfig:
        EnableBasicAuth: true
        Password: !Sub '{{resolve:secretsmanager:${MyAmpAppSecretManagerRotater}:SecretString:password}}'
        Username: !Sub '{{resolve:secretsmanager:${MyAmpAppSecretManagerRotater}:SecretString:username}}'
  MyAmpAppSecretManagerRotater:
    Type: AWS::SecretsManager::Secret
    Properties:
      GenerateSecretString:
        SecretStringTemplate: '{"username": "admin"}'
        GenerateStringKey: password
        PasswordLength: 16

References