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-51874 Overview
CVE-2026-51874 is a path traversal vulnerability in Devika v1.0, an open-source AI software engineering agent. The flaw resides in the save_code_to_project function of the Patcher Agent component. The function fails to sanitize file paths before writing content to disk, allowing an attacker to escape the intended project workspace. A remote attacker can write arbitrary files to locations outside the sandbox directory, resulting in unauthorized file modification or placement of malicious content on the host.
Critical Impact
Unauthenticated network attackers can write files outside the Devika project workspace, enabling tampering with host configuration, source code, or startup scripts.
Affected Products
- Devika v1.0
- Devika Patcher Agent component (save_code_to_project function)
- Deployments tracked in the stitionai/devika repository
Discovery Timeline
- 2026-10-01 - CVE-2026-51874 published to the National Vulnerability Database
- 2026-10-05 - Last updated in NVD database
Technical Details for CVE-2026-51874
Vulnerability Analysis
Devika is an agentic AI developer assistant that writes and modifies code inside a configured project directory. The Patcher Agent applies code changes via the save_code_to_project routine, which accepts file path strings generated or influenced by LLM output and user prompts. The routine joins the attacker-controlled path with the project workspace root and writes the file content without validating that the resulting path remains inside the workspace.
Because the path is not canonicalized or constrained, inputs containing ../ sequences or absolute paths traverse the directory structure. The attacker-supplied filename is interpreted by the operating system, resolving outside the sandbox. Any file the Devika process can access becomes a target for write operations.
The vulnerability is tracked as CWE-22: Improper Limitation of a Pathname to a Restricted Directory. Integrity impact is high while confidentiality and availability are not directly affected by the write primitive itself.
Root Cause
The save_code_to_project function performs a naive path join between the workspace root and a caller-supplied relative path. There is no call to resolve the final path and verify it starts with the workspace prefix. Devika also trusts output produced by the language model and the Patcher Agent prompt chain, so hostile prompts or crafted repository content can inject traversal sequences into filenames.
Attack Vector
An attacker reaches the vulnerable function through the Devika web interface or API by submitting a task that causes the Patcher Agent to save code. The attacker supplies a filename such as ../../etc/cron.d/devika or an equivalent traversal payload. The Patcher Agent writes attacker-controlled content to the targeted location on the host. Depending on process privileges, this can lead to persistence, overwriting of SSH authorized keys, or modification of application configuration. See the public proof-of-concept gist and the upstream issue tracker report for additional technical detail.
Detection Methods for CVE-2026-51874
Indicators of Compromise
- File write events originating from the Devika process targeting paths outside the configured workspace directory.
- New or modified files in sensitive locations such as ~/.ssh/, /etc/cron.d/, or application startup directories owned by the Devika service account.
- Prompt or task payloads containing ../ sequences, encoded traversal strings, or absolute paths in filename fields.
Detection Strategies
- Monitor the Devika application logs for Patcher Agent save operations and compare resolved target paths against the workspace root.
- Enable filesystem auditing (auditd on Linux) on sensitive directories and alert on writes by the Devika runtime user.
- Inspect inbound HTTP requests to the Devika API for traversal patterns in task and file parameters.
Monitoring Recommendations
- Centralize Devika container and host logs in a SIEM and correlate file-write telemetry with prompt submissions.
- Baseline normal project directory activity and alert on writes that resolve outside the baseline tree.
- Track process ancestry for shells or interpreters spawned from the Devika service after suspicious file writes.
How to Mitigate CVE-2026-51874
Immediate Actions Required
- Restrict network exposure of Devika v1.0 instances to trusted operators and internal networks only.
- Run the Devika service under a dedicated, unprivileged account with filesystem access limited to the project workspace.
- Deploy Devika inside a container or chroot with read-only mounts for all paths outside the workspace.
Patch Information
No vendor patch is referenced in the NVD advisory at the time of publication. Track the upstream issue for remediation status and apply fixes that canonicalize the resolved path and reject any target outside the workspace root.
Workarounds
- Add a wrapper around save_code_to_project that resolves the absolute path and verifies it starts with the workspace prefix before writing.
- Reject filenames containing .., null bytes, or absolute path separators before passing them to the Patcher Agent.
- Run Devika inside a container with the workspace mounted at a fixed path and the rest of the filesystem read-only or inaccessible.
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

