Real World CTF 5th writeup
2023-5-17 00:0:0 Author: bestwing.me(查看原文) 阅读量:17 收藏

TL;DR

这次 RWCTF 比赛我一共出了两个题: 「Printer2」 和 「Hardened Redis」。至于为什么今天才在博客更新这个Writeup一个原因就是 Pritner2 相关的漏洞今天终于发布了正式补丁。

Printer2

这个是漏洞存在于是 OpenPrinting 项目里的一个 cups-filters 下的 Backend Error Handler (beh)。这里是关于 beh 的介绍

漏洞点位与 cups-filters/backed/beh.c#L288

1
2
3
4
5
6
7
8
9
 
snprintf(cmdline, sizeof(cmdline),
"%s/backend/%s '%s' '%s' '%s' '%s' '%s' %s",
cups_serverbin, scheme, argv[1], argv[2], argv[3],
...
(argc == 6 ? "1" : argv[4]),
argv[5], filename);
...
retval = system(cmdline) >> 8;

可以看到这里有一个明显的命令注入, 当用户控制 user 或者 title 字段的时候可以造成任意命令执行。更详细的细节可以看官方公告:

report a command inject Vulnerabilities in cups-filters

Hardened Redis

这是题目考点是在较高版本的情况下在有访问 Redis 的情况下如何获取 Redis 所在系统 shell 权限。 在高版本的 Redis 已经不能使用主从复制来获取 shell了(印象中),另外我也禁用了一些 Redis 的方法。 但是由于对 Redis 的熟知程度不够, 其次也是去年参加 CTF 少了, 被 2022 Spring GoN Open Qual CTF 的一个 Redis 题的解法非预期了。

下次有机会可以和大家详细分享下这个解法。

这里接着讲我的预期解法,讲到 Redis , 如果大家有印象,应该会想到 CVE-2022-0543 。 当时这个漏洞影响了 Debian 系列的 Linux 发行版系统的包管理器所安装的 Redis 。因为 Debian 系列由于打包问题,Redis在Lua解析器初始化后,package变量没有被正确清除,导致攻击者可以利用它来进行Lua沙箱逃逸,从而执行任意系统命令。

这个时候我们注意到了这 Debian 系列用的 Redis 所使用的 lua 解析器是 lua 5.1 , 而且是存在一个 2015 年漏洞的 lua 解析器,虽然这个漏洞在 2015 年就被 Redis官方修复了, 但是 lua 5.1 解析器并没有修复。

2015 年这个漏洞是 CVE-2015-4335, 另外 HN 评论区当时也提到了这个问题,

I think this is still ‘broken’ because Redis have applied custom patches to the )

虽然当时我也给 ubuntu 和 Debian 发了邮件提醒了这件事,但是他们的回复看起来是不是很想单独修复。

image-20230518002900794

进一步的漏洞利用与分析可以参考我 chu 师父 的博客, Redis CVE-2015-4335分析 , 我就不赘述了。 没想到隔了这么久还是依然能受到 chu 师父的照顾。

cups-filters/backed/beh.c#L288

report a command inject Vulnerabilities in cups-filters

2022 Spring GoN Open Qual CTF

I think this is still ‘broken’ because Redis have applied custom patches to the … | Hacker News (ycombinator.com)

disable loading lua bytecode

Redis CVE-2015-4335分析


文章来源: https://bestwing.me/RWCTF-5th-Writeup.html
如有侵权请联系:admin#unsafe.sh