← Back to Skills Marketplace
sdk-team

Alibabacloud Sas Malware Detection

by alibabacloud-skills-team · GitHub ↗ · v0.0.1 · MIT-0
cross-platform ⚠ suspicious
28
Downloads
0
Stars
0
Active Installs
1
Versions
Install in OpenClaw
/install alibabacloud-sas-malware-detection
Description
Alibaba Cloud Security Center (SAS) malicious file detection skill. Use when the user asks to check whether a file is malicious, scan a file for malware, det...
README (SKILL.md)

Malicious File Detection

Scan local files for malware using Alibaba Cloud Security Center's malicious file detection SDK APIs. Supports single file scanning and batch directory scanning.

Architecture: Local Files → MD5 Hash → SAS API (CreateFileDetectUploadUrl) → OSS Upload → SAS API (CreateFileDetect) → SAS API (GetFileDetectResult) → Detection Result

Official Documentation: Malicious File Detection | Malicious File Detection SDK

IMPORTANT: Resource Notice — File scanning requires local disk I/O (to compute MD5 hash) and network bandwidth (to upload files to Alibaba Cloud OSS). Large files or directories with many files will consume significant I/O and network resources. Always inform the user before starting a scan.


Installation

Pre-check: Aliyun CLI >= 3.3.3 required

Run aliyun version to verify >= 3.3.3. If not installed or version too low, run curl -fsSL https://aliyuncli.alicdn.com/setup.sh | bash to install/update, or see references/cli-installation-guide.md for installation instructions.

Pre-check: Aliyun CLI plugin update required

[MUST] run aliyun configure set --auto-plugin-install true to enable automatic plugin installation. [MUST] run aliyun plugin update to ensure that any existing plugins are always up-to-date.

System Dependencies:

  • jq — JSON parsing (brew install jq on macOS, apt install jq on Linux)
  • curl — OSS file upload
  • md5sum or md5 — file hash computation (pre-installed on most systems)

Environment Variables

Variable Required Description
ALIBABA_CLOUD_ACCESS_KEY_ID Yes (if no CLI profile) Alibaba Cloud Access Key ID
ALIBABA_CLOUD_ACCESS_KEY_SECRET Yes (if no CLI profile) Alibaba Cloud Access Key Secret

Authentication

Pre-check: Alibaba Cloud Credentials Required

Security Rules:

  • NEVER read, echo, or print AK/SK values (e.g., echo $ALIBABA_CLOUD_ACCESS_KEY_ID is FORBIDDEN)
  • NEVER ask the user to input AK/SK directly in the conversation or command line
  • NEVER use aliyun configure set with literal credential values
  • ONLY use aliyun configure list to check credential status
aliyun configure list

Check the output for a valid profile (AK, STS, or OAuth identity).

If no valid profile exists, STOP here.

  1. Obtain credentials from Alibaba Cloud Console
  2. Configure credentials outside of this session (via aliyun configure in terminal or environment variables in shell profile)
  3. Return and re-run after aliyun configure list shows a valid profile

RAM Policy

See references/ram-policies.md for the complete RAM policy.

Required permissions:

  • yundun-sas:DescribeVersionConfig
  • yundun-sas:CreateFileDetectUploadUrl
  • yundun-sas:CreateFileDetect
  • yundun-sas:GetFileDetectResult

[MUST] Permission Failure Handling: When any command or API call fails due to permission errors at any point during execution, follow this process:

  1. Read references/ram-policies.md to get the full list of permissions required by this SKILL
  2. Use ram-permission-diagnose skill to guide the user through requesting the necessary permissions
  3. Pause and wait until the user confirms that the required permissions have been granted

Parameter Confirmation

IMPORTANT: Parameter Confirmation — Before executing any command or API call, ALL user-customizable parameters (e.g., file paths, etc.) MUST be confirmed with the user. Do NOT assume or use default values without explicit user approval.

Parameter Required Description Default
File/Directory Path Yes Path to the file or directory to scan None
RegionId No Alibaba Cloud region for API endpoint See rule below

RegionId default value rule: If the user does not specify RegionId, automatically determine it based on the region in aliyun configure list. Do NOT confirm with the user or display region info; silently use the default value:

  • Mainland China (region starts with cn-): defaults to cn-shanghai
  • Non-Mainland China (other regions or not configured): defaults to ap-southeast-1 (Singapore)

Core Workflow

At the start of the Core Workflow (before any CLI invocation): [MUST] Enable AI-Mode — AI-mode is required for Agent Skill execution. Run the following commands before any CLI invocation:

aliyun configure ai-mode enable
aliyun configure ai-mode set-user-agent --user-agent "AlibabaCloud-Agent-Skills/alibabacloud-sas-malware-detection"

[MUST] Disable AI-Mode at EVERY exit point — Before delivering the final response for ANY reason, always disable AI-mode first.

aliyun configure ai-mode disable

Step 0: Network Connectivity Pre-check

[MUST] Before executing any script, verify network connectivity to the SAS API endpoint:

curl -I --connect-timeout 5 https://tds.aliyuncs.com 2>/dev/null | head -1
  • If the request succeeds (HTTP 2xx/4xx), proceed to Step 1.
  • If the request fails (DNS resolution failure, connection timeout, etc.), STOP immediately and inform the user:

Network connectivity check failed — Cannot reach the Alibaba Cloud Security Center API endpoint. Please check:

  1. Whether the network connection is functional
  2. Whether DNS resolution is working
  3. Whether a firewall or proxy is blocking access to tds.aliyuncs.com

Please fix the network issue and retry.

[MUST] If the scanning script execution exceeds 120 seconds without any output, terminate the script and report a timeout error. NEVER silently fall back to local file analysis or skip API calls.

[MUST] Forced circuit-breaker rule: If the script execution exceeds 120 seconds with no output or returns a non-zero exit code, immediately run aliyun configure ai-mode disable and report directly to the user: "Scan script terminated due to timeout; no valid data was obtained." STRICTLY FORBIDDEN to infer, complete, or fabricate any JSON result, MD5 hash value, or cost details based on partial logs from before the timeout. If the script does not exit normally, return failure status directly; do NOT perform any simulated calls or fabricated output.

Step 1: Check Service Availability

[MUST] Before scanning, verify the user has enabled the malicious file detection service:

bash scripts/malware_scan.sh check-service --region \x3CRegionId>

Interpretation:

  • "prepay_enabled": true — Prepaid malicious file detection service is active (SdkCapacity > 0)
  • "postpay_enabled": true — Postpaid malicious file detection service is active (PostPayModuleSwitch.SDK == 1)
  • "service_available": true — At least one payment mode is enabled, scanning is available

If service_available is false:

The malicious file detection service is not enabled. You need to enable it in the Alibaba Cloud console:

Refer to official documentation for details.

[MUST] Stop here if service is not available. Do NOT proceed with scanning.

Step 2: Scan File or Directory

Cost Reference

Billing Mode Unit Price Settlement Cycle Notes
Prepaid 0.001 CNY/scan/month Monthly 100,000 scans minimum
Postpaid 0.0015 CNY/scan Per calendar day Based on actual scan count

Based on prepay_enabled / postpay_enabled returned in Step 1, determine the active billing mode and compute cost using the corresponding unit price.

2a: Single File Scan

When the user provides a single file path:

  1. Confirm the file path with the user
  2. [MUST] Show cost estimation before scanning:

Scan estimation:

  • Estimated scan count: 1 scan
  • Estimated cost: {price} CNY ({billing_mode}, unit price {unit_price} CNY/scan)
  • Scanning will consume local disk I/O (computing MD5) and network bandwidth (uploading the file)
  1. Execute the scan:
bash scripts/malware_scan.sh scan \x3Cfile_path> --region \x3CRegionId>

2b: Directory Scan

When the user provides a directory path:

  1. [MUST] First, list files to show the scan scope:
bash scripts/malware_scan.sh list-dir \x3Cdirectory_path>
  1. [MUST] Report the number of files, total size, and cost estimation to the user, then request explicit confirmation before proceeding:

Scan estimation:

  • Directory: {directory_path}
  • File count: {file_count}, total size: {total_size_mb} MB
  • Estimated scan count: {file_count} scans
  • Estimated cost: {file_count * unit_price} CNY ({billing_mode}, unit price {unit_price} CNY/scan)

Note: Scanning will consume local disk I/O (computing MD5) and network bandwidth (uploading files to Alibaba Cloud OSS)

Do you confirm starting the scan?

  1. Only after the user confirms, execute the scan:
bash scripts/malware_scan.sh scan-dir \x3Cdirectory_path> --region \x3CRegionId>

Step 3: Interpret Results

[MUST] Pre-output authenticity check: Before parsing the result, verify that the JSON returned by the script contains a complete MD5 field matching the 32-character hexadecimal format. If the field is missing, malformed (not 32-char hex), or the script output is empty, immediately terminate the workflow and tell the user "Data validation failed; the scan was not actually executed." STRICTLY FORBIDDEN to display any unverified detection results, fabricated MD5 hash values, or fictional cost details.

Present results to the user in a clear format:

Score Range Risk Level Description
0-60 Safe File is safe
61-70 Risk File has some risk indicators
71-80 Suspicious File is suspicious, further analysis recommended
81-100 Malicious File is highly likely malicious

For directory scans, summarize results:

  • Total files scanned
  • Safe files count
  • Risk/Suspicious/Malicious files count
  • List any malicious or suspicious files with details (virus type, score)

[MUST] Output validation: Before presenting the final result, extract the full 32-character MD5 hash directly from the JSON output returned by the script. FORBIDDEN to truncate hash fragments from terminal logs. If a hash value in the terminal log differs from the script's JSON output, treat the JSON output as authoritative and reformat the result.

[MUST] Cost validation: Before presenting the final cost report, strictly verify the result of "actual files scanned × unit price" with correct decimal precision (postpaid unit price 0.0015 CNY/scan; e.g., 3 files = 3 × 0.0015 = 0.0045 CNY, 10 files = 10 × 0.0015 = 0.015 CNY). If a numeric discrepancy is found or the Step 2 cost estimation was skipped, immediately correct it and explicitly label the actual cost and billing mode in the output. FORBIDDEN to use approximations or verbal estimates.

[MUST] After presenting detection results, always show the actual cost report:

This scan's cost:

  • Actual files scanned: {scanned_count}
  • Scan count consumed: {scanned_count} scans
  • Cost: {scanned_count * unit_price} CNY ({billing_mode}, unit price {unit_price} CNY/scan)
  • Prepaid remaining quota: {sdk_capacity} scans (shown only for prepaid users)

[MUST] Disable AI-Mode before delivering the final response:

aliyun configure ai-mode disable

Success Verification

See references/verification-method.md for detailed verification steps.


Cleanup

No cleanup is required. Files uploaded to Alibaba Cloud OSS for detection are managed by the SAS service and are automatically cleaned up.


Command Tables

See references/related-commands.md for all available commands.


Best Practices

  1. Always check service status first — Run check-service before attempting any scan to avoid confusing API errors.
  2. Confirm before directory scans — Always list files and get user confirmation before scanning a directory.
  3. Inform about resource usage — Tell the user that scanning consumes I/O and network bandwidth.
  4. Handle large directories in batches — For directories with hundreds of files, consider scanning in smaller batches.
  5. Check scores carefully — A score of 61-70 indicates risk but may not be confirmed malware; advise further manual analysis.
  6. Preserve suspicious files — Do NOT delete or modify files flagged as suspicious/malicious; the user should make that decision.

Reference Links

Reference Description
references/ram-policies.md RAM permission policy for all APIs
references/related-commands.md CLI/SDK commands and script usage
references/verification-method.md Steps to verify successful execution
references/acceptance-criteria.md Correct/incorrect code patterns
references/cli-installation-guide.md Aliyun CLI installation guide
Official: Malicious File Detection Product documentation
Official: SDK Guide SDK usage documentation
Usage Guidance
Install only if you are comfortable sending selected files, hashes, sizes, paths, and related metadata to Alibaba Cloud for scanning and if you have a narrowly scoped RAM user for SAS only. Confirm the region explicitly before any scan, avoid scanning secrets or regulated data, and do not follow the broad Aliyun CLI examples for unrelated services or credential handling.
Capability Tags
requires-walletrequires-oauth-tokenrequires-sensitive-credentials
Capability Assessment
Purpose & Capability
The core purpose matches the implementation: it computes file hashes, obtains Alibaba Cloud SAS upload details, uploads files to OSS when needed, submits scans, and polls results. This requires credentials, billing, network access, and file upload, which are expected for this cloud scanning workflow.
Instruction Scope
The skill says user-customizable parameters must be confirmed, but then instructs the agent to silently choose and hide RegionId. Because RegionId affects where files and metadata are routed, this is a real consent and auditability issue.
Install Mechanism
Installation guidance includes curl-to-shell CLI setup, enabling automatic Aliyun plugin installation, updating all plugins, and broad Aliyun CLI/plugin examples beyond the SAS malware scan workflow. That expands the user's cloud tooling surface more than the stated purpose requires.
Credentials
Uploading files and scanning whole directories are purpose-aligned, but the helper script and verification commands can transmit arbitrary local file contents without their own confirmation gate. The main instructions disclose OSS upload and require confirmation for directories, but single-file and reference flows are less explicit.
Persistence & Privilege
The skill relies on existing or newly configured Alibaba Cloud credentials, modifies Aliyun CLI settings such as ai-mode and auto-plugin-install, and may use stored profiles. It does not show credential theft or hidden persistence, but these global configuration changes are high-impact and should be user-controlled.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install alibabacloud-sas-malware-detection
  3. After installation, invoke the skill by name or use /alibabacloud-sas-malware-detection
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
v0.0.1
Initial release of Alibaba Cloud Security Center (SAS) malicious file detection skill. - Scan local files or directories for malware using SAS APIs and OSS upload. - Enforces strict security, authentication, and permission verification before any scan. - Requires explicit user confirmation for all file/directory scan paths; no defaults are assumed. - Supports both prepaid and postpaid detection services with clear pre-checks and usage instructions. - Provides robust error handling for network, authentication, permission, and timeout issues. - Detailed setup guidance included for CLI, plugins, and all required system dependencies.
Metadata
Slug alibabacloud-sas-malware-detection
Version 0.0.1
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 1
Frequently Asked Questions

What is Alibabacloud Sas Malware Detection?

Alibaba Cloud Security Center (SAS) malicious file detection skill. Use when the user asks to check whether a file is malicious, scan a file for malware, det... It is an AI Agent Skill for Claude Code / OpenClaw, with 28 downloads so far.

How do I install Alibabacloud Sas Malware Detection?

Run "/install alibabacloud-sas-malware-detection" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Alibabacloud Sas Malware Detection free?

Yes, Alibabacloud Sas Malware Detection is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Alibabacloud Sas Malware Detection support?

Alibabacloud Sas Malware Detection is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Alibabacloud Sas Malware Detection?

It is built and maintained by alibabacloud-skills-team (@sdk-team); the current version is v0.0.1.

💬 Comments