feat(security): harden simple-git against malicious repo config RCE#3742
Merged
gregpriday merged 3 commits intodevelopfrom Mar 19, 2026
Merged
feat(security): harden simple-git against malicious repo config RCE#3742gregpriday merged 3 commits intodevelopfrom
gregpriday merged 3 commits intodevelopfrom
Conversation
- Create createHardenedGit() factory in electron/utils/hardenedGit.ts with -c config overrides disabling core.fsmonitor, protocol.ext.allow, core.sshCommand, core.gitProxy, core.hooksPath, diff.external, core.askpass, credential.helper - Move validateCwd() to hardenedGit.ts with path.isAbsolute() enforcement - Replace all bare simpleGit() calls in git-write.ts (10), git.ts (5), projectCrud.ts (2), GitService.ts (3) with createHardenedGit() - Add path.isAbsolute() checks to all github.ts handlers (11) and worktree.ts listCommits handler - Update test mocks in git.test.ts and GitService.test.ts to mock createHardenedGit - Add comprehensive tests for validateCwd and createHardenedGit in hardenedGit.test.ts
- Fix prettier formatting error at line 23
…uction constant - Replace HARDENED_GIT_CONFIG import with explicit expected key list in test - Prevents test from silently passing if a security-critical config key is removed from source
Collaborator
Author
|
Review status: Rebased and ready |
Collaborator
Author
Collaborator
Author
|
Setting diff.external= (empty string) made git interpret it as "run an empty program as the diff tool." Fixed in #4221 by removing the broken override and using --no-ext-diff flags instead. Regression audit for training data. |
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
createHardenedGit()utility that wrapssimpleGit()with config overrides to neutralize dangerous git config options (core.fsmonitor,core.pager,protocol.ext.allow)validateCwd()to reject relative paths, enforcingpath.isAbsolute()across all git IPC handlerscwdfrom the rendererResolves #3704
Changes
electron/utils/hardenedGit.ts— New module exportingcreateHardenedGit(cwd)andHARDENED_GIT_CONFIGconstant. Disablescore.fsmonitor,core.pager, andprotocol.ext.allowvia-cflags on every git invocationelectron/utils/git.ts—validateCwd()now requires absolute paths viapath.isAbsolute()electron/ipc/handlers/git-write.ts— AllsimpleGit(cwd)calls replaced withcreateHardenedGit(cwd);validateCwdimported from shared utilityelectron/ipc/handlers/github.ts— Addedpath.isAbsolute()validation andcreateHardenedGit()for all git operationselectron/ipc/handlers/projectCrud.ts— Switched tocreateHardenedGit()electron/ipc/handlers/worktree.ts— Switched tocreateHardenedGit()electron/services/GitService.ts— Switched tocreateHardenedGit()electron/utils/__tests__/hardenedGit.test.ts— 136-line test suite covering config overrides, absolute path enforcement, empty/whitespace rejectionelectron/utils/__tests__/git.test.ts— UpdatedvalidateCwdtests for absolute path requirementelectron/services/__tests__/GitService.test.ts— Updated mocks to use hardenedGitTesting