Details
The three mapped keys are the safe siblings; the missing visual entry is the gap. Because prepareEnv (lines 60-68) filters on this map plus a git prefix, the omission is not merely a missing classification — the value never reaches the classifier at all.
Reproduction
Verified — reproduced dynamically, end to end, against a checkout of c427fbad33f1f2b11341f1cf852eedecbb106400 (packages/argv-parser/package.json = 1.1.1) and against the published npm artifact 1.1.1.
Observed at the parser level (vitest PoC run against the repo):
parseEnv({ EDITOR }),parseEnv({ GIT_EDITOR })andparseEnv({ GIT_SEQUENCE_EDITOR })each yield oneallowUnsafeEditorvulnerability.parseEnv({ VISUAL: '/tmp/poc/evileditor' })yields[]in every casing.vulnerabilityCheck(['commit', '--amend'], { VISUAL })— the exact call the spawn guard makes — returns[].- The published
dist/index.cjsof 1.1.1 contains zero occurrences ofvisual; the same holds for the repository at the verified commit, includingdocs/PLUGIN-UNSAFE-ACTIONS.md.
Observed at the Git level (only VISUAL set, EDITOR and GIT_EDITOR unset): git var GIT_EDITOR returned the attacker path; git commit --amend executed the attacker script (marker written, commit subject rewritten); git rebase -i executed it for the rebase-todo as well. VISUAL also took precedence over EDITOR (EDITOR=/bin/true VISUAL=evil -> evil).
Observed end to end through the real spawn path (simple-git built from this commit, default options, no unsafe allowances): the EDITOR and GIT_EDITOR variants both threw GitPluginError — "Use of ... is not permitted without enabling allowUnsafeEditor" — with no execution. The VISUAL variant was not blocked: the plugin saw an empty vulnerability list, Git spawned, and the attacker-supplied editor executed as the host user against .git/COMMIT_EDITMSG, rewriting the commit message.
Minimal Git-level reproduction:
#!/bin/sh
set -e
rm -rf /tmp/visual-repo /tmp/GIT_VISUAL_POC /tmp/evileditor
mkdir /tmp/visual-repo && cd /tmp/visual-repo
git init -q
git config user.email a@a && git config user.name a
touch a && git add a && git commit -qm init
printf '#!/bin/sh\ntouch /tmp/GIT_VISUAL_POC\nexit 1\n' >/tmp/evileditor
chmod +x /tmp/evileditor
env -u EDITOR -u GIT_EDITOR VISUAL=/tmp/evileditor git commit --amend || true
test -e /tmp/GIT_VISUAL_POC && echo executed
Guard-level reproduction, using the public API:
import { vulnerabilityCheck } from '@simple-git/argv-parser';
import { spawnSync } from 'node:child_process';
const args = ['commit', '--amend'];
const env = { VISUAL: '/tmp/evileditor' };
if (vulnerabilityCheck(args, env).length === 0) spawnSync('git', args, { env });
- Expected:
parseEnv({ VISUAL: '/tmp/evileditor' }).vulnerabilitiescontainsallowUnsafeEditor, and the spawn guard refuses the operation unless the consumer has enabledallowUnsafeEditor— the behaviour already applied toEDITOR,GIT_EDITORandGIT_SEQUENCE_EDITOR. - Actual: no vulnerability is reported, the guard permits the spawn, and Git executes the attacker-selected binary.
Suggested remediation
Treat VISUAL as an editor source, so Git's own editor-resolution precedence is fully covered by the denylist.
const GitEnvKeys = {
'editor': 'allowUnsafeEditor',
'visual': 'allowUnsafeEditor',
// ...
'git_editor': 'allowUnsafeEditor',
// ...
'git_sequence_editor': 'allowUnsafeEditor',
} as const satisfies Record<string, VulnerabilityCategory>;
Because prepareEnv filters on GitEnvKeys membership, this single entry is enough to make visual survive filtering and be classified; no change to prepareEnv or collectConfigVulnerabilities is required.
Notes:
TERMis likewise neither aGitEnvKeynorgit-prefixed, and it is the variable that decides whether Git consultsVISUALat all (TERM=dumbor unset meansVISUALis ignored). An attacker who controls the environment object supplies it alongsideVISUAL; whetherTERMwarrants its own classification is a maintainer judgement call, but it is worth considering while fixing this.git rebase -ireaches the same sink:git_sequence_editorfalls back to normal editor resolution, so theVISUALpath executes the attacker binary against the rebase-todo file as well.docs/PLUGIN-UNSAFE-ACTIONS.md("Text editor") should listVISUALalongsideEDITOR/GIT_EDITOR/GIT_SEQUENCE_EDITOR, since the documented scope of the control is what consumers rely on.- Already safe and needing no change:
EDITOR,GIT_EDITORandGIT_SEQUENCE_EDITORare all correctly classified and enforced by the plugin, and the parser's handling ofgit-prefixed variables is unaffected.
Suggested regression test alongside test/parse-env.spec.ts (which currently covers EDITOR / GIT_EDITOR / GIT_SEQUENCE_EDITOR / PAGER but has no VISUAL case): assert that parseEnv({ VISUAL: '/tmp/evileditor' }) yields one allowUnsafeEditor vulnerability in every casing, and that vulnerabilityCheck(['commit', '--amend'], { VISUAL: '/tmp/evileditor' }) returns that vulnerability rather than []. A precedence case is worth adding too: VISUAL set together with EDITOR must still be flagged, since VISUAL wins in Git's resolution order.