Back to skill

Security audit

alibabacloud-db-cost-diagnosis

Security checks for vulnerabilities and agentic risk

Overview

The skill is read-only, but its renewal audit can pull and display account-wide Alibaba Cloud order history beyond database/RDS costs.

Install only with a least-privilege Alibaba Cloud RAM identity and assume the renewal audit may reveal account-wide order and refund/cancellation details, not just RDS/database charges. Review the RAM policy before attaching it, remove unused permissions where possible, and avoid sharing generated reports unless recipients are allowed to see broader billing history.

Vulnerability Patterns
  • Unauthorized Access and Privilege EscalationObtains permissions beyond the task's legitimate needs
  • Skill Instruction HijackingAlters the agent's session goals or safety constraints when the skill loads
  • Agent Memory PoisoningWrites attacker-controlled rules into memory that affect later sessions
  • Remote Payload Retrieval and ExecutionFetches external code whose behavior can change after review
  • Embedded Malicious CodeShips malicious scripts inside the skill and executes them locally
Findings (2)

T05 · Unauthorized Access and Privilege Escalation

Warning
Location
scripts/audit_renewal_orders.py:304
Finding
RDS Renewal Audit Collects and Exposes Account-Wide Order History<![CDATA[ ## Vulnerability Details **File Location**: `scripts/audit_renewal_orders.py:304-437` **Vulnerability Type**: Excessive data access and insufficient product-scope filtering **Risk Level**: Medium ### Vulnerable Code ```python def fetch_orders(months: int, profile: str | None) -> tuple[list[dict], str, str]: """Full order history of the lookback window (no OrderType filter). The explicit CreateTimeStart/End window is mandatory: QueryOrders defaults to a ~1 hour window and would silently return nothing. Real argv assembled by the shared CLI layer (built-in API metadata mode): the product token immediately followed by the action token, then --endpoint ... --CreateTimeStart ... flags. Precheck R16 source anchor for the error-recovery-orders mock cmd (no CLI binary prefix here on purpose, per the SA-2.11 wording discipline): bssopenapi QueryOrders """ start_iso, end_iso = build_order_time_window(months) orders: list[dict] = [] page = 1 while page <= MAX_PAGES: body = _cli.call("bssopenapi", "QueryOrders", { "CreateTimeStart": start_iso, "CreateTimeEnd": end_iso, "PageSize": ORDER_PAGE_SIZE, "PageNum": page, }, profile=profile) data = body.get("Data") or {} rows = _unwrap(data.get("OrderList"), ("Order",)) orders.extend(r for r in rows if isinstance(r, dict)) total = int(data.get("TotalCount") or 0) if not rows or len(orders) >= total: break page += 1 if page > MAX_PAGES: print(f"[WARN] QueryOrders stopped at the {MAX_PAGES}-page " f"guardrail; results may be incomplete", file=sys.stderr) return orders, start_iso, end_iso ``` The unfiltered results are subsequently analyzed: ```python def analyze_orders(orders: list[dict]) -> dict: """Renewal series, price spikes and refund/cancel anomalies.""" renew_by_commodity: dict[str, list[dic ...[truncated 3912 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Apply a supported server-side product filter to `QueryOrders` when available. 2. Independently enforce a client-side allowlist before retaining, analyzing, or emitting orders. 3. Accept only orders positively associated with RDS or another explicitly requested database product. 4. Discard ambiguous or unrelated orders rather than grouping them under an unknown commodity. 5. Filter data before constructing `renewal_series`, refund anomalies, JSON output, or human-readable reports. 6. Minimize output fields. Do not emit order IDs or payment metadata unless they are necessary for the requested diagnosis. 7. Document the exact order-data scope and obtain explicit user confirmation if an account-wide order audit is genuinely required. 8. Add tests containing mixed RDS and non-RDS orders and verify that non-database orders never appear in analysis or output. ]]>

T05 · Unauthorized Access and Privilege Escalation

Note
Location
references/ram-policies.md:65
Finding
Recommended RAM Policy Grants an Unused CloudMonitor Action Outside the Skill Whitelist<![CDATA[ ## Vulnerability Details **File Location**: `references/ram-policies.md:65-68` **Vulnerability Type**: Excessive cloud permissions **Risk Level**: Low ### Vulnerable Code ```json { "Sid": "ReadOnlyCloudMonitorQuery", "Effect": "Allow", "Action": [ "cms:DescribeMetricList", "cms:QueryMetricList" ], "Resource": "*" } ``` ### Technical Analysis The project code invokes only the following CloudMonitor action: ```python _cli.call("cms", "DescribeMetricList", params, ...) ``` No project file invokes `cms:QueryMetricList`. In addition, the API whitelist in `SKILL.md` permits `DescribeMetricList` but does not include `QueryMetricList`. The supplied RAM policy nevertheless grants both actions over `Resource: "*"`. Because the extra action is unused by the audited implementation, it is not required for the Skill's declared behavior and violates least-privilege principles. The action is read-only, so the issue does not grant mutation privileges. However, any other process or injected code operating with the configured credential could use the unnecessary action to access monitoring information beyond the actual execution requirements of this Skill. ### Attack Path 1. An administrator follows `references/ram-policies.md` and installs the recommended policy. 2. The configured RAM identity receives both `cms:DescribeMetricList` and `cms:QueryMetricList`. 3. The Skill only needs and invokes `cms:DescribeMetricList`. 4. Another process, compromised component, or future unsafe code running with the same CLI profile can invoke the unnecessary `cms:QueryMetricList` permission. 5. Monitoring data accessible through that action can be queried even though the original Skill workflow did not require it. ### Impact Assessment The excessive permission is restricted to a read-only CloudMonitor query action. It does not permit resource creation, deletion, modification, or service persistence. The impact is an avoidable expansion of monitoring-dat ...[truncated 168 chars]
Remediation
<![CDATA[ ## Remediation Suggestions 1. Remove `cms:QueryMetricList` from the recommended policy. 2. Retain only the action used by the implementation: ```json { "Sid": "ReadOnlyCloudMonitorQuery", "Effect": "Allow", "Action": [ "cms:DescribeMetricList" ], "Resource": "*" } ``` 3. Keep the RAM policy synchronized with the API whitelist in `SKILL.md`. 4. Add an automated test that compares API actions referenced by code, documentation, and policy definitions. 5. If different Alibaba Cloud environments genuinely require alternative action names, select the required action during deployment rather than granting both by default. 6. Consider adding an explicit runtime allowlist in `scripts/_cli.py` so only documented product/action pairs can be invoked. ]]>
Vulnerability Patterns
  • Excessive AgencyUnrestricted Tool Access, Autonomous Decision Making, Scope Creep
  • Prompt InjectionInstruction Override, Hidden Instructions, Exfiltration Commands
  • Data ExfiltrationExternal Transmission, Env Variable Harvesting, File System Enumeration
  • Privilege EscalationExcessive Permissions, Sudo/Root Execution, Credential Access
  • Supply ChainUnpinned Dependencies, External Script Fetching, Obfuscated Code
Findings (1)

Context-Inappropriate Capability

Medium
Confidence
83% confidence
Finding
The fallback instruction authorizes behavior outside the stated script-only execution model by allowing web/documentation searching when APIs cannot answer. That expands the skill's effective network/data access surface and breaks the otherwise tight control boundary, creating opportunities for unintended outbound access, prompt-influenced retrieval, or inconsistent handling of untrusted remote content.

Static analysis

No suspicious patterns detected.