The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): scope remote spawn umask 077 to the mkdir subshell
whyyagswhya0caeda3ada6
diff --git a/apps/desktop/electron/remote-lifecycle.test.ts b/apps/desktop/electron/remote-lifecycle.test.tsindex 9e5b0f196a0..9e380116474 100644--- a/apps/desktop/electron/remote-lifecycle.test.ts+++ b/apps/desktop/electron/remote-lifecycle.test.ts@@ -1518,6 +1518,35 @@ test('buildSpawnCommand lockfile publication is POSIX sh (no bash substitution)'assert.ok(cmd.includes('sed "s/__PID__/${child}/"'), 'pid substitution must use sed')})+test('buildSpawnCommand scopes umask 077 to the mkdir subshell (no leak into serve)', () => {+ const cmd = buildSpawnCommand('/x/hermes', 'work', {+ hermesHome: '~/.hermes',+ logPath: spawnLogPath(OWNERSHIP_ID, SPAWN_NONCE),+ ownershipId: OWNERSHIP_ID,+ reservationNonce: SPAWN_NONCE,+ spawnNonce: SPAWN_NONCE,+ tokenFilePath: spawnTokenPath(OWNERSHIP_ID, SPAWN_NONCE),+ lockMetadata: { ownershipId: OWNERSHIP_ID, pid: '__PID__' }+ })++ // umask 077 must apply only to the reservation-parent mkdir. A bare+ // umask call at the top level leaks 077 into the rest of the payload,+ // so the detached setsid backend inherits 077 instead of the login umask.+ assert.ok(+ cmd.includes('(umask 077 && mkdir -p'),+ 'umask 077 must be scoped to a mkdir subshell'+ )+ assert.doesNotMatch(+ cmd,+ /(^|[^(])umask 077/,+ 'no bare umask 077 may leak into the spawn chain'+ )+ assert.ok(+ cmd.indexOf('(umask 077') < cmd.indexOf('serve --isolated'),+ 'scoped mkdir must still precede the serve spawn'+ )+})+test('spawnRemoteDashboard removes a token file when upload reporting fails', async () => {const failure = new Error('channel closed')diff --git a/apps/desktop/electron/remote-lifecycle.ts b/apps/desktop/electron/remote-lifecycle.tsindex f088b5c254b..a6e00240eda 100644--- a/apps/desktop/electron/remote-lifecycle.ts+++ b/apps/desktop/electron/remote-lifecycle.ts@@ -1125,7 +1125,7 @@ function buildSpawnCommand(hermesPath, profile, opts: any = {}) {const reservationNonce = validateSpawnNonce(opts.reservationNonce || crypto.randomBytes(8).toString('hex'))return withRemoteUpdateMutex(- `umask 077 && mkdir -p "$(dirname ${reservation})"; ` ++ `(umask 077 && mkdir -p "$(dirname ${reservation})"); ` +// reservation/lockPath/ownerPath are expandRemotePath() output — already// shell-quoted fragments ("$HOME"'/…'). Embed raw so the assignment// expands $HOME; shq() here would store the quote characters literally