T09 · Insecure Skill Coding Practices
Warning
- Location
- references/pricing-api.md:263
- Finding
- Unnecessary Requirement for Huawei Cloud Access Credentials in an Offline Pricing Workflow<![CDATA[ ## Vulnerability Details **File Location**: `SKILL.md:97-98`; `references/pricing-api.md:263-268`; related implementation at `scripts/hwc-pricing.py:225-259` **Vulnerability Type**: Unnecessary credential exposure and violation of least privilege **Risk Level**: Medium ### Vulnerable Code ```bash export HWC_ACCESS_KEY="your-ak" export HWC_SECRET_KEY="your-sk" ``` The Skill documentation states that these credentials are prerequisites for cost estimation. However, the pricing implementation only reads a local JSON file, uses the embedded `PRICE_TABLE`, and writes or prints a Markdown report: ```python with open(args.input, "r", encoding="utf-8") as f: resources = json.load(f) resources["billing_mode"] = args.billing result = calculate_cost(resources) md_content = format_markdown(result) if args.output: with open(args.output, "w", encoding="utf-8") as f: f.write(md_content) else: print(md_content) ``` ### Technical Analysis The pricing script does not read `HWC_ACCESS_KEY` or `HWC_SECRET_KEY` and does not make any network request. Requiring users to place active cloud credentials in the environment therefore exceeds the minimum privileges necessary for the declared offline pricing functionality. Environment variables may be inherited by child processes or exposed through debugging output, crash diagnostics, CI/CD configuration, shell initialization files, or other processes operating in the same execution environment. The project does not itself exfiltrate these credentials, but its documentation unnecessarily increases the available credential exposure surface. ### Attack Path 1. A user follows the documented prerequisite and exports an active Huawei Cloud AK/SK pair. 2. The credentials remain available in the shell and are inherited by subsequently launched processes. 3. A compromised local dependency, CI task, debugging tool, or process with access to that environment obtains the credentials. 4. The credentials are used ...[truncated 642 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove the AK/SK prerequisite from `SKILL.md` and the offline pricing-script instructions. 2. Clearly state that `scripts/hwc-pricing.py` operates exclusively from an embedded static price table. 3. If live pricing is implemented later, separate it into an explicit opt-in mode. 4. Use the official Huawei Cloud credential provider chain rather than custom credential handling. 5. Require a narrowly scoped, read-only pricing or billing identity for live queries. 6. Avoid printing credentials or including them in command-line arguments. 7. Document credential rotation, CI secret masking, and environment cleanup procedures. ]]>
