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

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2021-29440 PoC — Twig allowing dangerous PHP functions by default

Source
Associated Vulnerability
Title:Twig allowing dangerous PHP functions by default (CVE-2021-29440)
Description: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. The issue was addressed in version 1.7.11.
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. Local POC snapshots are reserved for subscribers — if the original source is unavailable, the local mirror is part of the paid plan.
    3. Mirroring, verifying, and maintaining this POC archive takes ongoing effort, so local snapshots are a paid feature. Your subscription keeps the archive online — thank you for the support. View subscription plans →