Skip to content

Commit 68874c2

Browse files
authored
Add VISUAL to tracked environment variables for allowUnsafeEditor (#1201)
* Add `VISUAL` to tracked environment variables for `allowUnsafeEditor`
1 parent 8430817 commit 68874c2

5 files changed

Lines changed: 42 additions & 2 deletions

File tree

‎.changeset/fresh-mugs-love.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@simple-git/argv-parser": patch
3+
"simple-git": patch
4+
---
5+
6+
Add `VISUAL` environment variable to set of `allowUnsafeEditor` environment variables.
7+
8+
Thanks to @oss-security-shopify for identifying the vulnerability.

‎packages/argv-parser/CHANGELOG.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,14 @@
99
- Adds support for TypeScript declaration maps
1010
- Exports the `isGitEnvKey` helper to detect whether an environment variable can be used to configure a `git` operation
1111

12-
- Adds detection for `includeIf.<condition>.path`, thanks to @NotAFlightRisk for identifying the vulnerability
12+
- Adds detection for `includeIf.<condition>.path`, thanks to @bhaswanthc, @NotAFlightRisk, @oss-security-shopify for identifying the vulnerability
1313

1414
### Patch Changes
1515

1616
- c427fba: Additional argument parser vulnerability checks:
17-
- Thanks to @mrillicit for identifying `include.path`, `filter.*.process`
17+
- Thanks to @bhaswanthc, @mrillicit, @avrlab233, @avrlab233 for identifying `include.path`, `filter.*.process`
1818
- Thanks to @tejas619 for identifying `url.*.insteadOf`
19+
1920
- 1bb14df: Vulnerability detection expanded to include `pager.*`, `uploadpack.packObjectsHook`, `difftool.*.cmd` and use of the `GIT_CONFIG_PARAMETERS` environment variable
2021

2122
Thanks to @threalwinky and @nuc13us for identifying.

‎packages/argv-parser/src/env/parse-env.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ const GitEnvKeys = {
2222
'pager': 'allowUnsafePager',
2323
'prefix': 'allowUnsafeConfigPaths',
2424
'ssh_askpass': 'allowUnsafeAskPass',
25+
'visual': 'allowUnsafeEditor',
2526
} as const satisfies Record<string, VulnerabilityCategory>;
2627

2728
type GitEnv = Record<string, string> & {

‎simple-git/CHANGELOG.md‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
// v4 - requires full option names, abbreviated option names will now throw a GitConfigurationError
3838
git.raw("fetch", "--config=user.name=me", "...");
3939
```
40+
Thanks to @anir0y, @CFionaBF, @Leeziao, @internetteletubbie, @idisdi, @the-vibe-dev,
41+
@D7EAD, @dellalibera, @gdegrange, @bilguunbicktivism, @cruzryan, @b1ue0ceanRun, @oss-security-shopify
42+
for identifying the vulnerability.
4043

4144
- Ambient environment variables are filtered before passing into the `git` child process.
4245

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { describe, expect, it } from 'vitest';
2+
import { exists, FILE } from '@kwsites/file-exists';
3+
import { promiseError } from '@kwsites/promise-result';
4+
import { assertGitError, createTestContext, newSimpleGit, setUpInit } from '@simple-git/test-utils';
5+
6+
describe('--exec-path', () => {
7+
it('blocks: use of VISUAL blocked by default', async () => {
8+
const context = await createTestContext();
9+
const root = await context.dir('poc-workdir');
10+
const pwnd = context.path('new-exec-path-pwned');
11+
12+
await setUpInit({ git: newSimpleGit(root) });
13+
await context.file(['poc-workdir', 'file']);
14+
await newSimpleGit(root).raw('add', '.');
15+
await newSimpleGit(root).raw('commit', '-m', 'foo');
16+
17+
const err = await promiseError(
18+
newSimpleGit(root)
19+
.env({ VISUAL: `touch ${pwnd}` })
20+
.raw('commit', '--ammend')
21+
);
22+
23+
expect(exists(pwnd, FILE)).toBe(false);
24+
25+
assertGitError(err, 'allowUnsafeEditor');
26+
});
27+
});

0 commit comments

Comments
 (0)