alibabacloud-cfw-exposure-detection

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Public Network Exposure Detection & Analysis

公网暴露检测与分析

⚠️ MANDATORY EXECUTION RULES — READ BEFORE DOING ANYTHING:
  1. DO NOT search for log files, security data, or any files in the workspace. There are none.
  2. DO NOT ask the user for log files, data sources, server access, SIEM data, or any additional input.
  3. DO NOT attempt to SSH, access, or connect to any server or IP address.
  4. The ONLY way to get data is by running
    aliyun cloudfw ...
    CLI commands
    as defined in the Core Workflow section below.
  5. Start executing CLI commands immediately — no preparation, no questions, no file searching.
⚠️ 强制执行规则——操作前请务必阅读:
  1. 不要搜索工作区中的日志文件、安全数据或任何文件。不存在此类文件。
  2. 不要向用户索要日志文件、数据源、服务器访问权限、SIEM数据或任何额外输入。
  3. 不要尝试SSH、访问或连接任何服务器或IP地址。
  4. 获取数据的唯一方式是运行下文核心工作流部分定义的
    aliyun cloudfw ...
    CLI命令。
  5. 立即开始执行CLI命令——无需准备、无需提问、无需搜索文件。

Scenario Description

场景说明

Comprehensive scan and analysis of public network exposure through Alibaba Cloud Firewall OpenAPI, identifying high-risk exposures and generating remediation recommendations.
Architecture:
Cloud Firewall Service → Internet Border Firewall → Exposure Detection + Risk Assessment + ACL Policy Analysis
Capability Level: Query (read-only)
Data Source: All data is obtained exclusively through Aliyun CLI commands (
aliyun cloudfw ...
). No log files, no databases, no server access, no SIEM — just CLI commands. Do NOT search the workspace for files. Do NOT ask the user for anything. Just run the commands.
通过阿里云云防火墙OpenAPI对公网暴露情况进行全面扫描和分析,识别高风险暴露项并生成修复建议。
架构:
云防火墙服务 → 互联网边界防火墙 → 暴露检测 + 风险评估 + ACL策略分析
能力级别: 查询(只读)
数据源: 所有数据通过阿里云CLI命令(
aliyun cloudfw ...
)获取。无需日志文件、数据库、服务器访问权限、SIEM——仅需CLI命令。不要搜索工作区文件,不要向用户索要任何内容,直接运行命令即可。

Network Access Boundary

网络访问边界

This skill follows least-privilege network access:
  • Allowed network target: Alibaba Cloud OpenAPI endpoints resolved by Aliyun CLI for
    cloudfw
    only (
    *.aliyuncs.com
    ).
  • Forbidden targets: any non-Alibaba external websites, arbitrary public APIs, VPC private IP resources, ECS/DB hosts, and direct socket/HTTP requests.
  • Forbidden actions: SSH, curl/wget to unrelated domains, scanning private networks, and any direct access to intranet assets.
Core Capabilities:
  1. Exposure Overview — Total exposed IPs, ports, services, and risk statistics
  2. Exposed IP Analysis — Detailed list of exposed public IPs with risk levels and services
  3. Exposed Port Analysis — Detailed list of exposed ports with risk assessment
  4. Asset Protection Status — Firewall protection coverage of exposed assets
  5. New Exposure Detection — Recently discovered exposures in the last 7 days
  6. Risk Assessment — Detailed risk reasons per IP
  7. Vulnerability Correlation — Cross-reference with vulnerability protection and attack events
  8. ACL Policy Review — Internet border ACL rule coverage

本技能遵循最小权限网络访问原则:
  • 允许访问的网络目标:仅阿里云CLI解析的云防火墙
    cloudfw
    对应的阿里云OpenAPI端点(
    *.aliyuncs.com
    )。
  • 禁止访问的目标:任何非阿里云的外部网站、任意公开API、VPC私有IP资源、ECS/数据库主机、直接socket/HTTP请求。
  • 禁止操作:SSH、向无关域名发起curl/wget请求、扫描私有网络、任何直接访问内网资产的行为。
核心能力:
  1. 暴露概览——暴露IP、端口、服务总数及风险统计
  2. 暴露IP分析——暴露公网IP的详细列表,附带风险等级和服务信息
  3. 暴露端口分析——暴露端口的详细列表,附带风险评估结果
  4. 资产防护状态——暴露资产的防火墙防护覆盖情况
  5. 新增暴露检测——过去7天内新发现的暴露项
  6. 风险评估——每个IP的详细风险原因
  7. 漏洞关联——与漏洞防护和攻击事件的交叉比对
  8. ACL策略检查——互联网边界ACL规则覆盖情况

Prerequisites

前置条件

Pre-check: Aliyun CLI >= 3.3.1 required Run
aliyun version
to verify >= 3.3.1. If not installed or version too low, see
references/cli-installation-guide.md
for installation instructions. Then [MUST] run
aliyun configure set --auto-plugin-install true
to enable automatic plugin installation.

前置检查:要求Aliyun CLI版本 >= 3.3.1 运行
aliyun version
确认版本 >= 3.3.1。如果未安装或版本过低,参考
references/cli-installation-guide.md
中的安装说明操作。 随后[必须]运行
aliyun configure set --auto-plugin-install true
开启插件自动安装功能。

Authentication

身份认证

Pre-check: Alibaba Cloud Credentials Required
Security Rules:
  • NEVER read, echo, print, cat, or display AK/SK values under any circumstances
  • 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
bash
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

前置检查:需要阿里云凭证
安全规则:
  • 任何情况下绝对不要读取、回显、打印、输出或展示AK/SK的值
  • 绝对不要要求用户在对话或命令行中直接输入AK/SK
  • 绝对不要
    aliyun configure set
    命令中直接使用明文凭证值
  • 可使用
    aliyun configure list
    检查凭证状态
bash
aliyun configure list
检查输出中是否存在有效配置(AK、STS或OAuth身份)。
如果不存在有效配置,请在此停止。
  1. 阿里云控制台获取凭证
  2. 在本次会话之外配置凭证(通过终端的
    aliyun configure
    命令或shell配置文件中的环境变量)
  3. aliyun configure list
    显示有效配置后,返回重新运行

RAM Policy

RAM权限策略

[MUST] RAM Permission Pre-check: Before executing any commands, verify the current user has the required permissions.
  1. Use
    ram-permission-diagnose
    skill to get current user's permissions
  2. Compare against
    references/ram-policies.md
  3. Abort and prompt user if any permission is missing
Minimum required permissions — see references/ram-policies.md for full policy JSON.
Alternatively, attach the system policy: AliyunYundunCloudFirewallReadOnlyAccess

[必须]RAM权限前置检查: 执行任何命令前,验证当前用户拥有所需权限。
  1. 使用
    ram-permission-diagnose
    技能获取当前用户的权限
  2. references/ram-policies.md
    中的要求比对
  3. 如果缺失任何权限,终止流程并提示用户
所需最低权限——完整策略JSON参考references/ram-policies.md
也可以直接挂载系统策略:AliyunYundunCloudFirewallReadOnlyAccess

Parameter Confirmation

参数确认

IMPORTANT: Parameter Confirmation — Before executing any command or API call, check if the user has already provided necessary parameters in their request.
  • If the user's request explicitly mentions a parameter value (e.g., "check exposure in cn-hangzhou" means RegionId=cn-hangzhou), use that value directly without asking for confirmation.
  • For optional parameters with sensible defaults (PageSize, CurrentPage, time ranges), use the defaults without asking unless the user indicates otherwise.
  • Do NOT re-ask for parameters that the user has clearly stated.
Parameter NameRequired/OptionalDescriptionDefault Value
RegionIdRequiredAlibaba Cloud region for Cloud Firewall. Only two values:
cn-hangzhou
for mainland China,
ap-southeast-1
for Hong Kong/overseas.
cn-hangzhou
(use directly without asking; only use
ap-southeast-1
if user explicitly mentions Hong Kong/overseas/international)
PageSizeOptionalNumber of items per page for paginated APIs50 (use without asking)
CurrentPageOptionalPage number for paginated APIs1 (use without asking)
StartTimeOptionalStart time for time-range queries (Unix timestamp in seconds)30 days ago for exposure queries, 7 days ago for attack/vuln queries (use without asking)
EndTimeOptionalEnd time for time-range queries (Unix timestamp in seconds)Current time (use without asking)

重要:参数确认——执行任何命令或API调用前,检查用户的请求中是否已经提供了必要参数。
  • 如果用户请求明确提到参数值(例如“检查杭州地域的暴露情况”代表RegionId=cn-hangzhou),直接使用该值无需确认
  • 对于有合理默认值的可选参数(PageSize、CurrentPage、时间范围),直接使用默认值即可,除非用户另有说明。
  • 不要重复询问用户已经明确说明的参数。
参数名称必填/可选说明默认值
RegionId必填云防火墙对应的阿里云地域。仅两个可选值:
cn-hangzhou
对应中国内地,
ap-southeast-1
对应中国香港/境外。
cn-hangzhou
(直接使用无需询问;仅当用户明确提到中国香港/境外/国际区域时使用
ap-southeast-1
PageSize可选分页API的每页返回条目数50(直接使用无需询问)
CurrentPage可选分页API的页码1(直接使用无需询问)
StartTime可选时间范围查询的起始时间(Unix时间戳,单位秒)暴露查询默认30天前,攻击/漏洞查询默认7天前(直接使用无需询问)
EndTime可选时间范围查询的结束时间(Unix时间戳,单位秒)当前时间(直接使用无需询问)

Error Handling and Workflow Resilience

错误处理与工作流韧性

CRITICAL: Continue on failure. If any individual API call fails, do NOT stop the entire workflow. Log the error for that step, then proceed to the next step. Present whatever data was successfully collected.
关键:失败时继续执行。如果单个API调用失败,不要停止整个工作流。 记录该步骤的错误,然后继续执行下一步。展示所有成功收集到的数据。

Retry Logic

重试逻辑

For each API call:
  1. If the call fails with a transient error (network timeout, throttling
    Throttling.User
    ,
    ServiceUnavailable
    , HTTP 500/502/503), retry up to 2 times with a 3-second delay between retries.
  2. If the call fails with a permanent error (e.g.,
    InvalidParameter
    ,
    Forbidden
    ,
    InvalidAccessKeyId
    ), do NOT retry. Record the error and move on.
  3. After all retries are exhausted, record "[Step X] Failed: {error message}" and continue to the next step.
每个API调用的处理规则:
  1. 如果调用返回瞬时错误(网络超时、限流
    Throttling.User
    ServiceUnavailable
    、HTTP 500/502/503),最多重试2次,每次重试间隔3秒。
  2. 如果调用返回永久错误(例如
    InvalidParameter
    Forbidden
    InvalidAccessKeyId
    ),不要重试。记录错误后继续执行下一步。
  3. 重试次数用尽后,记录“[步骤X] 失败:{错误信息}”,然后继续执行下一步。

Timeout Policy (MUST)

超时策略(必须执行)

Before executing any API command, set explicit timeout values:
bash
export ALIBABA_CLOUD_CONNECT_TIMEOUT=10
export ALIBABA_CLOUD_READ_TIMEOUT=30
  • ALIBABA_CLOUD_CONNECT_TIMEOUT=10
    : fail fast on network connect issues.
  • ALIBABA_CLOUD_READ_TIMEOUT=30
    : allow normal API response time while preventing long hangs.
  • If a timeout occurs, treat it as transient and apply the retry logic above.
执行任何API命令前,设置明确的超时值:
bash
export ALIBABA_CLOUD_CONNECT_TIMEOUT=10
export ALIBABA_CLOUD_READ_TIMEOUT=30
  • ALIBABA_CLOUD_CONNECT_TIMEOUT=10
    :网络连接问题时快速失败。
  • ALIBABA_CLOUD_READ_TIMEOUT=30
    :预留正常API响应时间,同时避免长时间挂起。
  • 如果发生超时,视为瞬时错误,应用上述重试逻辑。

Service Not Activated

服务未激活

If Step 1 (
DescribeInternetOpenStatistic
) returns all zeros or an error indicating the service is not activated:
  1. Inform the user: "Cloud Firewall service is not activated or no public assets exist. Please activate it at https://yundun.console.aliyun.com/?p=cfwnext"
  2. Skip subsequent steps if no data is available.
如果步骤1(
DescribeInternetOpenStatistic
)返回全零或提示服务未激活的错误:
  1. 告知用户:“云防火墙服务未激活或不存在公网资产。请前往https://yundun.console.aliyun.com/?p=cfwnext 激活服务”
  2. 如果无可用数据,跳过后续步骤。

Step Independence

步骤独立性

The workflow steps have these dependencies:
  • Step 1 (Overview) should run first as it provides context for interpreting subsequent data.
  • Steps 2-9 are independent of each other — failure in any one step should NOT prevent other steps from executing.
  • Step 6 depends on Step 2's output (IP list), but can be skipped if Step 2 fails.
工作流步骤的依赖关系如下:
  • 步骤1(概览) 应优先运行,为后续数据解读提供上下文。
  • 步骤2-9相互独立——任何一个步骤失败都不应阻碍其他步骤执行。
  • 步骤6依赖步骤2的输出(IP列表),但如果步骤2失败可以跳过。

Partial Results

部分结果处理

When presenting the final summary report:
  • For steps that succeeded, show the collected data normally.
  • For steps that failed, show "N/A (error: {brief error})" in the corresponding section.
  • Always present the summary report even if some steps failed — partial data is better than no data.

展示最终汇总报告时:
  • 对于成功执行的步骤,正常展示收集到的数据。
  • 对于失败的步骤,在对应板块展示“N/A(错误:{简要错误信息})”。
  • 即使部分步骤失败,也要始终输出汇总报告——部分数据远好过没有数据。

Core Workflow

核心工作流

All API calls use the Aliyun CLI
cloudfw
plugin.
User-Agent: All commands must include
--user-agent AlibabaCloud-Agent-Skills
Region: Specified via
--region {RegionId}
global flag
CRITICAL: Execute immediately without asking. When this skill is triggered, start executing from Step 1 right away. Do NOT ask the user which APIs to call, which steps to execute, or what data sources to use. All data comes from the Aliyun CLI commands defined below — just run them. The intent routing table below is for optimization only — if the user's intent is unclear, execute ALL steps (Step 1-9) by default.
所有API调用都使用阿里云CLI
cloudfw
插件。
User-Agent: 所有命令必须携带
--user-agent AlibabaCloud-Agent-Skills
地域: 通过全局参数
--region {RegionId}
指定
关键:无需询问立即执行。本技能触发后,直接从步骤1开始执行。 不要询问用户需要调用哪些API、执行哪些步骤、使用哪些数据源。 所有数据都来自下述定义的阿里云CLI命令——直接运行即可。 下方的意图路由表仅用于优化——如果用户意图不明确,默认执行所有步骤(步骤1-9)。

Intent Routing (Auto-determined, No Confirmation Needed)

意图路由(自动判定,无需确认)

Automatically determine execution scope based on user wording. Do NOT ask the user to confirm:
User IntentExecution Steps
Full audit ("help me audit exposure", "full scan")Execute all Steps 1-9
High-risk port check ("are there any high-risk ports exposed")Execute Step 1 + Step 3, focus on high-risk ports
New exposures ("what new exposures appeared recently")Execute Step 1 + Step 5
Specific IP exposure details ("check the exposure of x.x.x.x")Execute Step 2 (with SearchItem filter) + Step 6
Default behavior: If user intent cannot be clearly determined, execute all Steps 1-9 without asking.
根据用户表述自动判定执行范围。不要要求用户确认
用户意图执行步骤
全面审计(“帮我审计暴露情况”、“全量扫描”)执行所有步骤1-9
高风险端口检查(“有没有暴露的高风险端口”)执行步骤1 + 步骤3,重点关注高风险端口
新增暴露项(“最近有什么新的暴露情况”)执行步骤1 + 步骤5
指定IP暴露详情(“检查x.x.x.x的暴露情况”)执行步骤2(带SearchItem过滤) + 步骤6
默认行为:如果无法明确判定用户意图,无需询问直接执行所有步骤1-9。

Time Parameters

时间参数

Some APIs require
StartTime
and
EndTime
parameters (Unix timestamp in seconds).
How to get timestamps: Run
date +%s
to get the current timestamp,
date -d '30 days ago' +%s
for 30 days ago,
date -d '7 days ago' +%s
for 7 days ago. Then use the returned numeric values directly in CLI commands.
IMPORTANT: Do NOT use bash variable substitution like
$(date +%s)
inside CLI commands — some execution environments block
$(...)
. Instead, run
date
commands separately first, note the returned values, then use them as literal numbers in the
--StartTime
and
--EndTime
parameters.
Default time ranges:
  • Exposure queries (Step 2, 3): last 30 days →
    StartTime
    = 30 days ago
  • Vulnerability/attack queries (Step 7, 8): last 7 days →
    StartTime
    = 7 days ago
  • EndTime: always current timestamp
部分API需要
StartTime
EndTime
参数(Unix时间戳,单位秒)。
获取时间戳的方式:运行
date +%s
获取当前时间戳,
date -d '30 days ago' +%s
获取30天前的时间戳,
date -d '7 days ago' +%s
获取7天前的时间戳。然后将返回的数值直接填入CLI命令中。
重要:不要在CLI命令中使用
$(date +%s)
这类bash变量替换——部分执行环境会屏蔽
$(...)
语法。请先单独运行
date
命令,记录返回的值,然后将其作为字面量填入
--StartTime
--EndTime
参数中。
默认时间范围:
  • 暴露查询(步骤2、3):过去30天 →
    StartTime
    = 30天前
  • 漏洞/攻击查询(步骤7、8):过去7天 →
    StartTime
    = 7天前
  • EndTime:始终为当前时间戳

Step 1: Exposure Statistics Overview

步骤1:暴露统计概览

Retrieve overall public network exposure data. This is the starting point for subsequent analysis.
bash
aliyun cloudfw DescribeInternetOpenStatistic \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeInternetOpenStatistic
in references/api-analysis.md for response field details.
获取公网暴露整体数据,这是后续分析的起点。
bash
aliyun cloudfw DescribeInternetOpenStatistic \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeInternetOpenStatistic
说明。

Step 2: Exposed IP Details

步骤2:暴露IP详情

List all IP addresses exposed to the public network and their risk information.
bash
aliyun cloudfw DescribeInternetOpenIp \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeInternetOpenIp
in references/api-analysis.md for response field details. Pagination: Check
PageInfo.TotalCount
. If it exceeds
PageSize
, increment
CurrentPage
to fetch more.
列出所有暴露到公网的IP地址及其风险信息。
bash
aliyun cloudfw DescribeInternetOpenIp \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeInternetOpenIp
说明。 分页:检查
PageInfo.TotalCount
,如果超过
PageSize
,递增
CurrentPage
获取更多数据。

Step 3: Exposed Port Details

步骤3:暴露端口详情

List all exposed ports and their details. This is a key step for identifying high-risk exposures.
bash
aliyun cloudfw DescribeInternetOpenPort \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeInternetOpenPort
in references/api-analysis.md for response field details. Pagination: Check
PageInfo.TotalCount
.
列出所有暴露端口及其详情,这是识别高风险暴露项的核心步骤。
bash
aliyun cloudfw DescribeInternetOpenPort \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeInternetOpenPort
说明。 分页:检查
PageInfo.TotalCount

Step 4: Asset Protection Status

步骤4:资产防护状态

Retrieve the list of all assets protected by the firewall.
bash
aliyun cloudfw DescribeAssetList \
  --CurrentPage 1 \
  --PageSize 50 \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeAssetList
in references/api-analysis.md for response field details. Pagination: Check
TotalCount
.
获取防火墙防护的所有资产列表。
bash
aliyun cloudfw DescribeAssetList \
  --CurrentPage 1 \
  --PageSize 50 \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeAssetList
说明。 分页:检查
TotalCount

Step 5: New Exposures (Last 7 Days)

步骤5:新增暴露项(过去7天)

Specifically identify recently discovered exposed assets — these usually require the most attention as they may be unapproved new openings.
bash
aliyun cloudfw DescribeAssetList \
  --CurrentPage 1 \
  --PageSize 50 \
  --NewResourceTag "discovered in 7 days" \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
专门识别近期发现的暴露资产——这类资产通常最需要关注,因为可能是未经批准的新增开放项。
bash
aliyun cloudfw DescribeAssetList \
  --CurrentPage 1 \
  --PageSize 50 \
  --NewResourceTag "discovered in 7 days" \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills

Step 6: Asset Risk Details

步骤6:资产风险详情

Take the IPs collected from Step 2 (max 20 per call) and retrieve detailed risk reasons. If there are more than 20 IPs, make multiple batched calls.
bash
aliyun cloudfw DescribeAssetRiskList \
  --IpVersion 4 \
  --IpAddrList '["1.2.3.4","5.6.7.8"]' \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeAssetRiskList
in references/api-analysis.md for response field details.
取步骤2收集的IP(每次调用最多20个)获取详细风险原因。如果IP超过20个,分批调用。
bash
aliyun cloudfw DescribeAssetRiskList \
  --IpVersion 4 \
  --IpAddrList '["1.2.3.4","5.6.7.8"]' \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeAssetRiskList
说明。

Step 7: Vulnerability Protection Status

步骤7:漏洞防护状态

Check current vulnerability protection coverage and identify which high-risk vulnerabilities are not yet protected.
bash
aliyun cloudfw DescribeVulnerabilityProtectedList \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeVulnerabilityProtectedList
in references/api-analysis.md for response field details.
检查当前漏洞防护覆盖情况,识别尚未防护的高风险漏洞。
bash
aliyun cloudfw DescribeVulnerabilityProtectedList \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeVulnerabilityProtectedList
说明。

Step 8: Recent Attack Events

步骤8:近期攻击事件

Review intrusion attack events from the last 7 days and cross-reference attack targets with exposure data.
bash
aliyun cloudfw DescribeRiskEventGroup \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --DataType 1 \
  --Direction in \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeRiskEventGroup
in references/api-analysis.md for response field details.
查看过去7天的入侵攻击事件,将攻击目标与暴露数据交叉比对。
bash
aliyun cloudfw DescribeRiskEventGroup \
  --CurrentPage 1 \
  --PageSize 50 \
  --StartTime {StartTime} \
  --EndTime {EndTime} \
  --DataType 1 \
  --Direction in \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeRiskEventGroup
说明。

Step 9: Internet Border ACL Policy

步骤9:互联网边界ACL策略

Review current inbound ACL rules and assess protection coverage.
bash
aliyun cloudfw DescribeControlPolicy \
  --Direction in \
  --CurrentPage 1 \
  --PageSize 50 \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
Refer to
DescribeControlPolicy
in references/api-analysis.md for response field details.

检查当前入站ACL规则,评估防护覆盖情况。
bash
aliyun cloudfw DescribeControlPolicy \
  --Direction in \
  --CurrentPage 1 \
  --PageSize 50 \
  --region {RegionId} \
  --user-agent AlibabaCloud-Agent-Skills
响应字段详情参考references/api-analysis.md中的
DescribeControlPolicy
说明。

Analysis & Report

分析与报告

After collecting data, generate a report in the following structure. Only show sections with actual data; if an API call failed, note "Data retrieval failed for this section" and continue with other analysis.
收集数据后,按照以下结构生成报告。仅展示有实际数据的板块;如果API调用失败,标注“本板块数据获取失败”,然后继续其他分析。

1. Public Network Exposure Overview

1. 公网暴露概览

Display Step 1 statistics in a table:
MetricValueRisk Assessment
Total Exposed Public IPsx
High-Risk IP CountxFlag if > 0
Total Exposed Portsx
High-Risk Port CountxFlag if > 0
Unprotected Port CountxFlag if > 0
Total Exposed Servicesx
High-Risk Service CountxFlag if > 0
SLB Exposed IP Countx
以表格形式展示步骤1的统计数据:
指标数值风险评估
暴露公网IP总数x
高风险IP数量x大于0时标记风险
暴露端口总数x
高风险端口数量x大于0时标记风险
未防护端口数量x大于0时标记风险
暴露服务总数x
高风险服务数量x大于0时标记风险
SLB暴露IP数量x

2. High-Risk Exposure List

2. 高风险暴露列表

Combine data from Step 2 and Step 3, sorted by risk level (high → middle → low).
The following ports should be additionally flagged as high-risk when exposed to the public network, regardless of the API-returned risk level:
  • Management ports: 22(SSH), 23(Telnet), 3389(RDP), 21(FTP)
  • Database ports: 3306(MySQL), 1433(MSSQL), 5432(PostgreSQL)
  • Cache/NoSQL: 6379(Redis), 27017(MongoDB), 9200/9300(Elasticsearch), 11211(Memcached)
  • File sharing: 445(SMB/CIFS), 139(NetBIOS)
  • Management interfaces: 8080, 8443, 9090
Output format:
IP AddressPortServiceRisk LevelRisk ReasonACL StatusRecommended Action
合并步骤2和步骤3的数据,按风险等级排序(高 → 中 → 低)。
以下端口暴露到公网时,无论API返回的风险等级如何,都需额外标记为高风险:
  • 管理端口: 22(SSH), 23(Telnet), 3389(RDP), 21(FTP)
  • 数据库端口: 3306(MySQL), 1433(MSSQL), 5432(PostgreSQL)
  • 缓存/NoSQL: 6379(Redis), 27017(MongoDB), 9200/9300(Elasticsearch), 11211(Memcached)
  • 文件共享: 445(SMB/CIFS), 139(NetBIOS)
  • 管理接口: 8080, 8443, 9090
输出格式:
IP地址端口服务风险等级风险原因ACL状态建议操作

3. New Exposure Discoveries (Last 7 Days)

3. 新增暴露发现(过去7天)

Display assets discovered in Step 5:
IP AddressDiscovery TimeResource TypeInstance NameProtection StatusRisk Level
If no new exposures were found, state "No new exposed assets discovered in the last 7 days".
展示步骤5发现的资产:
IP地址发现时间资源类型实例名称防护状态风险等级
如果未发现新增暴露项,说明“过去7天未发现新的暴露资产”。

4. Vulnerability Correlation Analysis

4. 漏洞关联分析

Combine Step 7 and Step 8:
  1. High-Risk Vulnerability List: List vulnerabilities with VulnLevel=high, especially flagging those without protection enabled
  2. Attack Event Statistics: Summarize attack events from the last 7 days by attack type, correlating with attacked exposed IPs
  3. Cross-Analysis: Identify exposed assets that simultaneously have high-risk vulnerabilities AND have been attacked — these are the most urgent
合并步骤7和步骤8的数据:
  1. 高风险漏洞列表:列出VulnLevel=high的漏洞,重点标记未开启防护的漏洞
  2. 攻击事件统计:按攻击类型汇总过去7天的攻击事件,与被攻击的暴露IP关联
  3. 交叉分析:识别同时存在高风险漏洞被攻击过的暴露资产——这类资产优先级最高

5. Exposure Remediation Recommendations

5. 暴露修复建议

Generate specific recommendations based on actual data, sorted by priority. Each recommendation includes: Risk Description, Impact Scope, Recommended Action.
基于实际数据生成具体建议,按优先级排序。每条建议包含:风险描述影响范围建议操作

P0 — Critical (Immediate Action)

P0 — 紧急(立即处理)

  • Database ports (3306/5432/6379/27017/1433/9200) exposed to public network → Close public access or strictly restrict source IPs via ACL
  • Management ports (22/3389/23) without ACL protection → Add ACL restricting to bastion host/office network IPs
  • Exposed assets with high-risk vulnerabilities that have been attacked → Immediately enable IPS protection and virtual patches
  • 数据库端口(3306/5432/6379/27017/1433/9200)暴露到公网 → 关闭公网访问,或通过ACL严格限制源IP
  • 管理端口(22/3389/23)无ACL防护 → 添加ACL限制为仅堡垒机/办公网IP可访问
  • 存在高风险漏洞且已被攻击的暴露资产 → 立即开启IPS防护和虚拟补丁

P1 — High (Within 24 Hours)

P1 — 高优先级(24小时内处理)

  • Exposed services with known high-risk vulnerabilities but no virtual patches enabled → Enable virtual patches
  • Unprotected ports with external traffic → Add ACL policies
  • SMB(445)/NetBIOS(139) exposed → Close or restrict access
  • 存在已知高风险漏洞但未开启虚拟补丁的暴露服务 → 开启虚拟补丁
  • 有外部流量访问的未防护端口 → 添加ACL策略
  • SMB(445)/NetBIOS(139)暴露 → 关闭或限制访问

P2 — Medium (This Week)

P2 — 中优先级(本周内处理)

  • New exposed assets not yet approved → Confirm business necessity; close if unnecessary
  • Medium-risk ports exposed → Evaluate business requirements, restrict access sources
  • 尚未经过审批的新增暴露资产 → 确认业务必要性,非必要则关闭
  • 暴露的中风险端口 → 评估业务需求,限制访问源

P3 — Low (Periodic Review)

P3 — 低优先级(定期巡检)

  • Low-risk ports exposed → Include in periodic review
  • ACL rules with zero hit rate → Evaluate whether they can be cleaned up
Note: For any step that failed, show "N/A (error: {brief error})" for that section's data fields, and list all errors in the bottom section.

  • 暴露的低风险端口 → 纳入定期巡检范围
  • 命中次数为0的ACL规则 → 评估是否可以清理
注意:对于任何失败的步骤,对应板块的数据字段展示“N/A(错误:{简要错误信息})”,并在底部板块列出所有错误。

Success Verification

成功验证

See references/verification-method.md for detailed verification steps.
Quick verification: If all CLI commands return valid JSON responses without error codes, the skill executed successfully.

详细验证步骤参考references/verification-method.md
快速验证:如果所有CLI命令都返回有效JSON响应,无错误代码,说明技能执行成功。

API and Command Tables

API与命令对照表

Use references/related-apis.md as the single source of truth for API tables and command mappings.

API表和命令映射的唯一可信来源为references/related-apis.md

Best Practices

最佳实践

  1. Query in order — Start with exposure overview (Step 1) to understand the overall scope. If all values are zero, the service may not be activated or there are no public assets.
  2. Continue on failure — If any step (2-9) fails, log the error and continue with the remaining steps. Always produce a report with whatever data was collected.
  3. Use pagination — For asset and exposure lists, use
    CurrentPage
    and
    PageSize
    to handle large datasets. Default to PageSize=50. If
    TotalCount
    exceeds
    PageSize
    , iterate through all pages.
  4. Time range selection — For exposure queries, default to last 30 days. For attack/vulnerability queries, default to last 7 days. Use Unix timestamps in seconds. Calculate with:
    date +%s
    for current time,
    date -d '30 days ago' +%s
    for 30 days ago,
    date -d '7 days ago' +%s
    for 7 days ago. Run these commands separately, then use the returned values as literal numbers in
    --StartTime
    and
    --EndTime
    . Do NOT use
    $(...)
    substitution inside CLI commands.
  5. Region awareness — Cloud Firewall only has two regions:
    cn-hangzhou
    (mainland China) and
    ap-southeast-1
    (Hong Kong/overseas). Default to
    cn-hangzhou
    unless user specifies otherwise.
  6. Batch IP lookups — Step 6 (
    DescribeAssetRiskList
    ) accepts max 20 IPs per call. If more IPs are collected from Step 2, batch them into groups of 20.
  7. Rate limiting — Space API calls to avoid throttling. If you receive a
    Throttling.User
    error, wait 3 seconds and retry.
  8. Security — NEVER expose, log, echo, or display AK/SK values.
  9. Retry on transient errors — For network timeouts or 5xx errors, retry up to 2 times with a 3-second delay.
  10. Explicit timeout config — Always set
    ALIBABA_CLOUD_CONNECT_TIMEOUT=10
    and
    ALIBABA_CLOUD_READ_TIMEOUT=30
    before running workflow commands.
  11. Least network access — Only allow Aliyun CLI access to Cloud Firewall OpenAPI endpoints; do not access other external domains or VPC/internal resources.
  1. 按顺序查询——从暴露概览(步骤1)开始了解整体范围。如果所有值都为0,可能是服务未激活或不存在公网资产。
  2. 失败时继续执行——如果步骤2-9中任意步骤失败,记录错误后继续执行剩余步骤。始终基于收集到的所有数据生成报告。
  3. 使用分页——对于资产和暴露列表,使用
    CurrentPage
    PageSize
    处理大量数据集。默认PageSize=50。如果
    TotalCount
    超过
    PageSize
    ,遍历所有页面。
  4. 时间范围选择——暴露查询默认取过去30天,攻击/漏洞查询默认取过去7天。使用秒级Unix时间戳。计算方式:
    date +%s
    获取当前时间,
    date -d '30 days ago' +%s
    获取30天前时间,
    date -d '7 days ago' +%s
    获取7天前时间。单独运行这些命令,然后将返回的值作为字面量填入
    --StartTime
    --EndTime
    。不要在CLI命令中使用
    $(...)
    替换。
  5. 地域感知——云防火墙仅有两个地域:
    cn-hangzhou
    (中国内地)和
    ap-southeast-1
    (中国香港/境外)。除非用户另有说明,默认使用
    cn-hangzhou
  6. 批量IP查询——步骤6(
    DescribeAssetRiskList
    )每次调用最多接受20个IP。如果步骤2收集的IP更多,按20个一组分批调用。
  7. 限流处理——控制API调用间隔避免被限流。如果收到
    Throttling.User
    错误,等待3秒后重试。
  8. 安全要求——绝对不要暴露、记录、回显或展示AK/SK值。
  9. 瞬时错误重试——对于网络超时或5xx错误,最多重试2次,每次间隔3秒。
  10. 显式超时配置——运行工作流命令前,始终设置
    ALIBABA_CLOUD_CONNECT_TIMEOUT=10
    ALIBABA_CLOUD_READ_TIMEOUT=30
  11. 最小网络访问——仅允许阿里云CLI访问云防火墙OpenAPI端点,不要访问其他外部域名或VPC/内部资源。

Output Desensitization

输出脱敏

When printing analysis results, mask sensitive identifiers by default:
  • IP addresses: keep first segments only (example:
    203.0.x.x
    ,
    10.23.x.x
    ).
  • Instance IDs: keep prefix and last 4 chars only (example:
    i-abc***9f2d
    ).
  • Account identifiers / UID: keep last 4 digits only.
  • Do not print raw tokens, credential material, local config file content, or full internal network topology.
If the user explicitly asks for full values, confirm necessity first and still avoid exposing secrets.

打印分析结果时,默认脱敏敏感标识符:
  • IP地址:仅保留前两段(示例:
    203.0.x.x
    10.23.x.x
    )。
  • 实例ID:仅保留前缀和最后4位(示例:
    i-abc***9f2d
    )。
  • 账户标识符/UID:仅保留最后4位。
  • 不要打印原始令牌、凭证材料、本地配置文件内容或完整内网拓扑。
如果用户明确要求获取完整值,先确认必要性,仍需避免泄露机密信息。

Reference Links

参考链接

ReferenceDescription
references/related-apis.mdComplete API table with parameters
references/ram-policies.mdRequired RAM permissions and policy JSON
references/verification-method.mdStep-by-step verification commands
references/acceptance-criteria.mdCorrect/incorrect usage patterns
references/cli-installation-guide.mdAliyun CLI installation guide
references/api-analysis.mdDetailed API parameter and response documentation
参考文档说明
references/related-apis.md完整API参数对照表
references/ram-policies.md所需RAM权限和策略JSON
references/verification-method.md分步验证命令
references/acceptance-criteria.md正确/错误使用示例
references/cli-installation-guide.mdAliyun CLI安装指南
references/api-analysis.md详细API参数和响应文档