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

easywebpack-cli目录穿越漏洞 #25

Open
muxishuihan opened this issue Aug 18, 2020 · 9 comments
Open

easywebpack-cli目录穿越漏洞 #25

muxishuihan opened this issue Aug 18, 2020 · 9 comments
Labels

Comments

@muxishuihan
Copy link

你好~ 我发现了easywebpack-cli的一个安全问题,在使用easywebpack-cli并使用-d参数指定了生效目录后,使用"../../"会造成目录穿越问题,能够查看主机中的文件(如数据库连接文件等)。
复现方法:
1、执行 npm i -g easywebpack-cli
2、执行 easy server -d mock -p 8009,-d 指向任意一个目录
3、使用postman或其他工具发包,即可查看文件
image

我并没有查看您的代码来定位问题位置,因此我也不太确定是否是easywebpack-cli引入easywebpack的问题,请见谅。
希望您能够确认问题或及时回复哦~ 多谢

Easywebpack-cli directory traversal vulnerability

Hello~ I found a security problem with easywebpack-cli. After using easywebpack-cli and using the -d parameter to specify the effective directory, using "../../" will cause directory traversal problems. You can view the host Files (such as database connection files, etc.).
Reproduction method:

1.npm i -g easywebpack-cli
2.easy server -d mock -p 8009, -d points to any directory
3.Use postman or other tools to send the request to view the file
(See above for related pictures)

@hubcarl
Copy link
Collaborator

hubcarl commented Aug 27, 2020

这个命令是用于本地开发使用的,需要使用者自己指定目录,目录可以任意指定

@muxishuihan
Copy link
Author

你好,这个命令的主要问题并不是”目录可以任意指定”,而是指定目录后,可以跨目录访问到其他目录下的文件。比如,我执行了easy server -d mock -p 8009,-d /Users/kwai/Desktop/test,一个合理的实现是,我通过http请求只应该能够访问到/Users/kwai/Desktop/test目录下的文件及子目录。但我通过http://xxxxx/../../../../../../etc/passwd,却能够跨目录访问到/etc/passwd文件,这个漏洞的威胁是如果开放的server能够被其他机器访问(如局域网或互联网上的其他机器),访问者可以读取本机中的任意文件。当然我只是指出存在的问题,是否进行处理由您把握哈~

@hubcarl
Copy link
Collaborator

hubcarl commented Aug 28, 2020

@muxishuihan 明白了,这个我处理一下,有兴趣也可以提个 PR 修复

@hubcarl hubcarl added the bug label Aug 28, 2020
@hubcarl
Copy link
Collaborator

hubcarl commented Sep 5, 2020

@muxishuihan 我试了一下, 用 easy server -d test -p 8009 后, 然后访问 http://192.168.1.7:8009/../../easyjs-old/db 并不能访问上层目录内容, 最终获取的 filename 和 filepath 如下:

>>>filepath /easyjs-old/db  /Users/sky/dev/easyteam/easywebpack-cli/test/easyjs-old/db

用 chrome, curl, postman 访问,最终获取文件内容的路径都是上面内容。

看看能够给个完整例子我试试

@hubcarl hubcarl added question and removed bug labels Sep 5, 2020
@muxishuihan
Copy link
Author

muxishuihan commented Sep 5, 2020

@hubcarl 嗨~ 请问您有类似postman或者burpsuite的发包器嘛?浏览器或者curl应该是会自动将http://XXX/../../../../转成http://XXX/,这样就达不到跳转目录的目的啦。我自己使用curl和浏览器测试的结果也和您相同。

ok ,我给您录个像吧

@muxishuihan
Copy link
Author

你好,我已经发送到了您在github登记的个人邮箱 [email protected] 。我个人不是很清楚为什么您使用postman也无法复现该问题。

@hubcarl
Copy link
Collaborator

hubcarl commented Sep 5, 2020

你好,我已经发送到了您在github登记的个人邮箱 [email protected] 。我个人不是很清楚为什么您使用postman也无法复现该问题。

好的,我查看一下

@hubcarl
Copy link
Collaborator

hubcarl commented Sep 5, 2020

@muxishuihan 可以帮忙调试一下,直接修改 node_modules 加一下日志,然后启动项目看看:

目前看可能出现问题是这两个地方:

  • node_modules/node-tool-utils/lib/tool.js#L106, 获取 pathname 带有 /../ 这种,需要替换处理掉
  • node_modules/node-http-server/server/Server.js#767

@muxishuihan
Copy link
Author

@hubcarl 抱歉,这个我可能没法帮上忙。。因为我对node_modules完全不了解。。

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

No branches or pull requests

2 participants