Summary
A path traversal issue in Fluentd's out_file plugin allows attacker-controlled tags to influence dynamically constructed file paths using the ${tag} placeholder.
When Fluentd is configured to write logs based on unvalidated tag values, an attacker sending crafted tags with traversal sequences may cause arbitrary file writes and, in certain environments, progress to remote code execution.
Affected context
This vulnerability appears in Fluentd deployments that:
- Use the
out_fileplugin or similar file-based output plugins - Construct file paths via the
${tag}placeholder in configuration (e.g.,pathparameter) - Accept or derive tag values from untrusted or partially trusted data sources such as multi-tenant inputs, client-supplied identifiers, or external services
It is most relevant in logging pipelines where tags can be influenced by users or upstream systems and where the Fluentd process has write access to sensitive directories or executable locations.
Exploit preconditions
- Attack surface: Fluentd input endpoints and data sources that control or influence the log
tagvalue - Required access: Ability to send log/event data into Fluentd with attacker-chosen tags (e.g., via HTTP, TCP, message queues, or application logging integration)
- Trigger point: Evaluation of the
${tag}placeholder in file path templates by theout_fileplugin during log write operations - Why exploitation is possible: Tag values are interpolated into filesystem paths with insufficient normalization or restriction, enabling directory traversal sequences (
../) and other path manipulation to escape intended log directories and target arbitrary locations
Why this happens
The underlying issue is a failure to treat tag-derived path fragments as untrusted input before using them in filesystem operations.
Fluentd's configuration mechanism allows the ${tag} placeholder to be embedded into path templates, but the resolving logic does not robustly sanitize or constrain tag values to safe directory segments.
This aligns with CWE-22: Improper Limitation of a Pathname to a Restricted Directory, where user-controlled data is joined into a filesystem path without enforcing a strict base directory, removing traversal sequences, or applying a whitelist of acceptable characters and patterns.
Potential impact
- Arbitrary file creation or overwrite within directories writable by the Fluentd process
- Corruption or tampering of application configuration files or data stores
- Overwriting of scripts, binaries, or service files, which can lead to remote code execution when those files are later executed
- Disruption of logging integrity and loss of forensic visibility
- Escalation of impact if combined with other misconfigurations (e.g., writable cron directories, systemd unit overrides, or web-accessible code paths)
General mitigation guidance
Mitigation generally focuses on confining and validating all dynamic path components and minimizing trust in externally influenced tags.
Effective patterns include:
- Avoiding direct interpolation of untrusted tags into filesystem paths; instead, map tags to a controlled set of directory names through a lookup or normalization function
- Enforcing strict path constraints so that all generated file locations remain under a designated log directory, rejecting or rewriting inputs that produce traversal sequences
- Applying strong validation to tag values (e.g., character whitelists, length limits, and pattern checks) before using them in configuration-driven path templates
- Running Fluentd with least-privilege filesystem permissions, ensuring it cannot write to system directories, configuration locations, or executable paths
- Separating logs for untrusted tenants or sources into isolated directories or storage backends that limit cross-impact
How teams detect issues like this
Organizations can identify and manage this class of risk by:
- Reviewing Fluentd configuration files for usage of
${tag}(or similar placeholders) in path-related parameters, especially when tags originate from multi-tenant or user-controlled environments - Applying configuration linting or policy checks that flag dynamic path constructions lacking normalization or base-directory enforcement
- Using static analysis or rule-based scanners on infrastructure-as-code and logging configurations to detect potential path traversal patterns
- Monitoring runtime behavior for unexpected file creation or modification outside expected log directories, using filesystem integrity tools or audit logging
- Incorporating automated configuration reviews in CI/CD pipelines for logging and observability components

