fix: prevent command injection and fix cross-platform compatibility#19
Open
VivanRajath wants to merge 1 commit intoopen-gitagent:mainfrom
Open
fix: prevent command injection and fix cross-platform compatibility#19VivanRajath wants to merge 1 commit intoopen-gitagent:mainfrom
VivanRajath wants to merge 1 commit intoopen-gitagent:mainfrom
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.
fix: prevent command injection and fix cross-platform compatibility
Problem
Multiple files use
execSync()with string interpolation to run git commands. User-controlled inputs (branch names, commit messages, URLs) are interpolated directly into shell strings, enabling arbitrary command execution:Additionally:
cli,hooks,tool-loader) useshwhich doesn't exist on Windows, breaking core command execution on that platform./instead ofpath.sep, completely bypassing the security check on Windows (which uses\).Solution
1. Command Injection → Safe Argument Arrays
Replaced every
execSyncwith string interpolation withexecFileSyncusing argument arrays. Inputs are passed as separate OS-level arguments and are never interpreted by a shell:For compound git operations (e.g.,
git add && git commit), the single shell command was split into separateexecFileSynccalls:2. Cross-Platform Shell Execution
Shell-spawning tools now detect the platform and use the appropriate shell:
3. Path Traversal Guard Fix
Files Changed (12)
src/session.tsgit()helper rewritten + all 15 call sitessrc/loader.tsgit cloneinresolveInheritance()andresolveDependencies()src/index.tsisGitRepo(),ensureRepo()git init/add/commitsrc/tools/memory.tssrc/sandbox.tsgit remote get-url originsrc/tools/skill-learner.tsgitCommit()helper + delete actionsrc/tools/capture-photo.tssrc/plugin-cli.tsexecSyncimportsrc/tools/cli.tssh/cmd)src/hooks.tspath.sep) + cross-platform shellsrc/tool-loader.tsNot Included
src/voice/server.tsstill usesexecSync— it's a 113KB monolith that needs a refactor before these changes can be applied safely. Planned for a follow-up PR.Testing
-
tsc --noEmitpasses with zero compilation errors-
npm testpasses with zero compilation errors