Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: deny git --output and global options on the unattended lane
[._.]/ Adam Eivy624867ad017b
diff --git a/server/lib/commandSecurity.js b/server/lib/commandSecurity.jsindex 2a4dd80bf6..6942875c66 100644--- a/server/lib/commandSecurity.js+++ b/server/lib/commandSecurity.js@@ -186,6 +186,13 @@ const GIT_TAG_MUTATING_FLAGS = new Set(['-d', '--delete', '-a', '--annotate', '-const GIT_LIST_MODE_FLAGS = new Set(['-l', '--list', '--contains', '--no-contains', '--points-at', '--merged', '--no-merged']);const GIT_REMOTE_READ_VERBS = new Set(['show', 'get-url']);+// `--output[=<file>]` on log/show/diff (and any verb sharing diff-options)+// writes the command's output to an arbitrary path — the same file-write+// primitive `find -fprint*` is denied for below (#12020). Checked for every+// verb rather than per verb so a newly allowlisted verb cannot inherit it.+// `--output-indicator-*` only changes diff markers and is not matched.+const GIT_OUTPUT_FLAG = '--output';+// `find` action flags: `-delete` removes files and `-exec`/`-ok` family runs// arbitrary binaries, which would defeat the allowlist entirely. `-f*print*`// writes attacker-chosen files. Everything else (`-name`, `-type`, `-maxdepth`,@@ -218,10 +225,20 @@ function isGitRefListing(sub, rest) {function validateUnattendedGit(args) {const sub = args[0];if (!sub) return deny("'git' needs a read-only subcommand on the unattended lane.");+ // Global options (`-c key=val`, `--git-dir`, `--work-tree`, `--exec-path`,+ // `--config-env`, `-C`) precede the verb and reconfigure what it runs+ // against; the verb must be the first argument.+ if (sub.startsWith('-')) {+ return deny(`'git ${sub}' is not allowed on the unattended lane — global options before the subcommand are rejected; the first argument must be a read-only verb.`);+ }if (!UNATTENDED_GIT_SUBCOMMANDS.has(sub)) {return deny(`'git ${sub}' is not allowed on the unattended lane — only read-only inspection subcommands are: ${[...UNATTENDED_GIT_SUBCOMMANDS].sort().join(', ')}.`);}const rest = args.slice(1);+ const outputFlag = rest.find(a => a === GIT_OUTPUT_FLAG || a.startsWith(`${GIT_OUTPUT_FLAG}=`));+ if (outputFlag) {+ return deny(`'git ${sub} ${outputFlag}' is not allowed on the unattended lane — '--output' writes command output to a file.`);+ }if (sub === 'config' && !rest.some(a => GIT_CONFIG_READ_FLAGS.has(a))) {return deny("'git config' is only allowed in its read form on the unattended lane (e.g. 'git config --get <key>').");}diff --git a/server/lib/commandSecurity.test.js b/server/lib/commandSecurity.test.jsindex 1a2a671a35..b1f3ee63d5 100644--- a/server/lib/commandSecurity.test.js+++ b/server/lib/commandSecurity.test.js@@ -448,6 +448,34 @@ describe('commandSecurity', () => {expect(validateUnattendedCommand(cmd).valid).toBe(false)})+ // `--output[=<file>]` is a file-write primitive on a lane documented as+ // read-only — the same class `find -fprint` is denied for (#12020).+ it.each([+ 'git log --output=notes.txt',+ 'git diff --output=notes.txt',+ 'git show --output=notes.txt',+ 'git log --oneline --output notes.txt',+ ])('rejects git --output file write: %s', (cmd) => {+ const result = validateUnattendedCommand(cmd)+ expect(result.valid).toBe(false)+ expect(result.error).toMatch(/--output/)+ })++ it('still accepts --output-indicator-* on git diff (a marker option, not a file write)', () => {+ expect(validateUnattendedCommand('git diff --output-indicator-new=+').valid).toBe(true)+ })++ it.each([+ ['-c injects config such as core.pager or a credential helper', 'git -c core.pager=less log'],+ ['--git-dir retargets the repository', 'git --git-dir=../other/.git log'],+ ['--work-tree retargets the checkout', 'git --work-tree=../other status'],+ ['--exec-path swaps the git binaries', 'git --exec-path=/opt/evil log'],+ ])('rejects a global option before the verb: %s', (_label, cmd) => {+ const result = validateUnattendedCommand(cmd)+ expect(result.valid).toBe(false)+ expect(result.error).toMatch(/global options before the subcommand/)+ })+it.each([['-delete removes files', 'find . -delete'],// The `{}` / `;` form is already caught by the metacharacter filter, so this