Potential fix for code scanning alert no. 281: Uncontrolled data used in path expression#279
Closed
JensKrumsieck wants to merge 1 commit into
Closed
Potential fix for code scanning alert no. 281: Uncontrolled data used in path expression#279JensKrumsieck wants to merge 1 commit into
JensKrumsieck wants to merge 1 commit into
Conversation
… in path expression Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
JensKrumsieck
commented
May 29, 2026
Member
Author
JensKrumsieck
left a comment
There was a problem hiding this comment.
looks good to me
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.
Potential fix for https://github.com/fairagro/sciwin/security/code-scanning/281
General fix: validate and constrain the resolved path before using it in filesystem operations. The safest pattern is to resolve against an allowlisted base directory and reject paths that escape it.
Best fix here without changing broad behavior too much: harden
verify_base_dirso it rejects dangerous relative inputs (.., separators in components are inherently handled by component parsing) and ensures the final resolved path is under the current working directory. This matches the current implicit behavior of joining relative paths tocurrent_dir, while preventing traversal/escape and suspicious component use. Then downstream functions (create_arc_folder_structure) can continue using the returned validated path unchanged.Edit region:
packages/core/src/project.rs, functionverify_base_dir(lines ~100–122 in snippet).Needed changes:
std::path::Componentto inspect path components.ParentDirtraversal.current_dir().join(folder).No new dependency is required; only standard library API is used.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.