AWS - ECS Enum
Tip
सीखें और अभ्यास करें AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
सीखें और अभ्यास करें GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
सीखें और अभ्यास करें Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- देखें subscription plans!
- शामिल हों 💬 Discord group या telegram group या हमें फ़ॉलो करें Twitter 🐦 @hacktricks_live.
- PRs सबमिट करके hacking tricks साझा करें HackTricks और HackTricks Cloud github repos.
ECS
Basic Information
Amazon Elastic Container Services or ECS क्लाउड में containerized applications को host करने के लिए एक platform प्रदान करता है। ECS के दो deployment methods हैं, EC2 instance type और एक serverless option, Fargate। यह service क्लाउड में containers चलाना बहुत आसान और बिना परेशानी के बनाती है।
ECS निम्नलिखित तीन building blocks का उपयोग करके काम करता है: Clusters, Services, और Task Definitions।
- Clusters क्लाउड में चल रहे containers के groups हैं। जैसा कि पहले बताया गया, containers के लिए दो launch types हैं, EC2 और Fargate। AWS EC2 launch type को इस तरह परिभाषित करता है कि customers “अपने [containerized] applications को Amazon EC2 instances के cluster पर चलाएँ जिसे वे manage करते हैं”। Fargate भी इसी तरह है और इसे इस तरह परिभाषित किया गया है: “[आपको] अपने containerized applications को backend infrastructure को provision और manage करने की आवश्यकता के बिना चलाने देता है”।
- Services एक cluster के अंदर बनाए जाते हैं और tasks को run करने के लिए जिम्मेदार होते हैं। एक service definition के अंदर आप चलने वाले tasks की संख्या, auto scaling, capacity provider (Fargate/EC2/External), networking information जैसे VPC’s, subnets, और security groups define करते हैं।
- अनुप्रयोगों के 2 types होते हैं:
- Service: tasks का एक group जो long-running computing work को संभालता है जिसे stop और restart किया जा सकता है। उदाहरण के लिए, एक web application।
- Task: एक standalone task जो run होकर terminate हो जाता है। उदाहरण के लिए, एक batch job।
- service applications में, service schedulers के 2 types होते हैं:
- REPLICA: replica scheduling strategy आपके cluster में tasks की desired संख्या को place और maintain करती है। अगर किसी कारण से कोई task बंद हो जाए, तो उसी या किसी अलग node में एक नया task launch किया जाता है।
- DAEMON: हर active container instance पर, जिसके लिए आवश्यक requirements हैं, बिल्कुल एक task deploy करता है। desired number of tasks, task placement strategy specify करने या Service Auto Scaling policies का उपयोग करने की जरूरत नहीं होती।
- Task Definitions यह define करने के लिए जिम्मेदार हैं कि कौन से containers चलेंगे और containers के साथ कौन-से विभिन्न parameters configure होंगे, जैसे host के साथ port mappings, env variables, Docker entrypoint…
- env variables में sensitive info देखें!
Sensitive Data In Task Definitions
Task definitions ECS में चलने वाले actual containers को configure करने के लिए जिम्मेदार हैं। चूँकि task definitions यह define करती हैं कि containers कैसे चलेंगे, इनके अंदर बहुत सारी information मिल सकती है।
Pacu ECS enumerate कर सकता है (list-clusters, list-container-instances, list-services, list-task-definitions), यह task definitions dump भी कर सकता है।
Enumeration
# Clusters info
aws ecs list-clusters
aws ecs describe-clusters --clusters <cluster>
# Container instances
## An Amazon ECS container instance is an Amazon EC2 instance that is running the Amazon ECS container agent and has been registered into an Amazon ECS cluster.
aws ecs list-container-instances --cluster <cluster>
aws ecs describe-container-instances --cluster <cluster> --container-instances <container_instance_arn>
# Services info
aws ecs list-services --cluster <cluster>
aws ecs describe-services --cluster <cluster> --services <services>
aws ecs describe-task-sets --cluster <cluster> --service <service>
# Task definitions
aws ecs list-task-definition-families
aws ecs list-task-definitions
aws ecs list-tasks --cluster <cluster>
aws ecs describe-tasks --cluster <cluster> --tasks <tasks>
## Look for env vars and secrets used from the task definition
aws ecs describe-task-definition --task-definition <TASK_NAME>:<VERSION>
ECS Agent State DB (agent.db) के जरिए On-Host Enumeration
जब आपके पास एक ECS container instance पर shell access हो, या आपने /var/lib/ecs का host bind-mount लेकर एक container से escape किया हो (tasks के privileged रूप में चलने या volumesFrom के जरिए host data dir expose होने पर यह एक common misconfiguration है), तो ECS agent disk पर agent.db छोड़ता है जिसे किसी भी AWS API call के बिना, किसी भी IAM permission के बिना, और CloudTrail trigger किए बिना पढ़ा जा सकता है।
/var/lib/ecs/data/agent.db
(या, जब एक container से पढ़ रहे हों जिसमें host /host पर mounted है, /host/var/lib/ecs/data/agent.db).
# Most useful one-liner — dumps everything readable
strings /var/lib/ecs/data/agent.db
# From inside a container with the host mounted at /host
strings /host/var/lib/ecs/data/agent.db
# Filter for the highest-value artefacts
strings /var/lib/ecs/data/agent.db | grep -aE 'arn:aws:|AKIA|ASIA|"secret|password|TOKEN|credentials|taskRoleArn|executionRoleArn'
# Save the outcome from strings for offline analysis
strings /host/var/lib/ecs/data/agent.db >> /tmp/agent.txt
tr -s '{}[],:"\\' '\n' < /tmp/agent.txt | sed 's/^[[:space:]]*//; s/[[:space:]]*$//' | awk 'NF && length($0)>2 && !/^[0-9.]+$/' | sort -u
आप क्या recover कर सकते हैं
Cluster की age और workload churn पर निर्भर करते हुए, agent.db पर strings आमतौर पर यह देता है:
- Task और execution IAM role ARNs (
taskRoleArn,executionRoleArn) हर उस task के लिए जिसे agent ने run किया है — credential retrieval via the task metadata endpoint (169.254.170.2) के लिए उपयोगी targets। - Full task definitions — image URIs (अक्सर private ECR repos), command, entrypoint, port mappings, mount points, log configuration, और plaintext environment variables जो अक्सर database URLs, API tokens, और third-party secrets शामिल करते हैं।
- Secrets references —
secretOptionsऔरsecretsblocks जो SSM Parameter Store paths और Secrets Manager ARNs की ओर point करते हैं (great pivot list)। - Container instance ARN, cluster ARN, और registration token — बिना किसी API call के cluster name और account/region context confirm करता है।
- ENI metadata — private IPs, MAC addresses, subnet IDs, और security group IDs जो
awsvpcmode में assigned हैं (lateral movement planning के लिए उपयोगी)। - Image pull credentials — जब task definition
repositoryCredentialsuse करती है, तो referenced Secrets Manager ARN यहाँ होता है; older agents पर private-registry auth blobs (ECS_ENGINE_AUTH_DATA) भी cache हो सकते हैं। - Recently-stopped task containers — names, IDs, exit codes और labels सहित, कभी-कभी उस समय तक भी जब संबंधित
aws ecs describe-taskscall API response से उन्हें aged out कर चुका होता है।
Unauthenticated Access
AWS - ECS Unauthenticated Enum
Privesc
अगले page पर आप देख सकते हैं कि ECS permissions का abuse करके privileges कैसे escalate करें:
Post Exploitation
Persistence
Tip
सीखें और अभ्यास करें AWS Hacking:
HackTricks Training AWS Red Team Expert (ARTE)
सीखें और अभ्यास करें GCP Hacking:HackTricks Training GCP Red Team Expert (GRTE)
सीखें और अभ्यास करें Az Hacking:HackTricks Training Azure Red Team Expert (AzRTE)
HackTricks का समर्थन करें
- देखें subscription plans!
- शामिल हों 💬 Discord group या telegram group या हमें फ़ॉलो करें Twitter 🐦 @hacktricks_live.
- PRs सबमिट करके hacking tricks साझा करें HackTricks और HackTricks Cloud github repos.
HackTricks Cloud

