Deepak/fix issue 1031/prevent python symlink escape#1303
Open
deepakdp17 wants to merge 4 commits intojfrog:devfrom
Open
Deepak/fix issue 1031/prevent python symlink escape#1303deepakdp17 wants to merge 4 commits intojfrog:devfrom
deepakdp17 wants to merge 4 commits intojfrog:devfrom
Conversation
Introduces a shared utility that resolves symlinks via filepath.EvalSymlinks and verifies the real path stays within an allowed directory boundary. Covers file symlinks, directory symlinks, path traversal, and nonexistent file cases. Ref: jfrog#1031
is now rejected with a clear error. Ref: jfrog#1031
working directory are skipped with a warning log. This hardens all package managers that use this shared discovery path (NuGet, Pnpm, Conan, etc.). Ref: jfrog#1031
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.
Summary
Why
Frogbot's Python handler validated file paths using string prefix checks, but never resolved symlinks. In CI environments, a malicious symlink like requirements.txt -> /etc/shadow would pass the path check and still be read or overwritten. This is the issue described in #1031.
What changed
utils/pathutils.go — New ValidateFileWithinDir function that resolves symlinks on both the file and the allowed directory, then checks containment
utils/pathutils_test.go — 7 tests covering regular files, subdirectories, symlink escape, symlinks within the directory, path traversal, nonexistent files, and directory symlink escape
packagehandlers/pythonpackagehandler.go — tryReadRequirementFile and handlePip now validate paths through the new utility before any read or write
packagehandlers/commonpackagehandler.go — GetAllDescriptorFilesFullPaths validates each discovered file and logs a warning if it skips one
Fixes #1031