Mining Attack Diagnosis (Read-Only)
Absolute Rules
- CRITICAL — MANDATORY EXECUTION: You MUST run the investigation via the entry script
scripts/mining_investigation.py. Do NOT hand-write bash/python, do NOT issue individual aliyun CLI calls, do NOT skip any step. If the script fails or times out, re-run it once before falling back — never abandon the 6-step SOP. The entry script internally invokes every Step 1–4 API (DescribeSuspEvents, DescribeAlarmEventDetail, DescribeSuspEventDetail, DescribeSecurityStatInfo, DescribeFieldStatistics, DescribeExposedInstanceList, DescribeVulList) regardless of intermediate results, and auto-retries transient ServiceUnavailable/Throttling/InternalError responses — so you must not pre-empt or short-circuit it with ad-hoc calls.
- ABSOLUTE PROHIBITION (read-only enforcement): Under NO circumstances may you generate, write, or execute any command/script calling a mutating API (
Update*/Delete*/Disable*/Modify*/Create*/Rotate*/Set*/Operate*) — e.g. OperateSuspiciousTargetBatch, ModifySecurityGroupRule, DeleteInstance. This includes scripts "for the user to run manually". If the user asks to quarantine/kill/isolate, only output the manual remediation workflow and declare this skill is read-only.
- MANDATORY OUTPUT FORMAT: When mining is confirmed, the report MUST start with the URGENT banner (see Report Output section); the Conclusion section MUST include the 4-phase remediation workflow verbatim. Partial output is forbidden.
- EXECUTION RULE FOR ERRORS: On any API error, log
[WARN] <error> to stderr and continue to the next step — never silently skip. On Forbidden/NoPermission, record the missing permission and continue. On empty results, set fields to N/A and proceed. On transient errors (ServiceUnavailable/Throttling/InternalError), the entry script retries automatically — do not conclude "service down" from a single failed call.
- INFORMATION COMPLETENESS (auto-fill first, ask second): When the user omits the account UID or region but the request intent is clear (e.g. only an API fragment like "describe susp"), do NOT stall asking for what can be derived — auto-derive the UID via
sts:GetCallerIdentity (the entry script does this when --account is omitted), use the default region cn-hangzhou, state the derivation explicitly in your reply and in the report metadata ("account auto-derived via STS"), then run the full investigation. Only ask a brief clarifying question when the request is too ambiguous to determine the product or investigation goal at all. Never fabricate findings in either path.
Overview
This skill implements a standard 6-step operating procedure for Alibaba Cloud
cryptomining (cryptojacking) detection and diagnosis. It detects mining alerts
via Security Center (SAS), extracts Indicators of Compromise (IOCs) from alert
detail, scopes the affected assets, detects the attack surface (exposed assets
- unpatched vulnerabilities) to hypothesize the intrusion entry, assesses risk,
and generates a prioritized handling/remediation report.
This skill is strictly read-only — it never performs containment,
quarantine, process termination, host isolation, or any handling/mutating
action. When mining is confirmed it prints a prominent URGENT banner telling
the operator to remediate manually.
6-Step Detection & Diagnosis SOP
Mining Attack Detection & Diagnosis — SAS Public API
|
v
+-----------------------------------------------+
| Step 1: Mining Alert Detection |
| Action: SAS DescribeSuspEvents |
| Filter: mining keywords (xmrig/mining-pool/...) |
| Output: mining alerts, affected assets, level |
+-----------------------------------------------+
|
v
+-----------------------------------------------+
| Step 2: Alert Detail & IOC Extraction |
| Action: DescribeAlarmEventDetail / |
| DescribeSuspEventDetail |
| Output: pool IPs/domains, sample MD5/SHA256, |
| malicious process/command indicators |
+-----------------------------------------------+
|
v
+-----------------------------------------------+
| Step 3: Affected Asset Scope |
| Group alerts by asset (uuid/name/IP) |
| + DescribeSecurityStatInfo / FieldStatistics |
| Output: blast radius, spread assessment |
+-----------------------------------------------+
|
v
+-----------------------------------------------+
| Step 4: Attack Surface Detection |
| Action: DescribeExposedInstanceList + |
| DescribeVulList (asap) |
| Output: likely intrusion entry vector |
+-----------------------------------------------+
|
v
+-----------------------------------------------+
| Step 5: Risk Assessment |
| Severity, handled status, spread, entry |
+-----------------------------------------------+
|
v
+-----------------------------------------------+
| Step 6: Handling & Remediation Report |
| IOC table + affected assets + attack surface |
| + P0-P3 prioritized remediation + conclusion |
| Read-only; URGENT banner if mining confirmed |
+-----------------------------------------------+
Intent Routing
| User Intent |
Action |
| Step 1: Detect mining alerts |
Read references/module1_alert_detection.md |
| Step 2: Extract IOCs from an alert |
Read references/module2_alert_detail_ioc.md |
| Step 3: Scope affected assets |
Read references/module3_affected_assets.md |
| Step 4: Detect attack surface / entry vector |
Read references/module4_attack_surface.md |
| Step 6: Remediation guidance |
Read references/module5_remediation_best_practices.md |
| Mining keyword / IOC reference |
Read references/mining_indicators.md |
| End-to-end runtime flow |
Read references/detection_flow.md |
Prerequisites
- aliyun CLI 3.x — required for API access:
brew install aliyun-cli # macOS; see https://help.aliyun.com/document_detail/121541.html
aliyun configure # stored in ~/.aliyun/config.json
- Credentials — read-only Security Center (SAS) permissions for the
Step 1–4 APIs listed in Absolute Rule #1. This skill is strictly read-only:
it needs no write/mutating permissions and never quarantines, isolates, or
terminates anything. Full permission list:
references/ram-policies.md.
- Python 3.9+ — standard library only, no external dependencies.
Authentication
Credentials are resolved automatically from the aliyun CLI profile
(~/.aliyun/config.json). The scripts never handle or print secrets.
# Run the investigation
python scripts/mining_investigation.py --account <UID>
# Select a specific profile
python scripts/mining_investigation.py --account <UID> --profile prod
CLI Options
All scripts support --help. Common parameters:
--account <UID> — Alibaba Cloud account UID (optional; auto-derived, report label only)
--days <N> — Lookback window in days (default 30)
--region <REGION> — Alibaba Cloud region (default: cn-hangzhou)
--format json|markdown — Report format
--output <path> — Output file (default: output/mining_report.md)
Additional pass-through options: --dealed Y|N|all, --profile <name>
(see references/detection_flow.md).
Observability
All API calls made by this skill include a User-Agent header for
platform-level tracing:
--user-agent AlibabaCloud-Agent-Skills/alibabacloud-mining-attack-diagnosis/{session-id}
A session-id is a 32-character hex string auto-generated per invocation and
attached to every request in the same investigation run; it is logged to
stderr at the start of execution and included in the report metadata.
Report Output
MANDATORY OUTPUT FORMAT: The report MUST follow this structure exactly. When mining is confirmed, the URGENT banner MUST appear at the top. The Conclusion MUST include the full 4-phase remediation workflow (Phase 1: Preserve & Access → Phase 2: Eradicate & Isolate → Phase 3: Harden → Phase 4: Verify & Recover). Partial or truncated output is forbidden.
Step 6 produces a report with:
- Metadata & Severity — investigation time, account, window, overall severity
- URGENT banner — shown only when mining is confirmed (read-only reminder)
- Step 1 — Mining Alerts — table of matched alerts (level, event, asset, IP, keywords)
- Step 2 — IOC table — mining-pool IPs/domains, sample MD5/SHA256, process/command indicators
- Step 3 — Affected Assets — per-asset alert counts and event names
- Step 4 — Attack Surface — exposed asset count + unpatched vulnerability count
- Step 5 — Risk Analysis — findings (spread, connectivity, entry vector)
- Conclusion — Overview, Intrusion Path & Entry Vector, P0–P3 Remediation
No-Fabrication Rule
If Security Center returns no mining-matching alerts, report truthfully that no
mining compromise is indicated for the window. Never invent alerts, affected
assets, or IOCs to "complete" a conclusion, and do not print the URGENT banner
in that case.
Sensitive-Data Handling
- IOCs are preserved (never masked) — mining-pool IPs/domains, sample
hashes, and malicious process names carry forensic value and are needed for
containment.
- Account-scoped identifiers are masked — account UID and asset uuid are
masked in all output via
_cli.mask_sensitive(). Set MINING_NO_MASK=1 to
emit raw values.
- The AccessKey Secret / security token are used only for signing and are never
printed or logged.
Available Scripts
| Script |
Type |
Description |
scripts/mining_investigation.py |
Entry |
6-step detection & diagnosis orchestrator |
Standalone step scripts (scripts/query_*.py) and internal modules
(scripts/_cli.py, scripts/_constants.py) are invoked by the entry script;
do not run them directly.
Error Handling
On any error, log [WARN] <error> to stderr and continue to the next step
— never silently skip a step or abort the investigation. Transient errors
(ServiceUnavailable/Throttling/InternalError) are auto-retried by the
entry script; permission/parameter errors degrade gracefully with the failed
step recorded in the report. Full error table: see Absolute Rule #4 and
references/detection_flow.md.
1---2name: alibabacloud-mining-attack-diagnosis3description: Alibaba Cloud Security Center cryptomining (cryptojacking) diagnosis skill. Use when the user reports or suspects a mining infection, receives a mining alert, or asks for mining alert detection, IOC extraction (pool IPs, malicious domains, sample hashes, malicious processes), affected-asset scoping, attack-surface analysis, entry-vector analysis, risk assessment, prioritized remediation reporting, cryptomining incident response, or mining risk detection. Triggers: "mining", "cryptomining", "cryptojacking", "coin mining", "coin-mining", "miner", "mining alert", "mining alerts", "mining pool", "pool IPs", "malicious domains", "sample hashes", "malicious processes", "mining IOC", "IOC extraction", "mining alert detection", "affected-asset scoping", "attack-surface analysis", "entry-vector analysis", "risk assessment", "prioritized remediation reporting", "cryptomining incident response", "mining risk detection", "xmrig", "kdevtmpfsi", "kinsing", "sysrv", "minerd", "Security Center", "ECS high CPU mining"4---5
6# Mining Attack Diagnosis (Read-Only)
7
8## Absolute Rules
9
101. **CRITICAL — MANDATORY EXECUTION:** You **MUST** run the investigation via the entry script `scripts/mining_investigation.py`. Do **NOT** hand-write bash/python, do **NOT** issue individual `aliyun` CLI calls, do **NOT** skip any step. If the script fails or times out, **re-run it once** before falling back — never abandon the 6-step SOP. The entry script internally invokes **every** Step 1–4 API (`DescribeSuspEvents`, `DescribeAlarmEventDetail`, `DescribeSuspEventDetail`, `DescribeSecurityStatInfo`, `DescribeFieldStatistics`, `DescribeExposedInstanceList`, `DescribeVulList`) regardless of intermediate results, and auto-retries transient `ServiceUnavailable`/`Throttling`/`InternalError` responses — so you must **not** pre-empt or short-circuit it with ad-hoc calls.
112. **ABSOLUTE PROHIBITION (read-only enforcement):** Under **NO** circumstances may you generate, write, or execute any command/script calling a mutating API (`Update*`/`Delete*`/`Disable*`/`Modify*`/`Create*`/`Rotate*`/`Set*`/`Operate*`) — e.g. `OperateSuspiciousTargetBatch`, `ModifySecurityGroupRule`, `DeleteInstance`. This includes scripts "for the user to run manually". If the user asks to quarantine/kill/isolate, only output the manual remediation workflow and declare this skill is read-only.
123. **MANDATORY OUTPUT FORMAT:** When mining is confirmed, the report **MUST** start with the URGENT banner (see Report Output section); the Conclusion section **MUST** include the 4-phase remediation workflow verbatim. Partial output is forbidden.
134. **EXECUTION RULE FOR ERRORS:** On any API error, log `[WARN] <error>` to stderr and continue to the next step — never silently skip. On `Forbidden`/`NoPermission`, record the missing permission and continue. On empty results, set fields to N/A and proceed. On transient errors (`ServiceUnavailable`/`Throttling`/`InternalError`), the entry script retries automatically — do not conclude "service down" from a single failed call.
145. **INFORMATION COMPLETENESS (auto-fill first, ask second):** When the user omits the account UID or region but the request intent is clear (e.g. only an API fragment like "describe susp"), do **NOT** stall asking for what can be derived — auto-derive the UID via `sts:GetCallerIdentity` (the entry script does this when `--account` is omitted), use the default region `cn-hangzhou`, **state the derivation explicitly in your reply and in the report metadata** ("account auto-derived via STS"), then run the full investigation. Only ask a brief clarifying question when the request is too ambiguous to determine the product or investigation goal at all. Never fabricate findings in either path.
15
16## Overview
17
18This skill implements a standard 6-step operating procedure for Alibaba Cloud
19cryptomining (cryptojacking) detection and diagnosis. It detects mining alerts
20via Security Center (SAS), extracts Indicators of Compromise (IOCs) from alert
21detail, scopes the affected assets, detects the attack surface (exposed assets
22+ unpatched vulnerabilities) to hypothesize the intrusion entry, assesses risk,
23and generates a prioritized handling/remediation report.
24
25**This skill is strictly read-only — it never performs containment,
26quarantine, process termination, host isolation, or any handling/mutating
27action.** When mining is confirmed it prints a prominent URGENT banner telling
28the operator to remediate manually.
29
30## 6-Step Detection & Diagnosis SOP
31
32```
33Mining Attack Detection & Diagnosis — SAS Public API
34 |
35 v
36 +-----------------------------------------------+
37 | Step 1: Mining Alert Detection |
38 | Action: SAS DescribeSuspEvents |
39 | Filter: mining keywords (xmrig/mining-pool/...) |
40 | Output: mining alerts, affected assets, level |
41 +-----------------------------------------------+
42 |
43 v
44 +-----------------------------------------------+
45 | Step 2: Alert Detail & IOC Extraction |
46 | Action: DescribeAlarmEventDetail / |
47 | DescribeSuspEventDetail |
48 | Output: pool IPs/domains, sample MD5/SHA256, |
49 | malicious process/command indicators |
50 +-----------------------------------------------+
51 |
52 v
53 +-----------------------------------------------+
54 | Step 3: Affected Asset Scope |
55 | Group alerts by asset (uuid/name/IP) |
56 | + DescribeSecurityStatInfo / FieldStatistics |
57 | Output: blast radius, spread assessment |
58 +-----------------------------------------------+
59 |
60 v
61 +-----------------------------------------------+
62 | Step 4: Attack Surface Detection |
63 | Action: DescribeExposedInstanceList + |
64 | DescribeVulList (asap) |
65 | Output: likely intrusion entry vector |
66 +-----------------------------------------------+
67 |
68 v
69 +-----------------------------------------------+
70 | Step 5: Risk Assessment |
71 | Severity, handled status, spread, entry |
72 +-----------------------------------------------+
73 |
74 v
75 +-----------------------------------------------+
76 | Step 6: Handling & Remediation Report |
77 | IOC table + affected assets + attack surface |
78 | + P0-P3 prioritized remediation + conclusion |
79 | Read-only; URGENT banner if mining confirmed |
80 +-----------------------------------------------+
81```
82
83## Intent Routing
84
85| User Intent | Action |
86|-------------|--------|
87| Step 1: Detect mining alerts | Read [references/module1_alert_detection.md](references/module1_alert_detection.md) |
88| Step 2: Extract IOCs from an alert | Read [references/module2_alert_detail_ioc.md](references/module2_alert_detail_ioc.md) |
89| Step 3: Scope affected assets | Read [references/module3_affected_assets.md](references/module3_affected_assets.md) |
90| Step 4: Detect attack surface / entry vector | Read [references/module4_attack_surface.md](references/module4_attack_surface.md) |
91| Step 6: Remediation guidance | Read [references/module5_remediation_best_practices.md](references/module5_remediation_best_practices.md) |
92| Mining keyword / IOC reference | Read [references/mining_indicators.md](references/mining_indicators.md) |
93| End-to-end runtime flow | Read [references/detection_flow.md](references/detection_flow.md) |
94
95## Prerequisites
96
971. **aliyun CLI 3.x** — required for API access:
98 ```bash
99 brew install aliyun-cli # macOS; see https://help.aliyun.com/document_detail/121541.html
100 aliyun configure # stored in ~/.aliyun/config.json
101 ```
1022. **Credentials** — read-only Security Center (SAS) permissions for the
103 Step 1–4 APIs listed in Absolute Rule #1. This skill is strictly read-only:
104 it needs no write/mutating permissions and never quarantines, isolates, or
105 terminates anything. Full permission list:
106 [references/ram-policies.md](references/ram-policies.md).
1073. **Python 3.9+** — standard library only, no external dependencies.
108
109## Authentication
110
111Credentials are resolved automatically from the aliyun CLI profile
112(`~/.aliyun/config.json`). The scripts never handle or print secrets.
113
114```bash
115# Run the investigation
116python scripts/mining_investigation.py --account <UID>
117
118# Select a specific profile
119python scripts/mining_investigation.py --account <UID> --profile prod
120```
121
122## CLI Options
123
124All scripts support `--help`. Common parameters:
125
126- `--account <UID>` — Alibaba Cloud account UID (optional; auto-derived, report label only)
127- `--days <N>` — Lookback window in days (default 30)
128- `--region <REGION>` — Alibaba Cloud region (default: cn-hangzhou)
129- `--format json|markdown` — Report format
130- `--output <path>` — Output file (default: `output/mining_report.md`)
131
132Additional pass-through options: `--dealed Y|N|all`, `--profile <name>`
133(see [references/detection_flow.md](references/detection_flow.md)).
134
135## Observability
136
137All API calls made by this skill include a `User-Agent` header for
138platform-level tracing:
139
140```
141--user-agent AlibabaCloud-Agent-Skills/alibabacloud-mining-attack-diagnosis/{session-id}
142```
143
144A `session-id` is a 32-character hex string auto-generated per invocation and
145attached to every request in the same investigation run; it is logged to
146stderr at the start of execution and included in the report metadata.
147
148## Report Output
149
150> **MANDATORY OUTPUT FORMAT:** The report **MUST** follow this structure exactly. When mining is confirmed, the URGENT banner **MUST** appear at the top. The Conclusion **MUST** include the full 4-phase remediation workflow (Phase 1: Preserve & Access → Phase 2: Eradicate & Isolate → Phase 3: Harden → Phase 4: Verify & Recover). Partial or truncated output is forbidden.
151
152Step 6 produces a report with:
153
1541. **Metadata & Severity** — investigation time, account, window, overall severity
1552. **URGENT banner** — shown only when mining is confirmed (read-only reminder)
1563. **Step 1 — Mining Alerts** — table of matched alerts (level, event, asset, IP, keywords)
1574. **Step 2 — IOC table** — mining-pool IPs/domains, sample MD5/SHA256, process/command indicators
1585. **Step 3 — Affected Assets** — per-asset alert counts and event names
1596. **Step 4 — Attack Surface** — exposed asset count + unpatched vulnerability count
1607. **Step 5 — Risk Analysis** — findings (spread, connectivity, entry vector)
1618. **Conclusion** — Overview, Intrusion Path & Entry Vector, P0–P3 Remediation
162
163## No-Fabrication Rule
164
165If Security Center returns no mining-matching alerts, report truthfully that no
166mining compromise is indicated for the window. Never invent alerts, affected
167assets, or IOCs to "complete" a conclusion, and do not print the URGENT banner
168in that case.
169
170## Sensitive-Data Handling
171
172- **IOCs are preserved (never masked)** — mining-pool IPs/domains, sample
173 hashes, and malicious process names carry forensic value and are needed for
174 containment.
175- **Account-scoped identifiers are masked** — account UID and asset uuid are
176 masked in all output via `_cli.mask_sensitive()`. Set `MINING_NO_MASK=1` to
177 emit raw values.
178- The AccessKey Secret / security token are used only for signing and are never
179 printed or logged.
180
181## Available Scripts
182
183| Script | Type | Description |
184|--------|------|-------------|
185| `scripts/mining_investigation.py` | Entry | 6-step detection & diagnosis orchestrator |
186
187Standalone step scripts (`scripts/query_*.py`) and internal modules
188(`scripts/_cli.py`, `scripts/_constants.py`) are invoked by the entry script;
189do not run them directly.
190
191## Error Handling
192
193On any error, log `[WARN] <error>` to stderr and **continue** to the next step
194— never silently skip a step or abort the investigation. Transient errors
195(`ServiceUnavailable`/`Throttling`/`InternalError`) are auto-retried by the
196entry script; permission/parameter errors degrade gracefully with the failed
197step recorded in the report. Full error table: see Absolute Rule #4 and
198[references/detection_flow.md](references/detection_flow.md).