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
dagRunIdparameter. - Trigger point: Server-side creation and deferred cleanup of the temporary DAG run directory where
filepath.Joinis invoked with attacker-controlled input. - Why exploitation is possible: The use of
filepath.Joinon unvalidateddagRunIdallows..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
/tmpowned by the Dagu process user, disrupting active and scheduled workflows. - System-wide removal of
/tmpcontents 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
dagRunIdand other path-related parameters with traversal patterns (e.g.,.., nested../, and absolute paths) to observe unintended filesystem effects.

