/

CVE-2026-31886

Severity:

CRITICAL RISK

(9.1)

Path Traversal in Dagu Inline DAG Execution

CVE-2026-31886

Analyzed

Vulnerability type

Category:

Path Traversal

CWE:

CWE-22

Impact:

Denial of Service via Arbitrary Directory Deletion

Severity:

CRITICAL RISK

(9.1)

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

Dagu's inline DAG execution endpoints construct temporary directories using an unvalidated dagRunId request field, allowing directory traversal via values like ...

Because a deferred cleanup routine unconditionally calls os.RemoveAll on the resolved path, an attacker can cause mass deletion of files under /tmp, leading to system-wide denial of service in some deployments.

Affected context

The vulnerability affects Dagu deployments that expose the Web UI or HTTP API endpoints for inline DAG execution and accept user-supplied dagRunId values.

The issue occurs during temporary directory setup for a DAG run, where dagRunId is directly combined with a base path using filepath.Join without validating its format, allowed characters, or directory depth.

Environments are particularly at risk when Dagu runs with elevated privileges (such as root or inside Docker containers) and when /tmp is shared among multiple applications or jobs.

Exploit preconditions

  • Attack surface: HTTP endpoints backing Dagu's inline DAG execution functionality.
  • Required access: Ability to send requests to the affected execution endpoints and control the dagRunId parameter.
  • Trigger point: Server-side creation and deferred cleanup of the temporary DAG run directory where filepath.Join is invoked with attacker-controlled input.
  • Why exploitation is possible: The use of filepath.Join on unvalidated dagRunId allows .. segments to escape the intended /tmp/<name>/<id> directory.

A deferred os.RemoveAll call on the resolved directory executes unconditionally when the handler returns, deleting the entire target directory tree.

Why this happens

This vulnerability stems from path traversal due to improper input validation in filesystem path construction.

The HTTP handler accepts dagRunId directly from the request and passes it into filepath.Join with a base temporary directory.

Go's filepath.Join normalizes .. components, so values such as ".." or paths containing multiple ../ segments can traverse outside the intended directory hierarchy.

A deferred cleanup routine then calls os.RemoveAll on whatever path filepath.Join produced, effectively granting attackers the ability to trigger recursive deletion of arbitrary directories reachable via traversal.

This behavior aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory ('Path Traversal'), where untrusted path components are not constrained to a safe directory.

Potential impact

  • Deletion of all temporary files under /tmp owned by the Dagu process user, disrupting active and scheduled workflows.
  • System-wide removal of /tmp contents in root or containerized deployments, causing a broad denial of service for multiple services.
  • Loss of intermediate job data, logs, sockets, and other temporary resources critical for running processes.
  • Cascading failures in workflows and other applications that rely on /tmp, potentially requiring manual recovery or system restart.

General mitigation guidance

Effective mitigation focuses on constraining path construction and minimizing the power of cleanup routines:

  • Treat all request-derived path segments as untrusted and validate them against a strict allowlist (e.g., alphanumeric IDs, fixed length, no slashes or traversal tokens).
  • Avoid directly joining user input into filesystem paths that control deletion; instead, map opaque run identifiers to server-generated directory names.
  • Use APIs and patterns that enforce a fixed base directory and fail closed if the resolved path attempts to leave that directory.
  • Ensure cleanup mechanisms operate only on directories that were explicitly created by the application in the current run, tracking those paths internally rather than trusting request parameters.
  • Reduce privileges of the process managing workflows to limit the blast radius of any filesystem operation, especially in containerized or root environments.

How teams detect issues like this

Organizations can detect similar vulnerabilities through a combination of static and review-based approaches:

  • Static analysis rules that flag filepath.Join (or equivalent path constructors) when any argument originates from HTTP request fields or other untrusted sources without prior validation.
  • Code review checklists that require scrutiny of any use of os.RemoveAll, recursive deletion, or directory cleanup routines driven by external input.
  • Enforcement of secure coding policies that mandate canonicalization and validation of path segments before filesystem operations, especially for temporary directories.
  • Use of automated security testing tools or fuzzers that vary dagRunId and other path-related parameters with traversal patterns (e.g., .., nested ../, and absolute paths) to observe unintended filesystem effects.

Sources

SourceLink
github.comgithub.com/dagu-org/dagu/commit/12c2e5395bd9331d49ca103593edfd0db39c4f38
github.comgithub.com/dagu-org/dagu/security/advisories/GHSA-m4q3-457p-hh2x

Frequently asked

questions

Yes, if the Dagu Web UI or HTTP API is exposed, a remote caller who can reach the inline DAG execution endpoints can exploit the issue by choosing malicious dagRunId values.

The attacker needs the ability to invoke the affected HTTP handlers with arbitrary dagRunId input. No direct shell or filesystem access is required; the vulnerability is triggered through the web interface or API.

The most robust fix is to decouple user input from filesystem paths: treat dagRunId as a logical identifier only, validate it strictly, and map it to internally generated directory names stored in a trusted lookup, while ensuring cleanup routines only operate on those internally tracked directories.

Establish defensive patterns for filesystem operations: never join raw request parameters into paths, enforce normalization and allowlist-based validation for any path component, review any use of recursive deletion APIs, and add automated checks in CI to catch path traversal patterns before deployment.

Find out what's already
exploitable in your codebase.