漏洞简介
2022年12月22日,Apache 官方公告发布 ShardingSphere-Proxy 5.3.0 之前版本存在身份绕过漏洞(CVE-2022-45347)。当 ShardingSphere-Proxy 使用 MySQL 作为后端数据库时,由于 ShardingSphere-Proxy 在客户端认证失败后没有完全清理数据库会话信息,攻击者可利用未关闭的会话信息绕过 ShardingSphere-Proxy 的 MySQL 身份验证,执行任意 sql 命令。
漏洞分析
Apache ShardingSphere 是一个可将任意数据库转换为分布式数据库的生态系统,ShardingSphere-Proxy 是一个支持 MySQL 和 PostgreSQL 的数据库代理,提供了一个数据库服务器,并封装了数据库二进制协议来支持异构语言。
以 Apache ShardingSphere 5.2.1 版本为例, 用户可通过配置连接 ShardingSphere-Proxy 操作后端 MySQL 数据库:
(ShardingSphere-Proxy 应用场景示意图)
在该漏洞中存在的交互过程如下:
(MySQL client 与 ShardingSphere-Proxy 交互图)
以Python为例,当使用错误的账号密码通过 MySQL连接库(如pymysql)连接 ShardingSphere-Proxy:
import pymysql
# MySQL client 连接 ShardingSphere-Proxy
db = pymysq