From 885da1f1b9a7ef07dd79d6746105cfa8237dbf61 Mon Sep 17 00:00:00 2001 From: tgolob <34978067+tgolob@users.noreply.github.com> Date: Sat, 22 Aug 2026 00:09:36 -0400 Subject: [PATCH] fix: protect bash login startup files --- README.md | 3 ++- src/sandbox/sandbox-utils.ts | 2 ++ test/sandbox/mandatory-deny-paths.test.ts | 16 ++++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 14d896861..1d91fc1d5 100644 --- a/README.md +++ b/README.md @@ -658,7 +658,8 @@ Certain sensitive files and directories are **always blocked from writes**, even **Always-blocked files:** -- Shell config files: `.bashrc`, `.bash_profile`, `.zshrc`, `.zprofile`, `.profile` +- Shell config files: `.bashrc`, `.bash_profile`, `.bash_login`, `.bash_logout`, + `.zshrc`, `.zprofile`, `.profile` - Git config files: `.gitconfig`, `.gitmodules` - Other sensitive files: `.ripgreprc`, `.mcp.json` diff --git a/src/sandbox/sandbox-utils.ts b/src/sandbox/sandbox-utils.ts index 933585175..6929d95d7 100644 --- a/src/sandbox/sandbox-utils.ts +++ b/src/sandbox/sandbox-utils.ts @@ -13,6 +13,8 @@ export const DANGEROUS_FILES = [ '.gitmodules', '.bashrc', '.bash_profile', + '.bash_login', + '.bash_logout', '.zshrc', '.zprofile', '.profile', diff --git a/test/sandbox/mandatory-deny-paths.test.ts b/test/sandbox/mandatory-deny-paths.test.ts index e82ca64bd..f6ea4701f 100644 --- a/test/sandbox/mandatory-deny-paths.test.ts +++ b/test/sandbox/mandatory-deny-paths.test.ts @@ -56,6 +56,8 @@ describe.if(isSupportedPlatform)( // Create ALL dangerous files from DANGEROUS_FILES writeFileSync(join(TEST_DIR, '.bashrc'), ORIGINAL_CONTENT) writeFileSync(join(TEST_DIR, '.bash_profile'), ORIGINAL_CONTENT) + writeFileSync(join(TEST_DIR, '.bash_login'), ORIGINAL_CONTENT) + writeFileSync(join(TEST_DIR, '.bash_logout'), ORIGINAL_CONTENT) writeFileSync(join(TEST_DIR, '.gitconfig'), ORIGINAL_CONTENT) writeFileSync(join(TEST_DIR, '.gitmodules'), ORIGINAL_CONTENT) writeFileSync(join(TEST_DIR, '.zshrc'), ORIGINAL_CONTENT) @@ -217,6 +219,20 @@ describe.if(isSupportedPlatform)( expect(readFileSync('.bash_profile', 'utf8')).toBe(ORIGINAL_CONTENT) }) + it('blocks writes to .bash_login', async () => { + const result = await runSandboxedWrite('.bash_login', MODIFIED_CONTENT) + + expect(result.success).toBe(false) + expect(readFileSync('.bash_login', 'utf8')).toBe(ORIGINAL_CONTENT) + }) + + it('blocks writes to .bash_logout', async () => { + const result = await runSandboxedWrite('.bash_logout', MODIFIED_CONTENT) + + expect(result.success).toBe(false) + expect(readFileSync('.bash_logout', 'utf8')).toBe(ORIGINAL_CONTENT) + }) + it('blocks writes to .zprofile', async () => { const result = await runSandboxedWrite('.zprofile', MODIFIED_CONTENT)