There was an error while loading. Please reload this page.
1 parent 3c51865 commit 7918fccCopy full SHA for 7918fcc
1 file changed
test/test_repo.py
@@ -1180,3 +1180,29 @@ def test_do_not_strip_newline_in_stdout(self, rw_dir):
1180
r.git.add(Git.polish_url(fp))
1181
r.git.commit(message="init")
1182
self.assertEqual(r.git.show("HEAD:hello.txt", strip_newline_in_stdout=False), "hello\n")
1183
+
1184
+ @with_rw_repo("HEAD")
1185
+ def test_clone_command_injection(self, rw_repo):
1186
+ tmp_dir = pathlib.Path(tempfile.mkdtemp())
1187
+ unexpected_file = tmp_dir / "pwn"
1188
+ assert not unexpected_file.exists()
1189
1190
+ payload = f"--upload-pack=touch {unexpected_file}"
1191
+ rw_repo.clone(payload)
1192
1193
1194
+ # A repo was cloned with the payload as name
1195
+ assert pathlib.Path(payload).exists()
1196
1197
1198
+ def test_clone_from_command_injection(self, rw_repo):
1199
1200
+ temp_repo = Repo.init(tmp_dir / "repo")
1201
1202
1203
1204
1205
+ with self.assertRaises(GitCommandError):
1206
+ rw_repo.clone_from(payload, temp_repo.common_dir)
1207
1208
0 commit comments