Skip to content

Commit f704208

Browse files
committed
In extension to CVE-2022-25912, switch to case-insensitive check for protocol.allow in the handling of allowUnsafeProtocolOverride
1 parent f8cb7df commit f704208

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

.changeset/twelve-tires-trade.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
"simple-git": patch
3+
---
4+
5+
Enhanced `protocol.allow` checks in `allowUnsafeExtProtocol` handling.
6+
7+
Thanks to @CodeAnt-AI-Security for identifying the issue

simple-git/src/lib/plugins/block-unsafe-operations-plugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function preventProtocolOverride(arg: string, next: string) {
2121
return;
2222
}
2323

24-
if (!/^\s*protocol(.[a-z]+)?.allow/.test(next)) {
24+
if (!/^\s*protocol(.[a-z]+)?.allow/i.test(next)) {
2525
return;
2626
}
2727

simple-git/test/unit/plugins/plugin.unsafe.spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,29 @@ import {
77
} from '../__fixtures__';
88

99
describe('blockUnsafeOperationsPlugin', () => {
10+
it.each([
11+
['protocol.allow=always'],
12+
['PROTOCOL.ALLOW=always'],
13+
['Protocol.Allow=always'],
14+
['PROTOCOL.allow=always'],
15+
['protocol.ALLOW=always'],
16+
])('blocks protocol overide in format %s', async (cmd) => {
17+
const task = ['config', '-c', cmd, 'config', '--list'];
18+
19+
assertGitError(
20+
await promiseError(newSimpleGit().raw(...task)),
21+
'allowUnsafeExtProtocol'
22+
);
23+
24+
const err = promiseError(
25+
newSimpleGit({ unsafe: { allowUnsafeProtocolOverride: true } }).raw(...task),
26+
);
27+
28+
await closeWithSuccess();
29+
expect(await err).toBeUndefined();
30+
assertExecutedCommands(...task);
31+
});
32+
1033
it.each([
1134
['clone', '-u touch /tmp/pwn'],
1235
['cmd', '--upload-pack=touch /tmp/pwn0'],

0 commit comments

Comments
 (0)