データベースクラスターの IAM 認証が未使用

対応するデータベースクラスターで IAM 認証を設定し、長期パスワードの共有を減らします。

説明

対応する RDS または Aurora クラスターでは、アプリが IAM トークンでログインできます。多要素認証と DB の監査ログは個別に設定します。

想定される影響

共有 DB パスワードが漏えいすると、そのユーザーの権限でデータを読んだり変更したりできるおそれがあります。

対処方法

エンジンとバージョンの対応を確認し、クラスターに EnableIAMDatabaseAuthentication: true を設定します。DB ユーザーを IAM 認証用に設定し、そのユーザーで接続するための rds-db:connect をアプリに許可します。DB 内の権限も必要な範囲に絞り、トークンで TLS 接続を確認してから、不要になったパスワードを廃止します。

例

この Aurora PostgreSQL の例には、対応する DBEngineVersion と互換性のある DBClusterParameterGroupName が必要です。ユーザー名、パスワード、ネットワークを設定し、新しいクラスターに接続する前にライター DB インスタンスを作成してください。

変更前

yaml
AWSTemplateFormatVersion: "2010-09-09"
Resources:
  sample:
    Type: "AWS::RDS::DBCluster"
    Properties:
      MasterUsername: !Ref DBUsername
      MasterUserPassword: !Ref DBPassword
      StorageEncrypted: true
      DBClusterIdentifier: aurora-postgresql-cluster
      Engine: aurora-postgresql
      EngineVersion: !Ref DBEngineVersion
      DBClusterParameterGroupName: !Ref DBClusterParameterGroupName
      EnableCloudwatchLogsExports:
        - postgresql
      EnableIAMDatabaseAuthentication: false

変更後

yaml
AWSTemplateFormatVersion: "2010-09-09"
Resources:
  sample:
    Type: "AWS::RDS::DBCluster"
    Properties:
      MasterUsername: !Ref DBUsername
      MasterUserPassword: !Ref DBPassword
      StorageEncrypted: true
      DBClusterIdentifier: aurora-postgresql-cluster
      Engine: aurora-postgresql
      EngineVersion: !Ref DBEngineVersion
      DBClusterParameterGroupName: !Ref DBClusterParameterGroupName
      EnableCloudwatchLogsExports:
        - postgresql
      EnableIAMDatabaseAuthentication: true

参考資料