Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork939
Commit61b4dda
committed
Start on test_hook_uses_shell_not_from_cwd
This shows that run_commit_hook is vulnerable to an untrustedsearch path bug on Windows, when running script hooks: bash.exe isrun without setting NoDefaultCurrentDirectoryInExePath or otherwiseexcluding the current directory from the path search.The new test uses a non-bare repo, even though the surroundingtests use bare repos. Although the test also works if the repo isinitialized with `Repo.init(rw_dir, bare=True)`, using a bare repowould obscure how the bug this test reveals would typically beexploited, where a command that uses a hook is run after amalicious bash.exe is checked out into the working tree from anuntrusted branch.Running hooks that are themselves provided by an untrustedrepository or branch is of course never safe. If an attacker candeceive a user into doing that, then this vulnerability is notneeded. Instead, an attack that leverages this untrusted searchpath vulnerability would most likely be of roughly this form:1. The user clones a trusted repository and installs hooks.2. A malicious party offers a contribution to the project.3. The user checks out the malicious party's untrusted branch.4. The user performs an action that runs a hook.The hook the user runs is still trusted, but it runs with themalicious bash.exe found in the current directory (which is theworking tree or perhaps some subdirectory of it).The test added in this commit should, if possible, be improved tobe able to run and detect the bug (or its absence) even when bashis absent from the Windows system and, preferably, also even whenthe WSL bash.exe is present but no WSL distribution is installed.1 parentd2506c7 commit61b4dda
1 file changed
+36
-1
lines changedLines changed: 36 additions & 1 deletion
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
3 | 3 |
| |
4 | 4 |
| |
5 | 5 |
| |
| 6 | + | |
6 | 7 |
| |
7 | 8 |
| |
8 | 9 |
| |
9 | 10 |
| |
10 | 11 |
| |
11 | 12 |
| |
| 13 | + | |
12 | 14 |
| |
13 | 15 |
| |
14 | 16 |
| |
15 | 17 |
| |
| 18 | + | |
16 | 19 |
| |
17 | 20 |
| |
18 | 21 |
| |
| |||
36 | 39 |
| |
37 | 40 |
| |
38 | 41 |
| |
39 |
| - | |
| 42 | + | |
40 | 43 |
| |
41 | 44 |
| |
42 | 45 |
| |
| |||
172 | 175 |
| |
173 | 176 |
| |
174 | 177 |
| |
| 178 | + | |
175 | 179 |
| |
176 | 180 |
| |
177 | 181 |
| |
| |||
1012 | 1016 |
| |
1013 | 1017 |
| |
1014 | 1018 |
| |
| 1019 | + | |
| 1020 | + | |
| 1021 | + | |
| 1022 | + | |
| 1023 | + | |
| 1024 | + | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
| 1034 | + | |
| 1035 | + | |
| 1036 | + | |
| 1037 | + | |
| 1038 | + | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
| 1044 | + | |
| 1045 | + | |
| 1046 | + | |
| 1047 | + | |
| 1048 | + | |
| 1049 | + | |
1015 | 1050 |
| |
1016 | 1051 |
| |
1017 | 1052 |
| |
|
0 commit comments
Comments
(0)