pgadmin4 远程代码执行漏洞复发 (CVE-2022-4223) - 漏洞分析
最编程
2024-03-26 22:04:05
...
就是os.path.abspath(os.path.join(...))可以访问远程UNC路径的文件,subprocess.getoutput() 函数触发执行文件。
漏洞代码
@blueprint.route("/validate_binary_path",
endpoint="validate_binary_path",
methods=["POST"]) # [1]
def validate_binary_path():
"""
This function is used to validate the specified utilities path by
running the utilities with there versions.
"""
data = None
if hasattr(request.data, 'decode'):
data = request.data.decode('utf-8')
if data != '':
data = json.loads(data)
version_str = ''
if 'utility_path' in data and data['utility_path'] is not None: # [2]
# Check if "$DIR" present in binary path
binary_path = replace_binary_path(data['utility_path']) # [3]
for utility in UTILITIES_ARRAY: # [4]
full_path = os.path.abspath(
os.path.join(binary_path,
(utility if os.name != 'nt' else
(utility + '.exe')))) # [5]
try:
# Get the output of the '--version' command
version_string = \
subprocess.getoutput('"{0}" --version'.format(full_path)) # [6]
# Get the version number by splitting the result string
version_string.split(") ", 1)[1].split('.', 1)[0]
...
HTTP 路由处理程序被定义为/validate_binary_path触发代码的相应 URI 部分。该URI触发的代码要求是POST请求。request.data被读取[2] 处。不用管[3] 中的功能,自己可以检查“为什么”。但是在处,一个常量 UTILITIES_ARRAY
限制了我们稍后流入subprocess调用的最终输入。从constants.py可知UTILITIES_ARRAY = ['pg_dump', 'pg_dumpall', 'pg_restore', 'psql']。此时我们仍然控制binary_path变量,可以控制路径,但不能控制最终接收器中执行的文件名。此外,可以已经观察到该flask_login模块提供了一个@login_required注释(检查网络应用程序的其他路由)以检查经过身份验证的上下文。这里缺少这一点,没有进行身份验证,所以能够未经身份验证来进行RCE。
上一篇: 结构体-C语言
推荐阅读
-
CVE-2020-0674:Internet Explorer 远程代码执行漏洞通知
-
Fastjson 1.2.47 远程命令执行漏洞 复制分析环境
-
CVE-2023-3519:Citrix ADC/Gateway 远程代码执行漏洞通告
-
pgadmin4 远程代码执行漏洞复发 (CVE-2022-4223) - 漏洞分析
-
关于 log4j2 远程代码执行漏洞的详细重现过程
-
Apache Log4j2 远程代码执行漏洞学习
-
Apache Log4j2 远程代码执行漏洞 - 故障排除和修复建议
-
如何看待 Apache Log4j 2 远程代码执行漏洞?免费动手带你重现它!
-
关于 Apache log4j2 远程代码执行漏洞 (CVE-2021-44228) 的文章
-
修复 Apache Log4j2 远程代码执行漏洞的步骤