/

CVE-2026-51874

Severity:

HIGH RISK

(7.5)

Path Traversal (CWE-22) in Devika Patcher Agent Function

CVE-2026-51874

Deferred

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Unauthorized File Write

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

A path traversal vulnerability in Devika v1.0 allows the Patcher Agent's save_code_to_project function to write files outside the intended project workspace. The issue becomes risky when attacker-controlled or insufficiently validated path values reach the file-writing operation, potentially enabling unauthorized modification of application or system files.

A path traversal vulnerability in Devika v1.0 allows the Patcher Agent's save_code_to_project function to write files outside the intended project workspace. The issue becomes risky when attacker-controlled or insufficiently validated path values reach the file-writing operation, potentially enabling unauthorized modification of application or system files.

Affected context

The vulnerability occurs in Devika v1.0 within the Patcher Agent's project file-writing workflow. It is relevant where file paths are derived from user-controlled, agent-controlled, or otherwise untrusted input without reliable confinement to the configured project workspace. The practical impact depends on the permissions of the Devika process and the files reachable by that process.

The vulnerability occurs in Devika v1.0 within the Patcher Agent's project file-writing workflow. It is relevant where file paths are derived from user-controlled, agent-controlled, or otherwise untrusted input without reliable confinement to the configured project workspace. The practical impact depends on the permissions of the Devika process and the files reachable by that process.

Exploit preconditions

  • Attack surface: The Patcher Agent's save_code_to_project file-writing function
  • Required access: The ability to influence the path or file destination supplied to the agent, directly or through an exposed workflow
  • Trigger point: A save operation that processes the attacker-influenced path
  • Why exploitation is possible: Path values are not sufficiently constrained to the intended workspace before filesystem access occurs
  • Attack surface: The Patcher Agent's save_code_to_project file-writing function
  • Required access: The ability to influence the path or file destination supplied to the agent, directly or through an exposed workflow
  • Trigger point: A save operation that processes the attacker-influenced path
  • Why exploitation is possible: Path values are not sufficiently constrained to the intended workspace before filesystem access occurs

Why this happens

The underlying bug is improper neutralization of path elements before constructing a filesystem destination. When a file-writing routine trusts a relative or otherwise manipulated path, traversal components or alternate path representations may cause resolution outside the approved project directory. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly called path traversal.

The underlying bug is improper neutralization of path elements before constructing a filesystem destination. When a file-writing routine trusts a relative or otherwise manipulated path, traversal components or alternate path representations may cause resolution outside the approved project directory. This maps to CWE-22: Improper Limitation of a Pathname to a Restricted Directory, commonly called path traversal.

Potential impact

  • An attacker may overwrite or create files outside the project workspace
  • Application configuration or source files could be modified
  • The Devika process could be used to alter files accessible under its operating-system permissions
  • File integrity, availability, or downstream build and deployment processes could be affected
  • In some environments, unauthorized file writes could contribute to code execution or broader compromise
  • An attacker may overwrite or create files outside the project workspace
  • Application configuration or source files could be modified
  • The Devika process could be used to alter files accessible under its operating-system permissions
  • File integrity, availability, or downstream build and deployment processes could be affected
  • In some environments, unauthorized file writes could contribute to code execution or broader compromise

General mitigation guidance

Mitigation generally focuses on enforcing a strong filesystem trust boundary around project writes.

Common defensive patterns include:

  • Resolve candidate paths against a fixed workspace and verify that the canonical result remains within that workspace
  • Prefer safe file APIs that accept an approved directory handle or constrained destination
  • Reject traversal components, absolute paths, alternate separators, and ambiguous path encodings as defense-in-depth
  • Use allowlisted project-relative filenames and restrict writable file types where practical
  • Run the agent with the least filesystem privilege necessary and isolate project workspaces
  • Apply atomic writes, permission controls, and read-only protections to sensitive locations
  • Treat agent-generated paths as untrusted even when they originate from an internal workflow

Mitigation generally focuses on enforcing a strong filesystem trust boundary around project writes.

Common defensive patterns include:

  • Resolve candidate paths against a fixed workspace and verify that the canonical result remains within that workspace
  • Prefer safe file APIs that accept an approved directory handle or constrained destination
  • Reject traversal components, absolute paths, alternate separators, and ambiguous path encodings as defense-in-depth
  • Use allowlisted project-relative filenames and restrict writable file types where practical
  • Run the agent with the least filesystem privilege necessary and isolate project workspaces
  • Apply atomic writes, permission controls, and read-only protections to sensitive locations
  • Treat agent-generated paths as untrusted even when they originate from an internal workflow

How teams detect issues like this

High-level detection approaches include:

  • Static analysis rules for filesystem writes that concatenate or join untrusted input without canonicalization and boundary checks
  • Code review checks for missing workspace containment validation in save, export, upload, and archive-extraction functions
  • Runtime monitoring for writes outside approved project directories and unexpected modifications to configuration or executable files
  • Policy enforcement that limits agent processes to dedicated writable directories through operating-system or container controls
  • Tests covering relative traversal, absolute paths, symbolic links, alternate separators, and encoded path representations
  • Neutral automated code-review tools can help identify risky path construction patterns, but findings should be validated against deployment-specific controls

High-level detection approaches include:

  • Static analysis rules for filesystem writes that concatenate or join untrusted input without canonicalization and boundary checks
  • Code review checks for missing workspace containment validation in save, export, upload, and archive-extraction functions
  • Runtime monitoring for writes outside approved project directories and unexpected modifications to configuration or executable files
  • Policy enforcement that limits agent processes to dedicated writable directories through operating-system or container controls
  • Tests covering relative traversal, absolute paths, symbolic links, alternate separators, and encoded path representations
  • Neutral automated code-review tools can help identify risky path construction patterns, but findings should be validated against deployment-specific controls

Sources

SourceLink
gist.github.comgist.github.com/Ro1ME/eb9e0cd66ee3c682a624650464d07302
github.comgithub.com/stitionai/devika/issues/709

Frequently asked

questions

It may be remotely exploitable when an attacker can reach a Devika workflow that exposes the Patcher Agent and influence the destination path. If the function is only available locally or to trusted operators, exploitation scope is reduced.

The attacker generally needs a way to provide or control a path processed by save_code_to_project. The resulting impact also depends on the Devika process's filesystem permissions.

Treat every supplied path as untrusted, resolve it against a fixed workspace, and allow the write only when the canonical destination remains within that workspace. Least-privilege execution provides an additional containment layer.

Use centralized safe path-resolution helpers, maintain allowlists for writable locations, test boundary cases, review filesystem operations during code review, and monitor writes outside approved directories.

It may be remotely exploitable when an attacker can reach a Devika workflow that exposes the Patcher Agent and influence the destination path. If the function is only available locally or to trusted operators, exploitation scope is reduced.

The attacker generally needs a way to provide or control a path processed by save_code_to_project. The resulting impact also depends on the Devika process's filesystem permissions.

Treat every supplied path as untrusted, resolve it against a fixed workspace, and allow the write only when the canonical destination remains within that workspace. Least-privilege execution provides an additional containment layer.

Use centralized safe path-resolution helpers, maintain allowlists for writable locations, test boundary cases, review filesystem operations during code review, and monitor writes outside approved directories.

Find out what's already
exploitable in your codebase.