CVE-2024-39685

9.8 CRITICAL

📋 TL;DR

CVE-2024-39685 is a critical command injection vulnerability in Bert-VITS2 that allows attackers to execute arbitrary commands on the system by manipulating the data_dir variable. This affects all users running Bert-VITS2 version 2.3 or earlier, particularly those exposing the web interface to untrusted users. The vulnerability occurs because user input is passed directly to subprocess.run() with shell=True without proper sanitization.

💻 Affected Systems

Products:
  • Bert-VITS2
Versions: 2.3 and earlier
Operating Systems: Linux, Windows, macOS
Default Config Vulnerable: ⚠️ Yes
Notes: All deployments using the vulnerable webui_preprocess.py file are affected. The vulnerability is present in the resample function where user-controlled data_dir is used in shell commands.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full system compromise allowing attackers to execute arbitrary commands with the privileges of the Bert-VITS2 process, potentially leading to data theft, ransomware deployment, or complete system takeover.

🟠

Likely Case

Remote code execution allowing attackers to run commands, access sensitive data, or pivot to other systems in the network.

🟢

If Mitigated

Limited impact if proper input validation and command sanitization are implemented, restricting attackers to safe operations only.

🌐 Internet-Facing: HIGH
🏢 Internal Only: MEDIUM

🎯 Exploit Status

Public PoC: ⚠️ Yes
Weaponized: LIKELY
Unauthenticated Exploit: ⚠️ Yes
Complexity: LOW

The vulnerability is trivial to exploit as it requires simple command injection techniques. Public proof-of-concept code is available in the GitHub Security Lab advisory.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 2.4 or later

Vendor Advisory: https://github.com/fishaudio/Bert-VITS2/security/advisories

Restart Required: Yes

Instructions:

1. Update Bert-VITS2 to version 2.4 or later. 2. Replace shell=True with shell=False in subprocess.run() calls. 3. Use shlex.quote() or similar input sanitization for all user-controlled variables. 4. Restart the Bert-VITS2 service.

🔧 Temporary Workarounds

Input Validation Workaround

all

Implement strict input validation for the data_dir parameter to only allow safe characters and paths

# Add input validation before subprocess.run()
import re
if not re.match(r'^[a-zA-Z0-9_\-\.\/]+$', data_dir):
    raise ValueError('Invalid data_dir input')

Disable Web Interface

linux

Temporarily disable the web interface until patching is complete

# Stop the Bert-VITS2 web service
sudo systemctl stop bert-vits2
# Or kill the process
pkill -f 'python.*webui_preprocess'

🧯 If You Can't Patch

  • Implement network segmentation to isolate Bert-VITS2 instances from critical systems
  • Deploy application-level firewall rules to block suspicious command patterns in requests

🔍 How to Verify

Check if Vulnerable:

Check if webui_preprocess.py contains 'subprocess.run(cmd, shell=True)' with user-controlled variables like data_dir. Review lines 46-52 and 130-133 in the file.

Check Version:

python -c "import bert_vits2; print(bert_vits2.__version__)" or check the repository version tag

Verify Fix Applied:

Verify that shell=True is removed or properly sanitized in subprocess.run() calls, and that version is 2.4 or higher.

📡 Detection & Monitoring

Log Indicators:

  • Unusual subprocess executions from Bert-VITS2 process
  • Commands with shell metacharacters in data_dir parameter
  • Failed command execution attempts with special characters

Network Indicators:

  • HTTP requests to Bert-VITS2 containing shell metacharacters in parameters
  • Unusual outbound connections from Bert-VITS2 host

SIEM Query:

source="bert-vits2.log" AND ("subprocess.run" OR "shell=True") AND (data_dir CONTAINS "|" OR data_dir CONTAINS ";" OR data_dir CONTAINS "&")

🔗 References

📤 Share & Export