feat!: secure-by-default symlink handling for ByteStream and converters#11505
Closed
ritikraj2425 wants to merge 1 commit into
Closed
feat!: secure-by-default symlink handling for ByteStream and converters#11505ritikraj2425 wants to merge 1 commit into
ritikraj2425 wants to merge 1 commit into
Conversation
|
@ritikraj2425 is attempting to deploy a commit to the deepset Team on Vercel. A member of the Team first needs to authorize it. |
Member
|
See #11252 (comment) |
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.
Related Issues
Proposed Changes:
Currently,
ByteStream.from_file_pathand theget_bytestream_from_sourceutility follow symbolic links by default when reading files from disk. This "blind follow" behavior could lead to accidental Local File Inclusion (LFI) or Information Disclosure if a developer passes a user-supplied path that happens to be a symlink to a sensitive system file.This PR implements a "Secure by Default" approach:
follow_symlinks: bool = Falseparameter toByteStream.from_file_path.follow_symlinksis False (the new default), the method checksfilepath.is_symlink()and raises aValueErrorif a link is detected.get_bytestream_from_sourceutility so that components reading file paths (like routers or converters) inherit this secure behavior.How did you test it?
test/dataclasses/test_byte_stream.pyto verify thatValueErroris raised when trying to read a symlink with default parameters, and that it successfully reads it whenfollow_symlinks=Trueis explicitly passed.test/components/converters/test_utils.pyforget_bytestream_from_source.hatch run test:unitandhatch run test:types.Notes for the reviewer
.is_symlink()rather than aggressively resolving all parent paths to avoid breaking legitimate environments (like macOS/tmpdirectories which are often symlinked to/private/tmp).Checklist
fix:,feat:,build:,chore:,ci:,docs:,style:,refactor:,perf:,test:and added!in case the PR includes breaking changes.