Goal Reached Thanks to every supporter — we hit 100%!

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-29440 PoC — Grav 代码注入漏洞

Source
Associated Vulnerability
Title:Grav 代码注入漏洞 (CVE-2021-29440)
Description:Grav是一套可扩展的用于个人博客、小型内容发布平台和单页产品展示的CMS(内容管理系统)。 Grav 存在代码注入漏洞,攻击者可利用该漏洞任意代码执行和提升实例上的特权。
Description
Unsafe Twig processing of static pages leading to RCE in Grav CMS 1.7.10
Readme
# CVE-2021-29440
Unsafe Twig processing of static pages leading to RCE in Grav CMS 1.7.10

- Grav is a file based Web-platform. Twig processing of static pages can be enabled in the front matter by any administrative user allowed to create or edit pages. As the Twig processor runs unsandboxed, this behavior can be used to gain arbitrary code execution and elevate privileges on the instance. 

## Explanation
- You need a user who has access to /admin dashboard with page creation privileges.
- Front matter block supports a directive named **process.twig**, which will apply a Twig rendering pass on the content before serving the page.
- While this behavior is disabled by default, users with basic page creation privileges enable this feature in the front matter
- We create a page with content `{{ system("id") }}` and then enabling twig rendering : `Advanced --> Process --> Twig (enable)`
- Visiting the created page to see the output of our command

## Usage
- Edit the username, password and url variable and then run the script
```bash
python3 exploit.py
```

## Environment
- Run environment.sh to setup Grav CMS 1.7.10 on apache.

## Credits
- https://blog.sonarsource.com/grav-cms-code-execution-vulnerabilities


File Snapshot

[4.0K] /data/pocs/536a35cc6f25b21e8b6a575eb33de3ec85a1ef71 ├── [1.1K] environment.sh ├── [3.5K] exploit.py └── [1.2K] README.md 0 directories, 3 files
Shenlong Bot has cached this for you
Remarks
    1. It is advised to access via the original source first.
    2. If the original source is unavailable, please email f.jinxu#gmail.com for a local snapshot (replace # with @).
    3. Shenlong has snapshotted the POC code for you. To support long-term maintenance, please consider donating. Thank you for your support.