Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB
CVE-2026-51873 Overview
CVE-2026-51873 is a directory traversal vulnerability [CWE-22] in Devika v1.0, an open-source AI software engineering agent. The flaw resides in the Coder.save_code_to_project function, which fails to validate file paths before writing content to disk. Attackers with low-privileged access can submit crafted path inputs containing traversal sequences such as ../ to write files outside the intended project workspace. Successful exploitation allows adversaries to overwrite system files, drop executable payloads in sensitive locations, or achieve code execution by targeting startup directories and configuration files.
Critical Impact
Authenticated attackers can write arbitrary files to any location accessible to the Devika process, enabling remote code execution and full host compromise.
Affected Products
- Devika v1.0
- Devika AI software engineering agent (stitionai/devika repository)
- Deployments using the vulnerable Coder.save_code_to_project function
Discovery Timeline
- 2026-10-01 - CVE-2026-51873 published to NVD
- 2026-10-06 - Last updated in NVD database
Technical Details for CVE-2026-51873
Vulnerability Analysis
The vulnerability affects the Coder.save_code_to_project function in Devika v1.0. This function accepts file paths and content from AI-generated code output and writes them to the project workspace directory. The implementation concatenates user-controlled or AI-generated file names with the base project directory without canonicalizing the resulting path. Attackers who can influence the AI agent's generated file paths through prompts or API calls can inject traversal sequences. The function then resolves these sequences against the filesystem, placing files outside the sandbox.
This class of weakness falls under directory traversal, cataloged as CWE-22. Because Devika often runs with the privileges of the user operating the agent, written files inherit those permissions. Attackers can target shell initialization scripts, cron directories, SSH authorized_keys files, or Windows startup folders to pivot into persistent code execution.
Root Cause
The root cause is missing path canonicalization and lack of a boundary check that confirms the resolved absolute path remains within the project workspace. The function trusts the supplied filename without rejecting .. segments, absolute paths, or symbolic link targets that escape the intended directory.
Attack Vector
An authenticated attacker interacts with the Devika agent over the network. The attacker crafts a prompt or API request that causes the agent to invoke save_code_to_project with a path such as ../../../../etc/cron.d/payload or ..\..\Users\Public\Startup\run.bat. The agent writes attacker-controlled content to that location, bypassing workspace isolation.
A proof-of-concept script demonstrating exploitation is available in a public GitHub Gist, and additional context is documented in the upstream GitHub issue tracker.
Detection Methods for CVE-2026-51873
Indicators of Compromise
- File write operations originating from the Devika process targeting paths outside the configured project workspace directory
- Presence of files containing traversal sequences such as ../ or ..\ in Devika application logs or request bodies
- Unexpected files appearing in system directories such as /etc/cron.d/, ~/.ssh/, /tmp/, or Windows Startup folders following Devika activity
- Modification timestamps on sensitive configuration files that correlate with Devika agent sessions
Detection Strategies
- Monitor process-level file write events from the Devika Python interpreter and alert when target paths resolve outside the whitelisted workspace directory
- Inspect Devika HTTP request payloads and AI prompt logs for path traversal patterns including URL-encoded variants such as %2e%2e%2f
- Correlate agent-initiated file system changes with subsequent process executions to detect code execution chains
Monitoring Recommendations
- Enable filesystem auditing (auditd on Linux, Object Access auditing on Windows) for directories outside the Devika workspace
- Forward Devika application logs and host telemetry to a centralized analytics platform for retrospective hunting on traversal patterns
- Baseline normal file write locations for the Devika process and alert on deviations
How to Mitigate CVE-2026-51873
Immediate Actions Required
- Restrict network access to the Devika web interface and API to trusted administrators only, placing the service behind authenticated reverse proxies or VPNs
- Run Devika as an unprivileged service account inside a container or chroot environment to limit the blast radius of arbitrary file writes
- Audit the project workspace and surrounding directories for unauthorized files written by the Devika process
- Disable or isolate Devika v1.0 instances until an upstream patch is available
Patch Information
At the time of publication, no official vendor patch has been linked in the NVD advisory for CVE-2026-51873. Operators should monitor the upstream repository for fixes and apply updates once released. Interim mitigation requires source-level patching of the Coder.save_code_to_project function to canonicalize paths with os.path.realpath and verify the result begins with the absolute workspace directory before writing.
Workarounds
- Deploy Devika inside a container with a read-only root filesystem, mounting only the project workspace directory as writable
- Apply mandatory access control profiles such as AppArmor or SELinux to confine Devika write operations to a specific directory tree
- Implement a reverse proxy filter that rejects requests containing ../, ..\, or encoded traversal sequences before they reach the application
- Disable the code-saving feature or review all agent-generated file paths manually until the upstream fix is deployed
# Configuration example: run Devika in a confined container
docker run --rm \
--read-only \
--user 1000:1000 \
--cap-drop=ALL \
--security-opt no-new-privileges \
-v /srv/devika/workspace:/app/workspace:rw \
-p 127.0.0.1:3000:3000 \
devika:latest
Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.
Sources: National Vulnerability Database, CISA KEV, Exploit-DB

