fix(security): prevent search_code symlink path escape - #80
Closed
study8677 wants to merge 1 commit into
Closed
Conversation
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.
Motivation
search_codewalked workspace paths and read files without resolving targets or enforcingis_safe_path, allowing in-repo symlinks to disclose files outside the project.Description
search_codeand skip any target whereis_safe_path(ws, resolved)is false so symlink targets outside the workspace are not read.resolved.read_text(...)) instead of the originalfpath.test_search_code_skips_symlink_outside_workspacethat creates an in-repo symlink to an outside file and assertssearch_codedoes not return matches from that symlink.engine/antigravity_engine/hub/ask_tools.pyandengine/tests/test_ask_tools.py.Testing
pytest -q engine/tests/test_ask_tools.py -k "search_code", which completed successfully with7 passed, 11 deselected.Codex Task