Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commit2b47933
committed
Correct the "not from cwd" test and add more cases
This shows thatCVE-2023-40590 is only partially patched. Thiscommit does not fix the vulnerbility, only the test.The problem is that, when shell=True, the environment of the shellsubprocess, instead of the GitPython process, determines whethersearching for the "git" command will use the current directory.Currently NoDefaultCurrentDirectoryInExePath is set only in thecurrent process, and this is done after the environment for thesubprocess (env) is computed. So when git is an indirect subprocessdue to shell=True, Windows still checks a CWD when looking it up.(Note that this should not be a problem for indirect subprocessesstarted by git itself. When a standard git command is implementedas an external executable, when git runs a custom command, and whenone git command delegates some of its work to another -- e.g."git clone" running git-remote-https -- Git for Windows alreadydoes not search the current directory. Custom git commands thatstart their own git subprocesses could have an analogous pathsearch bug, but this would be separate from the bug in GitPython.)This is an exploitable vulnerability in GitPython. Althoughshell=True is rarer and inherently less secure than the default ofshell=False, it still ought to avoid automatically running anexecutable that may exist only due to having been cloned as part ofan untrusted repository. In addition, historically programs onWindows had sometimes used shell=True as a workaround for consolewindows being displayed for subprocesses, and some such code maystill be in use.Furthermore, even when GitPython's current working directory isoutside the repository being worked on, the Git object in a Repoinstance's "git" attribute holds the repository directory as its"_working_dir" attribute, which Git.execute consults to determinethe value of "cwd" to pass to subprocess.Popen. When the createddirect subprocess is really a shell, this is the CWD where git.exeis looked for before searching PATH directories.This is also why previous, more limited testing (includingaccompanying manual testing with shell=True) didn't discover thebug. Even when modified to test with shell=True, the old test hadthe "impostor" git.exe in the GitPython process's own currentdirectory (which was changed to a temporary directory for the test,where the "impostor" was created, but this was separate from theworking tree of the self.git repository). This was effective forthe shell=False case, but not the shell=True case where theimpostor would be found and run in the repository directory evenwhen it differs from the GitPython process's CWD.1 parent1c65efb commit2b47933
2 files changed
+32
-23
lines changedLines changed: 2 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
88 | 88 |
| |
89 | 89 |
| |
90 | 90 |
| |
91 |
| - | |
| 91 | + | |
92 | 92 |
| |
93 | 93 |
| |
94 | 94 |
| |
95 |
| - | |
| 95 | + | |
96 | 96 |
| |
97 | 97 |
| |
98 | 98 |
| |
|
Lines changed: 30 additions & 21 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
| |||
12 | 13 |
| |
13 | 14 |
| |
14 | 15 |
| |
15 |
| - | |
| 16 | + | |
16 | 17 |
| |
17 | 18 |
| |
18 | 19 |
| |
| |||
135 | 136 |
| |
136 | 137 |
| |
137 | 138 |
| |
138 |
| - | |
139 |
| - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
140 | 143 |
| |
141 |
| - | |
142 |
| - | |
143 |
| - | |
144 |
| - | |
145 |
| - | |
146 |
| - | |
147 |
| - | |
148 |
| - | |
149 |
| - | |
150 |
| - | |
151 |
| - | |
152 |
| - | |
153 |
| - | |
154 |
| - | |
155 |
| - | |
156 |
| - | |
157 |
| - | |
158 |
| - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
159 | 168 |
| |
160 | 169 |
| |
161 | 170 |
| |
|
0 commit comments
Comments
(0)