fix: block traversal segments in standard page export paths - #787
Merged
surajshetty3416 merged 2 commits intoAug 28, 2026
Merged
Conversation
export_dir_name scrubbed the name and replaced slashes, but let "." and ".." through as a whole segment. Route it through safe_segment, which already guards the template fixture paths, and move that helper into utils so both exporters share one implementation. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
Confidence Score: 5/5The PR appears safe to merge. No blocking failure remains. Reviews (2): Last reviewed commit: "test: cover the export path segment guar..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #787 +/- ##
===========================================
+ Coverage 65.98% 66.06% +0.08%
===========================================
Files 93 93
Lines 10373 10386 +13
===========================================
+ Hits 6845 6862 +17
+ Misses 3528 3524 -4 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-Authored-By: Claude <noreply@anthropic.com>
Member
Author
|
Added regression coverage for the guard in |
|
🎉 This PR is included in version 1.33.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
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.
The semgrep
frappe-security-file-traversalrule fires on the standard page exporters (export_page_as_standard,export_client_scripts), which write fixtures into an installed app'sbuilder_files/directory.Both are gated behind
frappe.conf.developer_modeand the path segments come fromexport_dir_name(), which scrubs the record name and replaces slashes. It did not, however, reject.or..as a whole segment, so a record named..would write one directory above its export root.template_sync.pyalready hadsafe_segment()for exactly this. Moved it intobuilder/utils.py(whichtemplate_syncalready imports from), routedexport_dir_name()through it, and marked the audited writes# nosemgrep, matching how the template exporter annotates its own.Tested with
test_standard_page_sync(28) andtest_utils(21), all passing.