alibabacloud-cfw-exposure-detection
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePublic Network Exposure Detection & Analysis
公网暴露检测与分析
⚠️ MANDATORY EXECUTION RULES — READ BEFORE DOING ANYTHING:
- DO NOT search for log files, security data, or any files in the workspace. There are none.
- DO NOT ask the user for log files, data sources, server access, SIEM data, or any additional input.
- DO NOT attempt to SSH, access, or connect to any server or IP address.
- The ONLY way to get data is by running
CLI commands as defined in the Core Workflow section below.aliyun cloudfw ...- Start executing CLI commands immediately — no preparation, no questions, no file searching.
⚠️ 强制执行规则——操作前请务必阅读:
- 不要搜索工作区中的日志文件、安全数据或任何文件。不存在此类文件。
- 不要向用户索要日志文件、数据源、服务器访问权限、SIEM数据或任何额外输入。
- 不要尝试SSH、访问或连接任何服务器或IP地址。
- 获取数据的唯一方式是运行下文核心工作流部分定义的
CLI命令。aliyun cloudfw ...- 立即开始执行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 AnalysisCapability Level: Query (read-only)
Data Source: All data is obtained exclusively through Aliyun CLI commands (). 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.
aliyun cloudfw ...通过阿里云云防火墙OpenAPI对公网暴露情况进行全面扫描和分析,识别高风险暴露项并生成修复建议。
架构:
云防火墙服务 → 互联网边界防火墙 → 暴露检测 + 风险评估 + ACL策略分析能力级别: 查询(只读)
数据源: 所有数据仅通过阿里云CLI命令()获取。无需日志文件、数据库、服务器访问权限、SIEM——仅需CLI命令。不要搜索工作区文件,不要向用户索要任何内容,直接运行命令即可。
aliyun cloudfw ...Network Access Boundary
网络访问边界
This skill follows least-privilege network access:
- Allowed network target: Alibaba Cloud OpenAPI endpoints resolved by Aliyun CLI for only (
cloudfw).*.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:
- Exposure Overview — Total exposed IPs, ports, services, and risk statistics
- Exposed IP Analysis — Detailed list of exposed public IPs with risk levels and services
- Exposed Port Analysis — Detailed list of exposed ports with risk assessment
- Asset Protection Status — Firewall protection coverage of exposed assets
- New Exposure Detection — Recently discovered exposures in the last 7 days
- Risk Assessment — Detailed risk reasons per IP
- Vulnerability Correlation — Cross-reference with vulnerability protection and attack events
- ACL Policy Review — Internet border ACL rule coverage
本技能遵循最小权限网络访问原则:
- 允许访问的网络目标:仅阿里云CLI解析的云防火墙对应的阿里云OpenAPI端点(
cloudfw)。*.aliyuncs.com - 禁止访问的目标:任何非阿里云的外部网站、任意公开API、VPC私有IP资源、ECS/数据库主机、直接socket/HTTP请求。
- 禁止操作:SSH、向无关域名发起curl/wget请求、扫描私有网络、任何直接访问内网资产的行为。
核心能力:
- 暴露概览——暴露IP、端口、服务总数及风险统计
- 暴露IP分析——暴露公网IP的详细列表,附带风险等级和服务信息
- 暴露端口分析——暴露端口的详细列表,附带风险评估结果
- 资产防护状态——暴露资产的防火墙防护覆盖情况
- 新增暴露检测——过去7天内新发现的暴露项
- 风险评估——每个IP的详细风险原因
- 漏洞关联——与漏洞防护和攻击事件的交叉比对
- ACL策略检查——互联网边界ACL规则覆盖情况
Prerequisites
前置条件
Pre-check: Aliyun CLI >= 3.3.1 required Runto verify >= 3.3.1. If not installed or version too low, seealiyun versionfor installation instructions. Then [MUST] runreferences/cli-installation-guide.mdto enable automatic plugin installation.aliyun configure set --auto-plugin-install true
前置检查:要求Aliyun CLI版本 >= 3.3.1 运行确认版本 >= 3.3.1。如果未安装或版本过低,参考aliyun version中的安装说明操作。 随后[必须]运行references/cli-installation-guide.md开启插件自动安装功能。aliyun configure set --auto-plugin-install true
Authentication
身份认证
Pre-check: Alibaba Cloud Credentials RequiredSecurity 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
with literal credential valuesaliyun configure set- ONLY use
to check credential statusaliyun configure listbashaliyun configure listCheck the output for a valid profile (AK, STS, or OAuth identity).If no valid profile exists, STOP here.
- Obtain credentials from Alibaba Cloud Console
- Configure credentials outside of this session (via
in terminal or environment variables in shell profile)aliyun configure- Return and re-run after
shows a valid profilealiyun configure list
前置检查:需要阿里云凭证安全规则:
- 任何情况下绝对不要读取、回显、打印、输出或展示AK/SK的值
- 绝对不要要求用户在对话或命令行中直接输入AK/SK
- 绝对不要在
命令中直接使用明文凭证值aliyun configure set- 仅可使用
检查凭证状态aliyun configure listbashaliyun configure list检查输出中是否存在有效配置(AK、STS或OAuth身份)。如果不存在有效配置,请在此停止。
- 从阿里云控制台获取凭证
- 在本次会话之外配置凭证(通过终端的
命令或shell配置文件中的环境变量)aliyun configure- 待
显示有效配置后,返回重新运行aliyun configure list
RAM Policy
RAM权限策略
[MUST] RAM Permission Pre-check: Before executing any commands, verify the current user has the required permissions.
- Use
skill to get current user's permissionsram-permission-diagnose- Compare against
references/ram-policies.md- 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权限前置检查: 执行任何命令前,验证当前用户拥有所需权限。
- 使用
技能获取当前用户的权限ram-permission-diagnose- 与
中的要求比对references/ram-policies.md- 如果缺失任何权限,终止流程并提示用户
所需最低权限——完整策略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 Name | Required/Optional | Description | Default Value |
|---|---|---|---|
| RegionId | Required | Alibaba Cloud region for Cloud Firewall. Only two values: | |
| PageSize | Optional | Number of items per page for paginated APIs | 50 (use without asking) |
| CurrentPage | Optional | Page number for paginated APIs | 1 (use without asking) |
| StartTime | Optional | Start 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) |
| EndTime | Optional | End time for time-range queries (Unix timestamp in seconds) | Current time (use without asking) |
重要:参数确认——执行任何命令或API调用前,检查用户的请求中是否已经提供了必要参数。
- 如果用户请求明确提到参数值(例如“检查杭州地域的暴露情况”代表RegionId=cn-hangzhou),直接使用该值无需确认。
- 对于有合理默认值的可选参数(PageSize、CurrentPage、时间范围),直接使用默认值即可,除非用户另有说明。
- 不要重复询问用户已经明确说明的参数。
| 参数名称 | 必填/可选 | 说明 | 默认值 |
|---|---|---|---|
| RegionId | 必填 | 云防火墙对应的阿里云地域。仅两个可选值: | |
| 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:
- If the call fails with a transient error (network timeout, throttling ,
Throttling.User, HTTP 500/502/503), retry up to 2 times with a 3-second delay between retries.ServiceUnavailable - If the call fails with a permanent error (e.g., ,
InvalidParameter,Forbidden), do NOT retry. Record the error and move on.InvalidAccessKeyId - After all retries are exhausted, record "[Step X] Failed: {error message}" and continue to the next step.
每个API调用的处理规则:
- 如果调用返回瞬时错误(网络超时、限流、
Throttling.User、HTTP 500/502/503),最多重试2次,每次重试间隔3秒。ServiceUnavailable - 如果调用返回永久错误(例如、
InvalidParameter、Forbidden),不要重试。记录错误后继续执行下一步。InvalidAccessKeyId - 重试次数用尽后,记录“[步骤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- : fail fast on network connect issues.
ALIBABA_CLOUD_CONNECT_TIMEOUT=10 - : allow normal API response time while preventing long hangs.
ALIBABA_CLOUD_READ_TIMEOUT=30 - 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 - :预留正常API响应时间,同时避免长时间挂起。
ALIBABA_CLOUD_READ_TIMEOUT=30 - 如果发生超时,视为瞬时错误,应用上述重试逻辑。
Service Not Activated
服务未激活
If Step 1 () returns all zeros or an error indicating the service is not activated:
DescribeInternetOpenStatistic- 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"
- Skip subsequent steps if no data is available.
如果步骤1()返回全零或提示服务未激活的错误:
DescribeInternetOpenStatistic- 告知用户:“云防火墙服务未激活或不存在公网资产。请前往https://yundun.console.aliyun.com/?p=cfwnext 激活服务”
- 如果无可用数据,跳过后续步骤。
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 plugin.
cloudfwUser-Agent: All commands must include
Region: Specified via global flag
--user-agent AlibabaCloud-Agent-Skills--region {RegionId}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 插件。
cloudfwUser-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 Intent | Execution 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 and parameters (Unix timestamp in seconds).
StartTimeEndTimeHow to get timestamps: Run to get the current timestamp, for 30 days ago, for 7 days ago. Then use the returned numeric values directly in CLI commands.
date +%sdate -d '30 days ago' +%sdate -d '7 days ago' +%sIMPORTANT: Do NOT use bash variable substitution likeinside CLI commands — some execution environments block$(date +%s). Instead, run$(...)commands separately first, note the returned values, then use them as literal numbers in thedateand--StartTimeparameters.--EndTime
Default time ranges:
- Exposure queries (Step 2, 3): last 30 days → = 30 days ago
StartTime - Vulnerability/attack queries (Step 7, 8): last 7 days → = 7 days ago
StartTime - EndTime: always current timestamp
部分API需要和参数(Unix时间戳,单位秒)。
StartTimeEndTime获取时间戳的方式:运行获取当前时间戳,获取30天前的时间戳,获取7天前的时间戳。然后将返回的数值直接填入CLI命令中。
date +%sdate -d '30 days ago' +%sdate -d '7 days ago' +%s重要:不要在CLI命令中使用这类bash变量替换——部分执行环境会屏蔽$(date +%s)语法。请先单独运行$(...)命令,记录返回的值,然后将其作为字面量填入date和--StartTime参数中。--EndTime
默认时间范围:
- 暴露查询(步骤2、3):过去30天 → = 30天前
StartTime - 漏洞/攻击查询(步骤7、8):过去7天 → = 7天前
StartTime - 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-SkillsRefer to in references/api-analysis.md for response field details.
DescribeInternetOpenStatistic获取公网暴露整体数据,这是后续分析的起点。
bash
aliyun cloudfw DescribeInternetOpenStatistic \
--region {RegionId} \
--user-agent AlibabaCloud-Agent-Skills响应字段详情参考references/api-analysis.md中的说明。
DescribeInternetOpenStatisticStep 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-SkillsRefer to in references/api-analysis.md for response field details.
Pagination: Check . If it exceeds , increment to fetch more.
DescribeInternetOpenIpPageInfo.TotalCountPageSizeCurrentPage列出所有暴露到公网的IP地址及其风险信息。
bash
aliyun cloudfw DescribeInternetOpenIp \
--CurrentPage 1 \
--PageSize 50 \
--StartTime {StartTime} \
--EndTime {EndTime} \
--region {RegionId} \
--user-agent AlibabaCloud-Agent-Skills响应字段详情参考references/api-analysis.md中的说明。
分页:检查,如果超过,递增获取更多数据。
DescribeInternetOpenIpPageInfo.TotalCountPageSizeCurrentPageStep 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-SkillsRefer to in references/api-analysis.md for response field details.
Pagination: Check .
DescribeInternetOpenPortPageInfo.TotalCount列出所有暴露端口及其详情,这是识别高风险暴露项的核心步骤。
bash
aliyun cloudfw DescribeInternetOpenPort \
--CurrentPage 1 \
--PageSize 50 \
--StartTime {StartTime} \
--EndTime {EndTime} \
--region {RegionId} \
--user-agent AlibabaCloud-Agent-Skills响应字段详情参考references/api-analysis.md中的说明。
分页:检查。
DescribeInternetOpenPortPageInfo.TotalCountStep 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-SkillsRefer to in references/api-analysis.md for response field details.
Pagination: Check .
DescribeAssetListTotalCount获取防火墙防护的所有资产列表。
bash
aliyun cloudfw DescribeAssetList \
--CurrentPage 1 \
--PageSize 50 \
--region {RegionId} \
--user-agent AlibabaCloud-Agent-Skills响应字段详情参考references/api-analysis.md中的说明。
分页:检查。
DescribeAssetListTotalCountStep 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-SkillsStep 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-SkillsRefer to in references/api-analysis.md for response field details.
DescribeAssetRiskList取步骤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中的说明。
DescribeAssetRiskListStep 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-SkillsRefer to in references/api-analysis.md for response field details.
DescribeVulnerabilityProtectedList检查当前漏洞防护覆盖情况,识别尚未防护的高风险漏洞。
bash
aliyun cloudfw DescribeVulnerabilityProtectedList \
--CurrentPage 1 \
--PageSize 50 \
--StartTime {StartTime} \
--EndTime {EndTime} \
--region {RegionId} \
--user-agent AlibabaCloud-Agent-Skills响应字段详情参考references/api-analysis.md中的说明。
DescribeVulnerabilityProtectedListStep 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-SkillsRefer to in references/api-analysis.md for response field details.
DescribeRiskEventGroup查看过去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中的说明。
DescribeRiskEventGroupStep 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-SkillsRefer to in references/api-analysis.md for response field details.
DescribeControlPolicy检查当前入站ACL规则,评估防护覆盖情况。
bash
aliyun cloudfw DescribeControlPolicy \
--Direction in \
--CurrentPage 1 \
--PageSize 50 \
--region {RegionId} \
--user-agent AlibabaCloud-Agent-Skills响应字段详情参考references/api-analysis.md中的说明。
DescribeControlPolicyAnalysis & 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:
| Metric | Value | Risk Assessment |
|---|---|---|
| Total Exposed Public IPs | x | — |
| High-Risk IP Count | x | Flag if > 0 |
| Total Exposed Ports | x | — |
| High-Risk Port Count | x | Flag if > 0 |
| Unprotected Port Count | x | Flag if > 0 |
| Total Exposed Services | x | — |
| High-Risk Service Count | x | Flag if > 0 |
| SLB Exposed IP Count | x | — |
以表格形式展示步骤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 Address | Port | Service | Risk Level | Risk Reason | ACL Status | Recommended 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 Address | Discovery Time | Resource Type | Instance Name | Protection Status | Risk 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:
- High-Risk Vulnerability List: List vulnerabilities with VulnLevel=high, especially flagging those without protection enabled
- Attack Event Statistics: Summarize attack events from the last 7 days by attack type, correlating with attacked exposed IPs
- Cross-Analysis: Identify exposed assets that simultaneously have high-risk vulnerabilities AND have been attacked — these are the most urgent
合并步骤7和步骤8的数据:
- 高风险漏洞列表:列出VulnLevel=high的漏洞,重点标记未开启防护的漏洞
- 攻击事件统计:按攻击类型汇总过去7天的攻击事件,与被攻击的暴露IP关联
- 交叉分析:识别同时存在高风险漏洞且被攻击过的暴露资产——这类资产优先级最高
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
最佳实践
- 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.
- 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.
- Use pagination — For asset and exposure lists, use and
CurrentPageto handle large datasets. Default to PageSize=50. IfPageSizeexceedsTotalCount, iterate through all pages.PageSize - 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: for current time,
date +%sfor 30 days ago,date -d '30 days ago' +%sfor 7 days ago. Run these commands separately, then use the returned values as literal numbers indate -d '7 days ago' +%sand--StartTime. Do NOT use--EndTimesubstitution inside CLI commands.$(...) - Region awareness — Cloud Firewall only has two regions: (mainland China) and
cn-hangzhou(Hong Kong/overseas). Default toap-southeast-1unless user specifies otherwise.cn-hangzhou - Batch IP lookups — Step 6 () accepts max 20 IPs per call. If more IPs are collected from Step 2, batch them into groups of 20.
DescribeAssetRiskList - Rate limiting — Space API calls to avoid throttling. If you receive a error, wait 3 seconds and retry.
Throttling.User - Security — NEVER expose, log, echo, or display AK/SK values.
- Retry on transient errors — For network timeouts or 5xx errors, retry up to 2 times with a 3-second delay.
- Explicit timeout config — Always set and
ALIBABA_CLOUD_CONNECT_TIMEOUT=10before running workflow commands.ALIBABA_CLOUD_READ_TIMEOUT=30 - Least network access — Only allow Aliyun CLI access to Cloud Firewall OpenAPI endpoints; do not access other external domains or VPC/internal resources.
- 按顺序查询——从暴露概览(步骤1)开始了解整体范围。如果所有值都为0,可能是服务未激活或不存在公网资产。
- 失败时继续执行——如果步骤2-9中任意步骤失败,记录错误后继续执行剩余步骤。始终基于收集到的所有数据生成报告。
- 使用分页——对于资产和暴露列表,使用和
CurrentPage处理大量数据集。默认PageSize=50。如果PageSize超过TotalCount,遍历所有页面。PageSize - 时间范围选择——暴露查询默认取过去30天,攻击/漏洞查询默认取过去7天。使用秒级Unix时间戳。计算方式:获取当前时间,
date +%s获取30天前时间,date -d '30 days ago' +%s获取7天前时间。单独运行这些命令,然后将返回的值作为字面量填入date -d '7 days ago' +%s和--StartTime。不要在CLI命令中使用--EndTime替换。$(...) - 地域感知——云防火墙仅有两个地域:(中国内地)和
cn-hangzhou(中国香港/境外)。除非用户另有说明,默认使用ap-southeast-1。cn-hangzhou - 批量IP查询——步骤6()每次调用最多接受20个IP。如果步骤2收集的IP更多,按20个一组分批调用。
DescribeAssetRiskList - 限流处理——控制API调用间隔避免被限流。如果收到错误,等待3秒后重试。
Throttling.User - 安全要求——绝对不要暴露、记录、回显或展示AK/SK值。
- 瞬时错误重试——对于网络超时或5xx错误,最多重试2次,每次间隔3秒。
- 显式超时配置——运行工作流命令前,始终设置和
ALIBABA_CLOUD_CONNECT_TIMEOUT=10。ALIBABA_CLOUD_READ_TIMEOUT=30 - 最小网络访问——仅允许阿里云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
参考链接
| Reference | Description |
|---|---|
| references/related-apis.md | Complete API table with parameters |
| references/ram-policies.md | Required RAM permissions and policy JSON |
| references/verification-method.md | Step-by-step verification commands |
| references/acceptance-criteria.md | Correct/incorrect usage patterns |
| references/cli-installation-guide.md | Aliyun CLI installation guide |
| references/api-analysis.md | Detailed 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.md | Aliyun CLI安装指南 |
| references/api-analysis.md | 详细API参数和响应文档 |