fix(security): reject symlinks when fetching skills from a git repo#96
Merged
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
GitRepositorySkillFetcher now skips ALL symbolic links when enumerating skill paths (previously only directory symlinks were skipped) and refuses to read a skill file that is a symlink or resolves outside the clone directory. This matches GitHubSkillTreeClient, which already filters symlinks, and prevents a malicious repo from making Luca read files such as ~/.ssh/id_rsa.
54eb0de to
a1b6f8c
Compare
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.
Description
GitRepositorySkillFetcherfetches skills by shallow-cloning a repository and reading files from the clone. It previously skipped only symlinks that resolved to directories, so a file symlink in a malicious repo (e.g.leak -> /Users/you/.ssh/id_rsa) would be enumerated and read, copying local file content outside the repository into the skill cache.downloadSkillalso resolved symlinks before reading without verifying the result stayed inside the clone.downloadSkillrefuses to read a file that is a symlink or whose resolved path escapes the clone directory. This matchesGitHubSkillTreeClient, which already filters symlinks, keeping the two fetchers consistent.Type of Change
How Has This Been Tested?
swift buildandswift testlocally on macOS (arm64).New tests: a file symlink in a cloned repo is excluded from enumerated skill paths, and
downloadSkillthrowsfileReadFailedwhen asked to read a symlinked path pointing outside the clone. The existing directory-symlink test still passes.Checklist
Breaking Changes?
Additional Notes
Part of a set of independent supply-chain hardening changes; this PR stands alone and can be merged on its own.