Skywalking SQL注入漏洞 (CVE-2020-9483)开源应对方案:APISIX
字数 936 2025-08-15 21:31:13
Apache SkyWalking SQL注入漏洞(CVE-2020-9483)防护指南
漏洞概述
Apache SkyWalking是一款应用性能监控(APM)系统,用于跟踪分析线上系统的性能,支持TCP、HTTP协议。该漏洞(CVE-2020-9483)影响版本为6.0-6.6和7.0,通过升级到8.0版本可修复此问题。
漏洞细节
- 受影响组件:GraphQL协议接口
- 受影响数据库:H2/MySQL/TiDB作为存储后端时
- 风险等级:SQL注入漏洞,可能导致未授权数据访问
漏洞影响范围
- 受影响版本:
- SkyWalking 6.0至6.6系列
- SkyWalking 7.0系列
- 安全版本:SkyWalking 8.0及以上
应急解决方案
1. 官方修复方案
升级到SkyWalking 8.0版本 - 这是最彻底的解决方案
2. 临时缓解措施
- 接口访问控制:对SkyWalking外网暴露的接口进行安全授权
- WAF防护:部署Web应用防火墙拦截SQL注入请求
基于APISIX的开源防护方案
APISIX是一款基于Nginx/OpenResty的API网关,与SkyWalking同属Apache项目,可提供以下防护功能:
1. 认证授权
使用APISIX插件实现接口访问控制:
- Key-auth插件:通过API密钥进行权限管理
- Basic-auth插件:通过用户名密码进行加密认证
2. SQL注入拦截
使用uri-blocker插件实现SQL注入防护:
插件配置示例
local core = require("apisix.core")
local re_compile = require("resty.core.regex").re_match_compile
local re_find = ngx.re.find
local ipairs = ipairs
local schema = {
type = "object",
properties = {
block_rules = {
type = "array",
items = {
type = "string",
minLength = 1,
maxLength = 4096,
},
uniqueItems = true
},
rejected_code = {
type = "integer",
minimum = 200,
default = 403
},
},
required = {"block_rules"},
}
local plugin_name = "uri-blocker"
local _M = {
version = 0.1,
priority = 2900,
name = plugin_name,
schema = schema,
}
function _M.check_schema(conf)
local ok, err = core.schema.check(schema, conf)
if not ok then
return false, err
end
local block_rules = {}
for i, re_rule in ipairs(conf.block_rules) do
local ok, err = re_compile(re_rule,"j")
if not ok then
return false, err
end
block_rules[i] = re_rule
end
conf.block_rules_concat = core.table.concat(block_rules, "|")
core.log.info("concat block_rules: ", conf.block_rules_concat)
return true
end
function _M.rewrite(conf, ctx)
core.log.info("uri: ", ctx.var.request_uri)
local from = re_find(ctx.var.request_uri, conf.block_rules_concat, "jo")
if from then
core.response.exit(conf.rejected_code)
end
end
return _M
SQL注入检测规则示例
"select.+(from|limit)""(?:(union(.*?)select))""having"
3. APISIX配置方法
启用防护规则:
curl -i http://127.0.0.1:9080/apisix/admin/routes/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
-X PUT -d '{
"uri": "/*",
"plugins": {
"uri-blocker": {
"block_rules": ["select.+(from|limit)", "(?:(union(.*?)select))", "having"]
}
},
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}
}'
升级后关闭防护:
curl http://127.0.0.1:9080/apisix/admin/routes/1 \
-H 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
-X PUT -d '{
"uri": "/*",
"upstream": {
"type": "roundrobin",
"nodes": {
"127.0.0.1:1980": 1
}
}
}'
总结
对于无法立即升级SkyWalking的环境,使用APISIX网关提供了一种灵活、低成本的临时防护方案。该方案不仅适用于CVE-2020-9483,也可作为其他类似安全问题的快速响应模式。
方案优势
- 无需立即升级核心系统
- 提供多层防护(认证+注入检测)
- 配置灵活,可快速启用/禁用
- 开源解决方案,成本可控