fix(github-dev-assistant): reject path traversal in repo path parameters#122
Open
konard wants to merge 3 commits intoxlabtg:mainfrom
Open
fix(github-dev-assistant): reject path traversal in repo path parameters#122konard wants to merge 3 commits intoxlabtg:mainfrom
konard wants to merge 3 commits intoxlabtg:mainfrom
Conversation
Adding .gitkeep for PR creation (default mode). This file will be removed when the task is complete. Issue: xlabtg#115
…ers (issue xlabtg#115) Add `validateRepoPath` helper to `utils.js` that rejects any path containing `..` segments or starting with `/`. Apply the check in `github_get_file`, `github_update_file`, `github_delete_file`, `github_list_directory`, `github_list_files`, and `github_download_file` before the path is interpolated into the GitHub API URL, preventing directory traversal attacks. Add `repo-ops.test.js` with 20 unit tests. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
🤖 Solution Draft LogThis log file contains the complete execution trace of the AI solution draft process. 💰 Cost estimation:
📊 Context and tokens usage:
Total: 52.4K + 2.0M cached input tokens, 12.1K output tokens, $0.977176 cost 🤖 Models used:
📎 Log file uploaded as Gist (924KB)Now working session is ended, feel free to review and add any feedback on the solution draft. |
Author
✅ Ready to mergeThis pull request is now ready to be merged:
Monitored by hive-mind with --auto-restart-until-mergeable flag |
This reverts commit b5ac59f.
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
Fixes #115 — path traversal vulnerability in
github_get_file(and related tools) where a caller could supply a path like../.github/workflows/deploy.ymland the GitHub API would resolve the..segments, potentially exposing files outside the intended scope.Root cause
Six tools in
repo-ops.jsandfile-ops.jsinterpolated thepathparameter directly into the GitHub API URL without validating it:github_get_filegithub_update_filegithub_delete_filegithub_list_directorygithub_list_filesgithub_download_fileWhile
encodeURIComponentwas used onownerandrepo,pathwas passed raw, allowing..segments to be sent to the API.Fix
Added a
validateRepoPath(path)helper toutils.jsthat:/(repo paths are always relative)/and\and rejects any segment equal to..Each of the six affected tools now calls
validateRepoPathimmediately aftervalidateRequired, returning{ success: false, error: "..." }before any API call is made.Tests
Added
plugins/github-dev-assistant/tests/repo-ops.test.jswith 20 unit tests covering:..alone,../etc/passwd,src/../../etc/passwdsrc\..\..\etc\passwd/src/index.js,/src/index.js,.github/workflows/ci.yml,README.md, empty stringAll 232 existing and new tests pass.
Test plan
npm testpasses (232 pass, 0 fail)validateRepoPathunit tests cover traversal attacks, absolute paths, edge cases, and valid pathsgithub_get_file,github_update_file,github_delete_file,github_list_directory,github_list_files,github_download_file🤖 Generated with Claude Code