AWS - SQS Persistence

Reading time: 2 minutes

tip

Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Learn & practice Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Support HackTricks

SQS

For more information check:

AWS - SQS Enum

Using resource policy

In SQS you need to indicate with an IAM policy who has access to read and write. It's possible to indicate external accounts, ARN of roles, or even "*".
The following policy gives everyone in AWS access to everything in the queue called MyTestQueue:

json
{
  "Version": "2008-10-17",
  "Id": "__default_policy_ID",
  "Statement": [
    {
      "Sid": "__owner_statement",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": ["SQS:*"],
      "Resource": "arn:aws:sqs:us-east-1:123123123123:MyTestQueue"
    }
  ]
}

note

You could even trigger a Lambda in the attacker's account every time a new message is put in the queue (you would need to re-put it). For this follow these instructions: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs-cross-account-example.html

More SQS Persistence Techniques

AWS - SQS DLQ Backdoor Persistence via RedrivePolicy/RedriveAllowPolicy

AWS - SQS OrgID Policy Backdoor

tip

Learn & practice AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Learn & practice GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE)
Learn & practice Az Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Support HackTricks