Description
Both commit() (src/git/diff.ts:240) and gitCommit() (src/commands/batch.ts:109) write the commit message to tmpdir()/commit-echo-msg-<pid>-<Date.now()>.txt using a guessable name (PID + millisecond timestamp) and default file permissions (writeFileSync(tmpFile, ..., 'utf-8'), mode 0666 & umask).
Issues:
- Collision: two concurrent
commit-echo processes started in the same millisecond (or two runs sharing a PID after reuse) write to the same path — one overwrites the other's message before git commit -F reads it.
- TOCTOU/symlink: the world-writable tmpdir + predictable name means another local user can pre-create a file/symlink at the target path; the message is also world-readable if the umask permits.
Location
src/git/diff.ts line 240
src/commands/batch.ts line 109
Code
const tmpFile = join(tmpdir(), `commit-echo-msg-${process.pid}-${Date.now()}.txt`);
writeFileSync(tmpFile, fullMessage, 'utf-8');
Suggested fix
Use mkdtempSync(join(tmpdir(), 'commit-echo-')) or randomUUID() in the filename, and pass { mode: 0o600 } to writeFileSync. Alternatively pipe the message to git commit -F - via stdin, which avoids the temp file entirely.
Impact
Rare but real race conditions (wrong/empty commit messages under concurrency) and a local information-disclosure / file-precreation risk in a shared tmpdir.
Description
Both
commit()(src/git/diff.ts:240) andgitCommit()(src/commands/batch.ts:109) write the commit message totmpdir()/commit-echo-msg-<pid>-<Date.now()>.txtusing a guessable name (PID + millisecond timestamp) and default file permissions (writeFileSync(tmpFile, ..., 'utf-8'), mode 0666 & umask).Issues:
commit-echoprocesses started in the same millisecond (or two runs sharing a PID after reuse) write to the same path — one overwrites the other's message beforegit commit -Freads it.Location
src/git/diff.tsline 240src/commands/batch.tsline 109Code
Suggested fix
Use
mkdtempSync(join(tmpdir(), 'commit-echo-'))orrandomUUID()in the filename, and pass{ mode: 0o600 }towriteFileSync. Alternatively pipe the message togit commit -F -via stdin, which avoids the temp file entirely.Impact
Rare but real race conditions (wrong/empty commit messages under concurrency) and a local information-disclosure / file-precreation risk in a shared tmpdir.