From 452624f4522b6692698a9fc564a45e8fc7742c72 Mon Sep 17 00:00:00 2001 From: Nicholas023 <498594526@qq.com> Date: Thu, 19 Nov 2026 00:08:42 +0800 Subject: [PATCH 1/7] fix(niubash): arm the prepared-root boundary only in confined modes (#870) A default DSH_HOME (~/.dsh) inside a home workspace made every full-access Niubash call refuse with 'the prepared payload must be outside the session workspace'. The boundary exists so confined workspace labeling and write gating never reach an executable through the workspace or a junction into it; full access runs without confinement and is not a security boundary against the account, so the refusal only removed a working configuration. --- docs/CHANGELOG.md | 9 ++++ docs/troubleshooting.md | 16 +++--- src/niubash/runtime.ts | 7 ++- src/shells/session-execution.ts | 2 +- test/niubash-workspace-mode.test.mjs | 29 +++++++++++ .../shells-niubash-prepared-boundary.test.mjs | 49 +++++++++++++++++++ 6 files changed, 102 insertions(+), 10 deletions(-) create mode 100644 test/niubash-workspace-mode.test.mjs create mode 100644 test/shells-niubash-prepared-boundary.test.mjs diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index d66194e1..54c02a19 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -7,6 +7,15 @@ this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## [Unreleased] +- Niubash no longer refuses to prepare its runtime when a full-access session's workspace contains + the default `~/.dsh` home (#870). The workspace boundary stays armed in read-only and + workspace-write modes, where host workspace labeling and write gating could otherwise reach the + executable; full access runs without confinement, so the refusal only made a default `DSH_HOME` + under a home workspace unusable. +- Niubash 在 full-access 会话的 workspace 包含默认 `~/.dsh` 时不再拒绝准备运行时(#870)。 + workspace 边界在 read-only 与 workspace-write 模式仍然生效——host 的 workspace 标注与写限制 + 本可能经由 workspace 触及可执行文件;full access 本就不经过 confinement,该拒绝只会让默认 + `DSH_HOME` 落在 home workspace 下的会话完全不可用。 - Native tool construction and the publication refusal queue no longer attach listeners or lifetime effects to the composition root. The evidence observer and result admission subscribe on the caller's context with global dispatch, and the refusal queue falls back to the caller lifetime when the root refuses an effect. dsh-tui 0.20 refuses `root.events.on` and `root.effect` from a plugin activation, and the native-tools row is one, so every `dsh-tui --resume` aborted with "cannot resume session" before the agent mounted. - 原生工具构造与发布拒绝队列不再向组合根挂监听或生命周期 effect:证据观察者与 result admission 改为在调用方上下文订阅并声明 global 分发,拒绝队列在 root 拒绝 effect 时回落到调用方生命周期。dsh-tui 0.20 会拒绝插件激活期内的 `root.events.on` 与 `root.effect`,而原生工具行正是插件激活,导致每次 `dsh-tui --resume` 都在 agent 挂载前报 "cannot resume session"。 - The Bash tool description now states the parse contract of `stdout`/`stderr` where the model reads it: `text` may be a partial fragment, `truncated` marks one that must not be parsed as complete structured output, and `spillPath` is optional and not a completeness guarantee. The typed output schema is unchanged: repeating the contract there would cost every PTC request without saying anything the tool text does not. Command semantics, exit codes, result values, limits, spill files, permissions and rendering are unchanged. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index b58646e9..4a7791a1 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -134,17 +134,19 @@ publishes the completed tree with an atomic sibling rename. Later calls check on prepared `niu.exe` still exists; they do not clone, hash, seal, write an execution receipt or dispose a per-call tree. Files the shell writes into its state directories are never inspected. -The prepared runtime must be **outside the session workspace**. Every call checks that boundary -and still uses the host's subprocess service and sandbox `confine` in restricted modes. In read-only and -workspace-write modes, the host denies writes to both the source and prepared payload outside the -workspace. Full-access mode keeps its normal host policy; the prepared directory is not a separate -security boundary against the account or an administrator. +The prepared runtime must be **outside the session workspace** in confined sessions. Read-only and +workspace-write modes check that boundary on every call and still use the host's subprocess service +and sandbox `confine`; the host denies writes to both the source and prepared payload outside the +workspace. Full-access mode keeps its normal host policy and runs a prepared root inside the +workspace — the default `~/.dsh` under a home workspace — instead of refusing it, because it is +not a separate security boundary against the account or an administrator (#870). - On first preparation only, Windows scanner/indexer handles can delay the atomic publication rename. Only `EPERM`/`EACCES`/`EBUSY` rename refusals are backed off, asynchronously, for up to 10 seconds; a persistent failure names the rename in `EXECUTOR_UNAVAILABLE`. Commands are never retried. -- Put `DSH_HOME` outside the workspace before starting DSH. A workspace containing the prepared - runtime is refused rather than silently moving the runtime or running without confinement. +- For confined sessions, put `DSH_HOME` outside the workspace before starting DSH. A workspace + containing the prepared runtime is refused in read-only and workspace-write modes rather than + silently moving the runtime or running without confinement; full access runs it where it is. - `DSH_OPS_EXEC_ROOT` and `NIUBASH_VERIFY=deep` are deprecated and ignored for new calls. Antivirus allow-list rules should target the fixed prepared location, not a per-call temporary directory. - For leftovers from older releases, stop **every OPS host and Bash job**, then use the installed diff --git a/src/niubash/runtime.ts b/src/niubash/runtime.ts index 7e8a96e7..50790c43 100644 --- a/src/niubash/runtime.ts +++ b/src/niubash/runtime.ts @@ -163,13 +163,16 @@ async function physicalPath(file: string): Promise { /** Command-time runtime for a selected payload. Host workspace labeling must never reach an * executable through the workspace or a junction into it, so the prepared root is checked first. + * Full access runs without confinement and keeps the account's own authority over every path + * (#870); the refusal guards exactly the confined modes that label and gate the workspace. */ export async function prepareNiubash(selected: string, inheritedPath = process.env.PATH ?? process.env.Path ?? '', signal: AbortSignal, - { workspaceRoot, env = process.env }: { workspaceRoot?: string; env?: NodeJS.ProcessEnv } = {}): Promise { + { workspaceRoot, mode, env = process.env }: { workspaceRoot?: string; mode?: 'read-only' | 'workspace-write' | 'danger-full-access'; env?: NodeJS.ProcessEnv } = {}): Promise { signal.throwIfAborted() if (!path.isAbsolute(selected) || !isNiubashExecutable(selected)) throw unavailable('expected an absolute niu.exe path') const source = path.dirname(selected), target = niubashPreparedRoot(env) - if (workspaceRoot && (inside(target, path.resolve(workspaceRoot)) || inside(await physicalPath(target), await physicalPath(workspaceRoot)))) { + if (workspaceRoot && mode !== 'danger-full-access' + && (inside(target, path.resolve(workspaceRoot)) || inside(await physicalPath(target), await physicalPath(workspaceRoot)))) { throw unavailable('the prepared payload must be outside the session workspace; move DSH_HOME outside the workspace') } let file: string diff --git a/src/shells/session-execution.ts b/src/shells/session-execution.ts index c97981a3..1629d08a 100644 --- a/src/shells/session-execution.ts +++ b/src/shells/session-execution.ts @@ -32,7 +32,7 @@ export function startSessionBash({ ctx, bash, active }: { ctx: ShellContext; bas assertAuthority() try { const runtime = native ? await prepareNiubash(bash.file, dshEnv.PATH ?? dshEnv.Path ?? process.env.PATH, signal, - { workspaceRoot: typeof policy.workspaceRoot === 'string' ? policy.workspaceRoot : undefined }) + { workspaceRoot: typeof policy.workspaceRoot === 'string' ? policy.workspaceRoot : undefined, mode: policy.mode }) : policy.mode === 'danger-full-access' ? { file: bash.file } : confinedBash(bash.file, { source: bash.source }) if (native) for (const key of Object.keys(env)) if (['PATH', 'NIU_ROOT', 'WINUXCMD_PATH', 'NIU_SKIP_WINUXCMD_ACTIVATION'].includes(key.toUpperCase())) delete env[key] Object.assign(env, native ? runtime.env : { ...runtime.env, ...dshEnv }) diff --git a/test/niubash-workspace-mode.test.mjs b/test/niubash-workspace-mode.test.mjs new file mode 100644 index 00000000..57ec35a0 --- /dev/null +++ b/test/niubash-workspace-mode.test.mjs @@ -0,0 +1,29 @@ +/** The prepared-root workspace boundary is armed for confined modes only (#870). */ +import path from 'node:path' +import { niubashPreparedRoot, prepareNiubash } from '../lib/niubash/runtime.js' +import { NIUBASH_PACKAGE_PATH } from '../lib/cli/niubash-payload.js' +import { syntheticNiubashTree } from './lib/niubash-distribution-fixture.mjs' +import { assert, report, test, withTempDir } from './lib/harness.mjs' + +const signal = new AbortController().signal + +await test('full access prepares a workspace-contained DSH_HOME; confined modes still refuse it', async () => { + await withTempDir('niu-ws-mode', async root => { + const source = syntheticNiubashTree(path.join(root, 'package', NIUBASH_PACKAGE_PATH)) + const file = path.join(source, 'niu.exe') + const inside = { DSH_HOME: path.join(root, 'home') } + const prepare = mode => prepareNiubash(file, 'inherited', signal, { workspaceRoot: root, env: inside, ...(mode ? { mode } : {}) }) + // Full access runs unconfined and keeps the account's own authority over every path, so the + // default DSH_HOME inside a home workspace must not make Niubash unusable (#870). + const full = await prepare('danger-full-access') + assert.equal(full.file, path.join(niubashPreparedRoot(inside), 'niu.exe')) + assert.equal(full.env.PATH.split(path.delimiter).at(-1), 'inherited', 'the inherited PATH stays last') + assert.equal(full.env.NIU_ROOT, path.join(niubashPreparedRoot(inside), 'winuxcmd')) + // Confined modes keep the refusal: workspace labeling must never reach an executable. + for (const mode of ['read-only', 'workspace-write', undefined]) { + await assert.rejects(prepare(mode), error => error.message.startsWith('EXECUTOR_UNAVAILABLE:') + && error.message.includes('outside the session workspace')) + } + }) +}) +report('niubash-workspace-mode') diff --git a/test/shells-niubash-prepared-boundary.test.mjs b/test/shells-niubash-prepared-boundary.test.mjs new file mode 100644 index 00000000..3726fa55 --- /dev/null +++ b/test/shells-niubash-prepared-boundary.test.mjs @@ -0,0 +1,49 @@ +/** The session layer arms the prepared-root boundary only for confined modes (#870). */ +import path from 'node:path' +import { startSessionBash } from '../lib/shells/session-execution.js' +import { niubashPreparedRoot } from '../lib/niubash/runtime.js' +import { NIUBASH_PACKAGE_PATH } from '../lib/cli/niubash-payload.js' +import { syntheticNiubashTree } from './lib/niubash-distribution-fixture.mjs' +import { assert, report, skipSuite, TEST_HOME, test, withTempDir } from './lib/harness.mjs' + +if (process.platform !== 'win32') skipSuite('shells-niubash-prepared-boundary', 'requires the Windows Niubash runtime branch') + +await test('full access executes with the prepared root inside the workspace; confined modes refuse it', async () => { + await withTempDir('niu-boundary', async root => { + const source = syntheticNiubashTree(path.join(root, 'package', NIUBASH_PACKAGE_PATH)) + let argv0, spawnCalls = 0 + const run = mode => { + // The test process DSH_HOME (TEST_HOME) is itself the workspace root, so the prepared + // root it selects is contained in the workspace exactly like a default ~/.dsh inside + // a home workspace (#870). + const policy = { mode, workspaceRoot: TEST_HOME } + const agent = { id: 'niu-boundary', session: { id: 'niu-boundary', header: { cwd: root } } } + const ctx = { + get(name) { + if (name === 'sandboxPolicy') return { resolve: () => policy } + if (name === 'sandbox') return { confine: async argv => ({ argv, enforcement: 'partial' }) } + if (name === 'subprocess') return { + spawn(spec) { + spawnCalls++; argv0 = spec.argv[0] + const stream = text => ({ readFrom: () => ({ text, nextOffset: text.length, lossy: false }) }) + return { done: Promise.resolve({ exitCode: 0, signal: null }), collected: { stdout: stream('ok'), stderr: stream('') } } + }, + } + return undefined + }, + } + const execution = startSessionBash({ ctx, bash: { file: path.join(source, 'niu.exe'), source: 'bundled' }, active: () => true }, + { command: 'true', workdir: root }, { agent, signal: new AbortController().signal }, policy, policy, {}, {}) + return execution.result() + } + const full = await run('danger-full-access') + assert.equal(full.error, undefined, JSON.stringify(full)) + assert.equal(full.status, 'completed', JSON.stringify(full)) + assert.equal(spawnCalls, 1, 'full access spawned the prepared runtime') + assert.equal(argv0, path.join(niubashPreparedRoot(), 'niu.exe'), 'full access executes the prepared runtime') + const denied = await run('workspace-write') + assert.match(denied.error, /EXECUTOR_UNAVAILABLE:.*outside the session workspace/) + assert.equal(spawnCalls, 1, 'the confined refusal spawned nothing') + }) +}) +report('shells-niubash-prepared-boundary') From 5a88d96469e8325c15aaac06fa3c0e3a24e4a756 Mon Sep 17 00:00:00 2001 From: Nicholas023 <498594526@qq.com> Date: Thu, 19 Nov 2026 00:10:23 +0800 Subject: [PATCH 2/7] fix(shells): classify the shared MSYS section failure as executor-unavailable (#409) msys-2.0.dll prints a per-user section conflict as 'CreateFileMapping S-., Win32 error 5. Terminating.' with no 'fatal error' prefix, so the restricted-token runtime failure reached the model as a bare non-zero exit and read like a command or denial problem. Classify that message like the signal-pipe failure: EXECUTOR_UNAVAILABLE with sandbox.runnerFailed, never a user authorization denial. The proxy still arms only new objects; a foreign DACL is not rewritten. --- docs/CHANGELOG.md | 9 +++++ docs/windows-runtime-evidence.md | 6 ++++ docs/windows-runtime-evidence.zh.md | 5 +++ src/shells/session-execution.ts | 5 ++- test/shells-msys-shared-section.test.mjs | 44 ++++++++++++++++++++++++ 5 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 test/shells-msys-shared-section.test.mjs diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 54c02a19..195f7a44 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -16,6 +16,15 @@ this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm workspace 边界在 read-only 与 workspace-write 模式仍然生效——host 的 workspace 标注与写限制 本可能经由 workspace 触及可执行文件;full access 本就不经过 confinement,该拒绝只会让默认 `DSH_HOME` 落在 home workspace 下的会话完全不可用。 +- ops_bash classifies the msys-2.0.dll shared-section startup failure + ("CreateFileMapping S-., Win32 error 5", printed without any "fatal + error" prefix) as EXECUTOR_UNAVAILABLE with `sandbox.runnerFailed`, so a restricted + token hitting an unrestricted MSYS holder's per-user section is no longer presented + as a bare non-zero exit (#409). +- ops_bash 将 msys-2.0.dll 的共享段启动失败("CreateFileMapping S-<用户 SID>., + Win32 error 5",打印时不带任何 "fatal error" 前缀)归类为 EXECUTOR_UNAVAILABLE 并带 + `sandbox.runnerFailed`:受限令牌撞上非受限 MSYS 持有者的用户级共享段时,不再只呈现 + 一个裸的非零退出码(#409)。 - Native tool construction and the publication refusal queue no longer attach listeners or lifetime effects to the composition root. The evidence observer and result admission subscribe on the caller's context with global dispatch, and the refusal queue falls back to the caller lifetime when the root refuses an effect. dsh-tui 0.20 refuses `root.events.on` and `root.effect` from a plugin activation, and the native-tools row is one, so every `dsh-tui --resume` aborted with "cannot resume session" before the agent mounted. - 原生工具构造与发布拒绝队列不再向组合根挂监听或生命周期 effect:证据观察者与 result admission 改为在调用方上下文订阅并声明 global 分发,拒绝队列在 root 拒绝 effect 时回落到调用方生命周期。dsh-tui 0.20 会拒绝插件激活期内的 `root.events.on` 与 `root.effect`,而原生工具行正是插件激活,导致每次 `dsh-tui --resume` 都在 agent 挂载前报 "cannot resume session"。 - The Bash tool description now states the parse contract of `stdout`/`stderr` where the model reads it: `text` may be a partial fragment, `truncated` marks one that must not be parsed as complete structured output, and `spillPath` is optional and not a completeness guarantee. The typed output schema is unchanged: repeating the contract there would cost every PTC request without saying anything the tool text does not. Command semantics, exit codes, result values, limits, spill files, permissions and rendering are unchanged. diff --git a/docs/windows-runtime-evidence.md b/docs/windows-runtime-evidence.md index a04240ca..9f76f768 100644 --- a/docs/windows-runtime-evidence.md +++ b/docs/windows-runtime-evidence.md @@ -59,6 +59,12 @@ payload/root, whether an owned normal-token holder is alive, stderr, exit value, and a restricted positive control. Stop only jobs you own; do not kill all Bash processes or rewrite foreign ACLs to make a comparison pass. +An unrestricted MSYS process that created the per-user section first omits every +restricted-logon ACE, so the restricted token cannot reopen it; the proxy only arms +**new** objects. `ops_bash` classifies this message as `EXECUTOR_UNAVAILABLE` with +`sandbox.runnerFailed`, like the signal-pipe failure, instead of presenting a bare +non-zero exit (#409); it is never a user authorization denial. + `3221225794` and `-1073741502` represent `0xC0000142`. The status alone does not identify the failing DLL or prove which process reached the command. A manual launch of a staged restricted payload under a normal token is unsupported: its diff --git a/docs/windows-runtime-evidence.zh.md b/docs/windows-runtime-evidence.zh.md index d9de93e1..ba6cc3b1 100644 --- a/docs/windows-runtime-evidence.zh.md +++ b/docs/windows-runtime-evidence.zh.md @@ -47,6 +47,11 @@ Get-FileHash -LiteralPath '<实际 msys-2.0.dll 路径>' -Algorithm SHA256 是否仍存活、stderr、退出值及受限正向对照。只停止自己拥有的任务,不要杀死所有 Bash 或重写外部对象 ACL 来让测试通过。 +先以非受限令牌创建该用户 section 的 MSYS 进程不包含任何受限登录会话 ACE,受限令牌因此 +无法重新打开它;代理只为**新建**对象附加权限。`ops_bash` 现在把这条消息与信号管失败一样 +归类为 `EXECUTOR_UNAVAILABLE`(带 `sandbox.runnerFailed`),不再只呈现裸的非零退出码(#409); +它绝不是一次用户授权拒绝。 + `3221225794` 与 `-1073741502` 都表示 `0xC0000142`;数字本身不说明哪个 DLL 失败,也不证明哪个进程已执行命令。不支持用普通令牌手动启动 staged 受限载荷:其 IPC 代理要求受限 Low 令牌。请通过 OPS 工具测试宿主实际 confinement 路径,保留完整 stderr, diff --git a/src/shells/session-execution.ts b/src/shells/session-execution.ts index 1629d08a..6467c85f 100644 --- a/src/shells/session-execution.ts +++ b/src/shells/session-execution.ts @@ -57,7 +57,10 @@ export function startSessionBash({ ctx, bash, active }: { ctx: ShellContext; bas (!rule.allowedExitCodes || (value.exitCode != null && rule.allowedExitCodes.includes(value.exitCode))) && stderr.split(/\r?\n/).filter(line => !rule.informationalLines?.some(info => info.toLowerCase() === line.toLowerCase())) .some(line => rule.fatalSignatures?.some(signature => line.toLowerCase().includes(signature.toLowerCase())))) - const unavailable = runnerFailed || /couldn't create signal pipe|fatal error.*win32 error|sandbox_unavailable/i.test(stderr) + // msys-2.0.dll reports a shared-section conflict as "CreateFileMapping %W, %E." + // without any "fatal error" prefix: an unrestricted MSYS process created the per-user + // section first with no restricted-logon ACE, so the restricted token cannot reopen it (#409). + const unavailable = runnerFailed || /couldn't create signal pipe|createfilemapping\b.*win32 error|fatal error.*win32 error|sandbox_unavailable/i.test(stderr) const denied = !unavailable && value.exitCode !== 0 && confinement?.denialSignatures?.some(signature => stderr.toLowerCase().includes(signature.toLowerCase())) return withBashStatus({ ...value, ...(unavailable ? { error: 'EXECUTOR_UNAVAILABLE: the sandbox runtime failed before the command ran; this is not a user authorization denial. Restore the runtime or confinement provider; changing the DSH selector is not a repair. Do not bypass confinement.' } : {}), diff --git a/test/shells-msys-shared-section.test.mjs b/test/shells-msys-shared-section.test.mjs new file mode 100644 index 00000000..507f631b --- /dev/null +++ b/test/shells-msys-shared-section.test.mjs @@ -0,0 +1,44 @@ +/** A shared MSYS section failure reports as the runtime failure it is (#409). */ +import path from 'node:path' +import { startSessionBash } from '../lib/shells/session-execution.js' +import { NIUBASH_PACKAGE_PATH } from '../lib/cli/niubash-payload.js' +import { syntheticNiubashTree } from './lib/niubash-distribution-fixture.mjs' +import { assert, report, skipSuite, test, withTempDir } from './lib/harness.mjs' + +if (process.platform !== 'win32') skipSuite('shells-msys-shared-section', 'requires the Windows Niubash runtime branch') + +await test('a CreateFileMapping shared-section failure is EXECUTOR_UNAVAILABLE, never a denial', async () => { + await withTempDir('niu-section', async root => { + const source = syntheticNiubashTree(path.join(root, 'package', NIUBASH_PACKAGE_PATH)) + const policy = { mode: 'workspace-write', workspaceRoot: root } + const agent = { id: 'niu-section', session: { id: 'niu-section', header: { cwd: root } } } + // msys-2.0.dll prints exactly "CreateFileMapping %W, %E. Terminating." with %E as + // "Win32 error %d": a restricted token cannot reopen a per-user section an unrestricted + // MSYS process created first, because that object's DACL has no restricted-logon ACE (#409). + const sectionFailure = 'bash: CreateFileMapping S-1-5-21-500-1001.1, Win32 error 5. Terminating.' + const ctx = { + get(name) { + if (name === 'sandboxPolicy') return { resolve: () => policy } + if (name === 'sandbox') return { confine: async argv => ({ argv, enforcement: 'partial', denialSignatures: ['permission denied'] }) } + if (name === 'subprocess') return { + spawn() { + const stream = text => ({ readFrom: () => ({ text, nextOffset: text.length, lossy: false }) }) + return { done: Promise.resolve({ exitCode: 126, signal: null }), collected: { stdout: stream(''), stderr: stream(sectionFailure) } } + }, + } + return undefined + }, + } + const execution = startSessionBash({ ctx, bash: { file: path.join(source, 'niu.exe'), source: 'bundled' }, active: () => true }, + { command: 'true', workdir: root }, { agent, signal: new AbortController().signal }, policy, policy, {}, {}) + const value = await execution.result() + assert.match(value.stderr.text, /CreateFileMapping/, 'the simulated stderr reached the result') + // The shared-section conflict belongs to the restricted-token runtime, exactly like the + // signal-pipe failure, so the model must not read it as a user authorization denial. + assert.match(value.error ?? '', /EXECUTOR_UNAVAILABLE/) + assert.equal(value.sandbox.runnerFailed, true) + assert.equal(value.sandbox.denied, false, 'a shared-section conflict is not a user authorization denial') + assert.equal(value.exitCode, 126) + }) +}) +report('shells-msys-shared-section') From c38a8a96d643dfebd41050c059eb0b49b3d36bc8 Mon Sep 17 00:00:00 2001 From: Nicholas023 <498594526@qq.com> Date: Thu, 19 Nov 2026 00:13:20 +0800 Subject: [PATCH 3/7] test(shells): guard the full-access confinement projection (#581) A report described ops_bash children still carrying the restricted Low token (S-1-16-4096) in danger-full-access while the host pwsh ran Medium. The projection chain (standing policy, per-call approval, the full-access short-circuit and the skipped confine) checks out in this repository, and a full-access child reports the caller's own integrity label here, so the failure did not reproduce. Lock the boundary with a guard that fails when full access ever routes through confinedBash or sandbox.confine, and document the whoami /groups token comparison for the next report. --- docs/CHANGELOG.md | 11 ++++ docs/troubleshooting.md | 22 +++++++ test/shells-full-access-confinement.test.mjs | 64 ++++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 test/shells-full-access-confinement.test.mjs diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 195f7a44..540e5956 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -25,6 +25,17 @@ this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm Win32 error 5",打印时不带任何 "fatal error" 前缀)归类为 EXECUTOR_UNAVAILABLE 并带 `sandbox.runnerFailed`:受限令牌撞上非受限 MSYS 持有者的用户级共享段时,不再只呈现 一个裸的非零退出码(#409)。 +- A regression guard locks the full-access projection of ops_bash: the selected + payload spawns without sandbox.confine and a plain bashPath runs directly, while + confined modes still route through confinement (#581). The reported full-access + child carrying a Low token (S-1-16-4096) did not reproduce on 0.5.5 — a + full-access child reported the caller's own integrity label here — so the guard + and the token-comparison diagnosis document the boundary instead of claiming a + code fix. +- 回归守卫锁定 ops_bash 的 full-access 投影:所选载荷不经 sandbox.confine 直接 spawn, + 普通 bashPath 直接运行,受限模式仍走 confinement(#581)。报告的 full-access 子进程 + Low 令牌(S-1-16-4096)在 0.5.5 上未能复现——本机 full-access 子进程回报调用方自身的 + 完整性标签——因此以守卫与令牌对照诊断记录该边界,而非声称代码修复。 - Native tool construction and the publication refusal queue no longer attach listeners or lifetime effects to the composition root. The evidence observer and result admission subscribe on the caller's context with global dispatch, and the refusal queue falls back to the caller lifetime when the root refuses an effect. dsh-tui 0.20 refuses `root.events.on` and `root.effect` from a plugin activation, and the native-tools row is one, so every `dsh-tui --resume` aborted with "cannot resume session" before the agent mounted. - 原生工具构造与发布拒绝队列不再向组合根挂监听或生命周期 effect:证据观察者与 result admission 改为在调用方上下文订阅并声明 global 分发,拒绝队列在 root 拒绝 effect 时回落到调用方生命周期。dsh-tui 0.20 会拒绝插件激活期内的 `root.events.on` 与 `root.effect`,而原生工具行正是插件激活,导致每次 `dsh-tui --resume` 都在 agent 挂载前报 "cannot resume session"。 - The Bash tool description now states the parse contract of `stdout`/`stderr` where the model reads it: `text` may be a partial fragment, `truncated` marks one that must not be parsed as complete structured output, and `spillPath` is optional and not a completeness guarantee. The typed output schema is unchanged: repeating the contract there would cost every PTC request without saying anything the tool text does not. Command semantics, exit codes, result values, limits, spill files, permissions and rendering are unchanged. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 4a7791a1..7902324a 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -109,6 +109,28 @@ What to do: - Or switch the session to `danger-full-access`, where `bashPath` runs directly. - Check with the profile's own copy: `node "\node_modules\dsh-ops\bin\dsh-ops.mjs" ladder --config ` reports `restricted: yes/no` for the resolved bash. +### A full-access `ops_bash` child seems to keep the restricted Low token + +The session mode projects straight through in full access: the selected payload +spawns without `sandbox.confine`, a plain `bashPath` runs directly, and the child +carries the session's own token. Compare the tokens from the same caller before +assigning a cause (#581): + +```console +MSYS2_ARG_CONV_EXCL='*' /c/Windows/System32/whoami.exe /groups +``` + +The `Mandatory Label` line is the child's integrity level: `S-1-16-4096` is Low, +`S-1-16-8192` Medium, and an elevated caller reports higher. A confined-mode child +is expected to differ from the host shell; a full-access child must match the +session's own level. A full-access child that still reports Low is a host +token-construction difference, not a dsh-ops setting: collect both `whoami.exe +/groups` outputs, the DSH core, OPS and Bash payload versions, and the exact +executable paths, and report them with the [runtime evidence +guide](windows-runtime-evidence.md). The plugin-side projection is guarded by +`test/shells-full-access-confinement.test.mjs`, which fails if a full-access +call ever routes through `confinedBash` or `sandbox.confine`. + ### Restricted Bash is still preparing, or its last preparation was interrupted Symptom, in a read-only or workspace-write session: an `EXECUTOR_UNAVAILABLE` whose second segment names a stage, for example `EXECUTOR_UNAVAILABLE: bash-staging-failed: …`, `bash-generation-quarantine-failed: …` or `bash-lifecycle-lock-busy: …`. diff --git a/test/shells-full-access-confinement.test.mjs b/test/shells-full-access-confinement.test.mjs new file mode 100644 index 00000000..4aea9fca --- /dev/null +++ b/test/shells-full-access-confinement.test.mjs @@ -0,0 +1,64 @@ +/** Full access projects straight through; confinement is a confined-mode fact (#581). */ +import path from 'node:path' +import { startSessionBash } from '../lib/shells/session-execution.js' +import { NIUBASH_PACKAGE_PATH } from '../lib/cli/niubash-payload.js' +import { syntheticNiubashTree } from './lib/niubash-distribution-fixture.mjs' +import { assert, report, skipSuite, test, withTempDir } from './lib/harness.mjs' + +if (process.platform !== 'win32') skipSuite('shells-full-access-confinement', 'requires the Windows Niubash runtime branch') + +await test('full access spawns directly and never confines; confined modes route through confine', async () => { + await withTempDir('niu-full-access', async root => { + const source = syntheticNiubashTree(path.join(root, 'package', NIUBASH_PACKAGE_PATH)) + const scenarios = [ + { label: 'the Niubash runtime', file: path.join(source, 'niu.exe') }, + { label: 'a plain bash payload', file: path.join(root, 'bash.exe') }, + ] + for (const { label, file } of scenarios) { + let argv0, confineCalls = 0, spawnCalls = 0 + const run = mode => { + const policy = { mode, workspaceRoot: root } + const agent = { id: 'niu-full-access', session: { id: 'niu-full-access', header: { cwd: root } } } + const ctx = { + get(name) { + if (name === 'sandboxPolicy') return { resolve: () => policy } + if (name === 'sandbox') return { confine: async argv => { confineCalls++; return { argv, enforcement: 'partial' } } } + if (name === 'subprocess') return { + spawn(spec) { + spawnCalls++; argv0 = spec.argv[0] + const stream = text => ({ readFrom: () => ({ text, nextOffset: text.length, lossy: false }) }) + return { done: Promise.resolve({ exitCode: 0, signal: null }), collected: { stdout: stream('ok'), stderr: stream('') } } + }, + } + return undefined + }, + } + const execution = startSessionBash({ ctx, bash: { file, source: 'config' }, active: () => true }, + { command: 'true', workdir: root }, { agent, signal: new AbortController().signal }, policy, policy, {}, {}) + return execution.result() + } + // Full access keeps the caller's own token: no confinement, no runner downgrade (#581). + const full = await run('danger-full-access') + assert.equal(full.error, undefined, `${label}: ${JSON.stringify(full)}`) + assert.equal(full.status, 'completed', `${label}: ${JSON.stringify(full)}`) + assert.equal(spawnCalls, 1, `${label}: full access spawned once`) + assert.equal(confineCalls, 0, `${label}: full access never asks the sandbox to confine`) + if (file.endsWith('niu.exe')) assert.equal(path.basename(argv0), 'niu.exe', `${label}: the prepared runtime executes`) + else assert.equal(argv0, file, `${label}: the configured payload executes unchanged`) + // A confined mode must pass through the sandbox before the spawn; a plain bash.exe + // that is not the supported MSYS payload is refused by confinedBash instead, which is + // exactly the call full access must never make. + const confined = await run('workspace-write') + if (file.endsWith('niu.exe')) { + assert.equal(confined.error, undefined, `${label}: ${JSON.stringify(confined)}`) + assert.equal(confineCalls, 1, `${label}: the confined mode routed through confine exactly once`) + assert.equal(spawnCalls, 2, `${label}: the confined mode spawned once more`) + } else { + assert.match(confined.error ?? '', /EXECUTOR_UNAVAILABLE:.*restricted modes/, `${label}: a foreign payload is refused in confined modes`) + assert.equal(confineCalls, 0, `${label}: the refusal precedes confinement`) + assert.equal(spawnCalls, 1, `${label}: the refusal spawned nothing`) + } + } + }) +}) +report('shells-full-access-confinement') From 197a000f3ac8287192fa2a3553425f2af23a13cb Mon Sep 17 00:00:00 2001 From: Nicholas023 <498594526@qq.com> Date: Thu, 19 Nov 2026 00:14:40 +0800 Subject: [PATCH 4/7] docs(troubleshooting): record the niu-Git shebang hook failure (#958) A husky v9 hook with the shebang #!/usr/bin/env sh failed under the niu-Git command while the same script with #!/bin/sh ran. The interpreter lookup happens inside the niu-Git payload, which this repository cannot patch, so the entry documents the diagnostic pair and the shebang workaround and marks the root cause unresolved-upstream. --- docs/CHANGELOG.md | 9 +++++++++ docs/troubleshooting.md | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 540e5956..fa94e085 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -36,6 +36,15 @@ this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm 普通 bashPath 直接运行,受限模式仍走 confinement(#581)。报告的 full-access 子进程 Low 令牌(S-1-16-4096)在 0.5.5 上未能复现——本机 full-access 子进程回报调用方自身的 完整性标签——因此以守卫与令牌对照诊断记录该边界,而非声称代码修复。 +- Document the niu-Git hook failure whose only difference is the shebang: + `#!/usr/bin/env sh` fails while `#!/bin/sh` runs, so husky v9 hooks are + affected. The interpreter resolution lives inside the niu-Git payload, so the + entry records the diagnostic pair and the `#!/bin/sh` workaround instead of + claiming a repository fix (#958, unresolved-upstream). +- 记录 niu-Git 钩子失败:唯一差异是 shebang——`#!/usr/bin/env sh` 失败而 + `#!/bin/sh` 可运行,husky v9 钩子同样受影响。解释器解析位于 niu-Git 载荷内部, + 因此该条目记录诊断对照与 `#!/bin/sh` 缓解,而非声称本仓修复(#958, + unresolved-upstream)。 - Native tool construction and the publication refusal queue no longer attach listeners or lifetime effects to the composition root. The evidence observer and result admission subscribe on the caller's context with global dispatch, and the refusal queue falls back to the caller lifetime when the root refuses an effect. dsh-tui 0.20 refuses `root.events.on` and `root.effect` from a plugin activation, and the native-tools row is one, so every `dsh-tui --resume` aborted with "cannot resume session" before the agent mounted. - 原生工具构造与发布拒绝队列不再向组合根挂监听或生命周期 effect:证据观察者与 result admission 改为在调用方上下文订阅并声明 global 分发,拒绝队列在 root 拒绝 effect 时回落到调用方生命周期。dsh-tui 0.20 会拒绝插件激活期内的 `root.events.on` 与 `root.effect`,而原生工具行正是插件激活,导致每次 `dsh-tui --resume` 都在 agent 挂载前报 "cannot resume session"。 - The Bash tool description now states the parse contract of `stdout`/`stderr` where the model reads it: `text` may be a partial fragment, `truncated` marks one that must not be parsed as complete structured output, and `spillPath` is optional and not a completeness guarantee. The typed output schema is unchanged: repeating the contract there would cost every PTC request without saying anything the tool text does not. Command semantics, exit codes, result values, limits, spill files, permissions and rendering are unchanged. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 7902324a..6da431d7 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -201,6 +201,25 @@ not a separate security boundary against the account or an administrator (#870). switching sessions do not repair it. Selecting an arbitrary Git Bash is not a restricted-mode workaround: only a compatible pinned MSYS build may run restricted, never an unconfined fallback. +### `niu`-Git hooks fail with `#!/usr/bin/env sh` while `#!/bin/sh` works + +Symptom: a repository hook installed through the niu-Git command — for example a +husky v9 hook — fails when its shebang is `#!/usr/bin/env sh`, while the same +script with `#!/bin/sh` runs. The `env sh` lookup resolves through the payload's +own interpreter machinery and differs from the direct `sh` face; that +resolution lives inside the niu-Git binary tree, not in this repository (#958). + +What to do: + +- Confirm the pair from the same hook file: only the shebang differs, and the + `#!/bin/sh` form succeeds. +- Rewrite the affected hooks to `#!/bin/sh`; husky hooks are plain shell + scripts, so the shebang is the whole change. +- Report the payload version and both hook texts to the payload maintainers. + This repository can only record the diagnosis, because the + shebang-to-interpreter path is inside the niu-Git payload + (unresolved-upstream). + ### A second restricted Bash fails while another Bash is still running The `CreateFileMapping S-., Win32 error 5` failure in #363 came From b13df2219ac3eb50015d9fddd399a938fd054cc9 Mon Sep 17 00:00:00 2001 From: Nicholas023 <498594526@qq.com> Date: Thu, 19 Nov 2026 00:15:01 +0800 Subject: [PATCH 5/7] docs(troubleshooting): record the Windows 10 console flash with Windows Terminal (#828) Each ops_bash call flashed a console window on Windows 10 when Windows Terminal was the default terminal. Niubash is a console-subsystem binary launched without an interactive parent, and the Windows-10 terminal hand-off re-creates a visible console per call; no dsh-ops setting controls console hosting, and the shipped binary cannot be patched here. Record the default-terminal comparison as the diagnosis and mark the hidden-console build upstream work. --- docs/CHANGELOG.md | 10 ++++++++++ docs/troubleshooting.md | 18 ++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index fa94e085..e6a21410 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -45,6 +45,16 @@ this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm `#!/bin/sh` 可运行,husky v9 钩子同样受影响。解释器解析位于 niu-Git 载荷内部, 因此该条目记录诊断对照与 `#!/bin/sh` 缓解,而非声称本仓修复(#958, unresolved-upstream)。 +- Document the per-call console flash on Windows 10 when Windows Terminal is + the default terminal: niubash is a console-subsystem binary launched without + an interactive parent, so each call asks for a console host. The entry gives + the default-terminal comparison as the diagnosis and marks the hidden-console + build upstream work, because no dsh-ops setting controls console hosting + (#828, unresolved-upstream). +- 记录 Windows 10 默认终端为 Windows Terminal 时每次调用的控制台闪烁:niubash + 是无交互父进程启动的控制台子系统二进制,每次调用都会请求控制台宿主。条目给出 + 默认终端对照作为诊断,并标注隐藏控制台构建属上游工作——没有任何 dsh-ops 设置 + 控制控制台宿主(#828,unresolved-upstream)。 - Native tool construction and the publication refusal queue no longer attach listeners or lifetime effects to the composition root. The evidence observer and result admission subscribe on the caller's context with global dispatch, and the refusal queue falls back to the caller lifetime when the root refuses an effect. dsh-tui 0.20 refuses `root.events.on` and `root.effect` from a plugin activation, and the native-tools row is one, so every `dsh-tui --resume` aborted with "cannot resume session" before the agent mounted. - 原生工具构造与发布拒绝队列不再向组合根挂监听或生命周期 effect:证据观察者与 result admission 改为在调用方上下文订阅并声明 global 分发,拒绝队列在 root 拒绝 effect 时回落到调用方生命周期。dsh-tui 0.20 会拒绝插件激活期内的 `root.events.on` 与 `root.effect`,而原生工具行正是插件激活,导致每次 `dsh-tui --resume` 都在 agent 挂载前报 "cannot resume session"。 - The Bash tool description now states the parse contract of `stdout`/`stderr` where the model reads it: `text` may be a partial fragment, `truncated` marks one that must not be parsed as complete structured output, and `spillPath` is optional and not a completeness guarantee. The typed output schema is unchanged: repeating the contract there would cost every PTC request without saying anything the tool text does not. Command semantics, exit codes, result values, limits, spill files, permissions and rendering are unchanged. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 6da431d7..7c8b135f 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -220,6 +220,24 @@ What to do: shebang-to-interpreter path is inside the niu-Git payload (unresolved-upstream). +### `ops_bash` flashes a console window on Windows 10 with Windows Terminal + +Symptom: every `ops_bash` call briefly flashes a black console window when +Windows Terminal is the system's default terminal application on Windows 10. +The niubash executable is a console-subsystem binary that the host launches +without an interactive parent, so each call asks the system for a console host; +the Windows-10 hand-off between Windows Terminal and the classic conhost +re-creates a visible console per call (#828). + +What to do: + +- Verify the default terminal setting (Settings → For developers → Terminal) + and compare the flashing with the default switched back to the Windows + Console Host; that observation pair is the diagnosis. +- A hidden-console niubash build is upstream payload work. This repository only + records the evidence: no dsh-ops setting controls console hosting, and the + shipped binary cannot be patched here (unresolved-upstream). + ### A second restricted Bash fails while another Bash is still running The `CreateFileMapping S-., Win32 error 5` failure in #363 came From 9a33d9d5919787c465292f0b06eed557d7141fe1 Mon Sep 17 00:00:00 2001 From: Nicholas023 <498594526@qq.com> Date: Thu, 19 Nov 2026 00:15:22 +0800 Subject: [PATCH 6/7] docs(troubleshooting): record the antivirus quarantine of niu.exe (#771) A Defender or ESET event removed only niu.exe from an otherwise complete payload, so selection failed with the member-level diagnostic from #844. The quarantine is an external security-product decision: collect the matching threat event, restore the pinned tree with provision-shells, and if an allow-list is chosen target the fixed prepared location. No repository behaviour claims to prevent it. --- docs/CHANGELOG.md | 8 ++++++++ docs/troubleshooting.md | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index e6a21410..6e3b2a9d 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -55,6 +55,14 @@ this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm 是无交互父进程启动的控制台子系统二进制,每次调用都会请求控制台宿主。条目给出 默认终端对照作为诊断,并标注隐藏控制台构建属上游工作——没有任何 dsh-ops 设置 控制控制台宿主(#828,unresolved-upstream)。 +- Document the antivirus pattern for Niubash: all pinned files intact except a + quarantined `niu.exe`, named by the #844 member diagnostic. The entry gives + the Defender/ESET event collection, the provision restore and the fixed-location + allow-list guidance, and marks the quarantine an external event rather than a + code defect (#771). +- 记录 Niubash 的杀毒软件模式:全部 pinned 文件完好、仅 `niu.exe` 被隔离,由 #844 + 的成员级诊断点名。条目给出 Defender/ESET 事件收集、provision 恢复与固定位置允许 + 列表指引,并把隔离标注为外部事件而非代码缺陷(#771)。 - Native tool construction and the publication refusal queue no longer attach listeners or lifetime effects to the composition root. The evidence observer and result admission subscribe on the caller's context with global dispatch, and the refusal queue falls back to the caller lifetime when the root refuses an effect. dsh-tui 0.20 refuses `root.events.on` and `root.effect` from a plugin activation, and the native-tools row is one, so every `dsh-tui --resume` aborted with "cannot resume session" before the agent mounted. - 原生工具构造与发布拒绝队列不再向组合根挂监听或生命周期 effect:证据观察者与 result admission 改为在调用方上下文订阅并声明 global 分发,拒绝队列在 root 拒绝 effect 时回落到调用方生命周期。dsh-tui 0.20 会拒绝插件激活期内的 `root.events.on` 与 `root.effect`,而原生工具行正是插件激活,导致每次 `dsh-tui --resume` 都在 agent 挂载前报 "cannot resume session"。 - The Bash tool description now states the parse contract of `stdout`/`stderr` where the model reads it: `text` may be a partial fragment, `truncated` marks one that must not be parsed as complete structured output, and `spillPath` is optional and not a completeness guarantee. The typed output schema is unchanged: repeating the contract there would cost every PTC request without saying anything the tool text does not. Command semantics, exit codes, result values, limits, spill files, permissions and rendering are unchanged. diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index 7c8b135f..caed7c04 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -238,6 +238,28 @@ What to do: records the evidence: no dsh-ops setting controls console hosting, and the shipped binary cannot be patched here (unresolved-upstream). +### Antivirus quarantined `niu.exe` from the payload + +Symptom: selection reports `EXECUTOR_UNAVAILABLE ... Incomplete Niubash payload: +niu.exe` while every other pinned file is intact — only `niu.exe` is missing +(#771). Preparation copies each pinned member verbatim, so a preparation that +stops at one executable is not a dsh-ops bug: the matching Defender or ESET +event is the security product quarantining that executable. This is an external +event; no repository change can prevent it, and the diagnostic naming the +missing member landed with #844. + +What to do: + +- Collect the matching event before restoring: Defender + `Get-MpThreat` / `Get-MpThreatDetection` (or the ESET detection log) with its + timestamp, action and the exact file path. +- Restore the complete pinned tree with `dsh-ops provision-shells --bash`, which + re-verifies every member. +- An allow-list rule, if you choose one, targets the fixed prepared location — + never disable protection or broadly trust the payload tree. +- If tampering is suspected, hash the restored `niu.exe` and compare it with the + receipt. + ### A second restricted Bash fails while another Bash is still running The `CreateFileMapping S-., Win32 error 5` failure in #363 came From 85734b2bbcddc2fafa8863ea18d08e50b544169f Mon Sep 17 00:00:00 2001 From: Nicholas023 <498594526@qq.com> Date: Thu, 19 Nov 2026 00:27:40 +0800 Subject: [PATCH 7/7] docs(troubleshooting): present upstream mechanisms as unverified inferences (#958, #828) Review follow-up: the shebang and console-flash entries stated upstream mechanisms as established facts. Separate what the reporter observes (the two-shebang comparison, the default-terminal comparison) from the attributed mechanism, which this repository cannot verify inside the upstream payloads, so both entries point a diagnosis instead of claiming a proven root cause. --- docs/CHANGELOG.md | 26 ++++++++++++-------------- docs/troubleshooting.md | 27 ++++++++++++++------------- 2 files changed, 26 insertions(+), 27 deletions(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 6e3b2a9d..b887eb97 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -38,23 +38,21 @@ this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm 完整性标签——因此以守卫与令牌对照诊断记录该边界,而非声称代码修复。 - Document the niu-Git hook failure whose only difference is the shebang: `#!/usr/bin/env sh` fails while `#!/bin/sh` runs, so husky v9 hooks are - affected. The interpreter resolution lives inside the niu-Git payload, so the - entry records the diagnostic pair and the `#!/bin/sh` workaround instead of - claiming a repository fix (#958, unresolved-upstream). + affected. The entry records the observed diagnostic pair and the `#!/bin/sh` + workaround; the interpreter-resolution attribution is an upstream inference, + not a verified root cause (#958, unresolved-upstream). - 记录 niu-Git 钩子失败:唯一差异是 shebang——`#!/usr/bin/env sh` 失败而 - `#!/bin/sh` 可运行,husky v9 钩子同样受影响。解释器解析位于 niu-Git 载荷内部, - 因此该条目记录诊断对照与 `#!/bin/sh` 缓解,而非声称本仓修复(#958, + `#!/bin/sh` 可运行,husky v9 钩子同样受影响。条目记录实测诊断对照与 + `#!/bin/sh` 缓解;解释器解析的归因是上游推断,不是已证根因(#958, unresolved-upstream)。 - Document the per-call console flash on Windows 10 when Windows Terminal is - the default terminal: niubash is a console-subsystem binary launched without - an interactive parent, so each call asks for a console host. The entry gives - the default-terminal comparison as the diagnosis and marks the hidden-console - build upstream work, because no dsh-ops setting controls console hosting - (#828, unresolved-upstream). -- 记录 Windows 10 默认终端为 Windows Terminal 时每次调用的控制台闪烁:niubash - 是无交互父进程启动的控制台子系统二进制,每次调用都会请求控制台宿主。条目给出 - 默认终端对照作为诊断,并标注隐藏控制台构建属上游工作——没有任何 dsh-ops 设置 - 控制控制台宿主(#828,unresolved-upstream)。 + the default terminal. The entry gives the default-terminal comparison as the + diagnosis; the console-host hand-off explanation is an upstream inference, and + the hidden-console build remains upstream work, because no dsh-ops setting + controls console hosting (#828, unresolved-upstream). +- 记录 Windows 10 默认终端为 Windows Terminal 时每次调用的控制台闪烁。条目给出 + 默认终端对照作为诊断;控制台宿主交接的解释是上游推断,隐藏控制台构建仍属 + 上游工作——没有任何 dsh-ops 设置控制控制台宿主(#828,unresolved-upstream)。 - Document the antivirus pattern for Niubash: all pinned files intact except a quarantined `niu.exe`, named by the #844 member diagnostic. The entry gives the Defender/ESET event collection, the provision restore and the fixed-location diff --git a/docs/troubleshooting.md b/docs/troubleshooting.md index caed7c04..ec2f850f 100644 --- a/docs/troubleshooting.md +++ b/docs/troubleshooting.md @@ -205,9 +205,10 @@ not a separate security boundary against the account or an administrator (#870). Symptom: a repository hook installed through the niu-Git command — for example a husky v9 hook — fails when its shebang is `#!/usr/bin/env sh`, while the same -script with `#!/bin/sh` runs. The `env sh` lookup resolves through the payload's -own interpreter machinery and differs from the direct `sh` face; that -resolution lives inside the niu-Git binary tree, not in this repository (#958). +script with `#!/bin/sh` runs. The observed pair is the diagnosis. The likely +mechanism — the `env sh` lookup resolving through the payload's own interpreter +machinery instead of the direct `sh` face — is an upstream inference this +repository has not verified inside the niu-Git binary tree (#958). What to do: @@ -215,28 +216,28 @@ What to do: `#!/bin/sh` form succeeds. - Rewrite the affected hooks to `#!/bin/sh`; husky hooks are plain shell scripts, so the shebang is the whole change. -- Report the payload version and both hook texts to the payload maintainers. - This repository can only record the diagnosis, because the - shebang-to-interpreter path is inside the niu-Git payload +- Report the payload version and both hook texts to the payload maintainers; + they can confirm or correct the interpreter-resolution attribution (unresolved-upstream). ### `ops_bash` flashes a console window on Windows 10 with Windows Terminal Symptom: every `ops_bash` call briefly flashes a black console window when Windows Terminal is the system's default terminal application on Windows 10. -The niubash executable is a console-subsystem binary that the host launches -without an interactive parent, so each call asks the system for a console host; -the Windows-10 hand-off between Windows Terminal and the classic conhost -re-creates a visible console per call (#828). +What is observed is the comparison, not the mechanism: switch the default back +to the Windows Console Host and see whether the flashing stops. The likely +mechanism — niubash being a console-subsystem binary launched without an +interactive parent, so each call asks for a console host and the Windows-10 +terminal hand-off re-creates a visible console — is an upstream inference this +repository has not verified; no dsh-ops setting controls console hosting, and +the shipped binary cannot be patched here (#828). What to do: - Verify the default terminal setting (Settings → For developers → Terminal) and compare the flashing with the default switched back to the Windows Console Host; that observation pair is the diagnosis. -- A hidden-console niubash build is upstream payload work. This repository only - records the evidence: no dsh-ops setting controls console hosting, and the - shipped binary cannot be patched here (unresolved-upstream). +- A hidden-console niubash build is upstream payload work (unresolved-upstream). ### Antivirus quarantined `niu.exe` from the payload