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

Goal: 1000 CNY · Raised: 1000 CNY

100.0%

CVE-2019-6690 PoC — python-gnupg 输入验证错误漏洞

Source
Associated Vulnerability
Title:python-gnupg 输入验证错误漏洞 (CVE-2019-6690)
Description:python-gnupg是一款用于处理与GnuPG交互的Python接口的软件包,它包括秘钥文件生成、秘钥导出和导入等功能。 python-gnupg 0.4.3版本中存在输入验证错误漏洞,该漏洞源于程序没有正确地过滤用户提交的输入。远程攻击者可利用该漏洞在受影响应用程序的上下文中注入并执行任意代码,访问或修改数据。
Readme
# CVE-2019-6690: Improper Input Validation in python-gnupg 0.4.3

We discovered a way to inject data trough the passphrase property of the
gnupg.GPG.encrypt() and gnupg.GPG.decrypt() methods when symmetric encryption is
used.

The supplied passphrase is not validated for newlines, and the library passes
`--passphrase-fd=0` to the gpg executable, which expects the passphrase on the
first line of stdin, and the ciphertext to be decrypted or plaintext to be
encrypted on sebsequent lines.

By supplying a passphrase containing a newline an attacker can control/modify
the ciphertext/plaintext being decrypted/encrypted.

# Vulnerable

python-gnupg 0.4.3, and maybe earlier versions

# Mitigation

Users should upgrade to 0.4.4

# Timeline

- 2019-01-19: Vulnerability discovered during Insomni'hack teaser 2019
- 2019-01-20: PoC created
- 2019-01-22: Applied for CVE, Vendor notified
- 2019-01-23: CVE-2019-6690 assigned
- 2019-01-23: Vendor responded, fix committed
- 2019-01-24: Vendor released 0.4.4

# References

- https://pypi.org/project/python-gnupg/
- https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2019-6690
- https://github.com/hackeriet/CVE-2019-6690-python-gnupg-vulnerability
- https://ctftime.org/task/7458

# Proof of Concept

Hypothetical application using sucessful decryption of data to authenticate
a user, and a way to exploit it is available here: 

https://github.com/hackeriet/CVE-2019-6690-python-gnupg-vulnerability


## Dependencies 

Debian: `apt install libmojolicious-perl python3-gnupg python3-flask`

Nix: `nix-shell`

## Run the server

`./server.py`

## Run the exploit

`./exploit.pl`

# Credits

Vulnerability discovered by Alexander Kjäll and Stig Palmquist. 

Thanks to remmer.
File Snapshot

[4.0K] /data/pocs/5bfad8b40dd2fd69962c5ca1ee6e8943a27b6ce2 ├── [1.0K] exploit.pl ├── [ 376] exploit.sh ├── [ 56K] gnupg.py ├── [1.7K] README.md ├── [1.6K] server.py ├── [ 140] shell.nix ├── [7.7K] talk-hackeriet-ctf-and-python-gnupg.org └── [ 294] vulnerable.py 0 directories, 8 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.