Backport(v1.19) output: enforce strict path boundary validation for tag#5391
Merged
Conversation
**Which issue(s) this PR fixes**:
Fixes #
**What this PR does / why we need it**:
This PR enhances the robustness of the `${tag}` placeholder expansion by preventing unintended path boundaries from being crossed.
Previously, tags containing relative parent directory patterns (`../`) or absolute paths (e.g., `/etc/passwd`, `\Windows`) were expanded without validation in `extract_placeholders`. This could lead to unexpected file creation or access outside of the intended base directories, especially when using plugins like `out_file`.
To address this, we introduced a strict, highly optimized path boundary validation inside `extract_placeholders` specifically for the `${tag}` variable.
* By validating the variable before substitution, all core and third-party plugins using `extract_placeholders` automatically benefit from this boundary check.
* Backward Compatibility
* Tags containing safe slashes (e.g., `app/web`) are still permitted, ensuring URL expansions (e.g., in `out_http`) or safe nested directories remain fully functional.
**Docs Changes**:
**Release Note**:
Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
kenhys
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue(s) this PR fixes:
Fixes #
What this PR does / why we need it:
This PR enhances the robustness of the
${tag}placeholder expansion by preventing unintended path boundaries from being crossed.Previously, tags containing relative parent directory patterns (
../) or absolute paths (e.g.,/etc/passwd,\Windows) were expanded without validation inextract_placeholders. This could lead to unexpected file creation or access outside of the intended base directories, especially when using plugins likeout_file.To address this, we introduced a strict, highly optimized path boundary validation inside
extract_placeholdersspecifically for the${tag}variable.extract_placeholdersautomatically benefit from this boundary check.app/web) are still permitted, ensuring URL expansions (e.g., inout_http) or safe nested directories remain fully functional.Docs Changes:
Release Note: