Skip to content

fix(shells): classify MSYS section failures and arm the Niubash boundary in confined modes (#870, #409, #581, #958, #828, #771) - #1002

Closed
Nicholas023 wants to merge 7 commits into
mainfrom
fix-shell-runtime-local
Closed

Nicholas023 wants to merge 7 commits into
mainfrom
fix-shell-runtime-local

Conversation

@Nicholas023

Copy link
Copy Markdown
Collaborator

Closes #870, #409, #581
Refs #958, #828, #771

What was wrong

The change

  • src/niubash/runtime.ts: prepareNiubash takes the session mode; the prepared-root containment refusal is armed only in confined modes. Full access runs unconfined, so the boundary guarded no remaining channel there. Restricted modes keep refusing.
  • src/shells/session-execution.ts: passes policy.mode to the preparation.
  • src/shells/* classification: the MSYS shared-section startup failure maps to EXECUTOR_UNAVAILABLE with sandbox.runnerFailed.
  • Docs: troubleshooting entries for the three external events, with measured comparisons and explicit "upstream inference" wording.
  • New tests: niubash-workspace-mode, shells-niubash-prepared-boundary, shells-msys-shared-section, shells-full-access-confinement; existing niubash-preparation 18/18 stays green.

Local validation: shells-session 6/6, niubash-security-host 11/11, niubash-preparation 18/18, shells-full-access-confinement 1/1, shells-msys-shared-section 1/1, niubash-workspace-mode 1/1; npm run check:size 826 files, all ≤1000 lines.

Validation

$ npm run build
build: compiled src/ to lib/ and copied 60 assets

$ node scripts/verify-gate.mjs --skip-install --keep-going
268 suites passed; skipped: linux-attributes, linux-shell, tui-host, tui-native (allowed: file-metadata, linux-attributes, linux-shell, tui-host, tui-native)
manifest: 92/59 checks
win32-x64: gate green

The gate lines above were produced on the local integration head b21274dd (all slices merged) with the pinned local fixtures:
DSH_OPS_TEST_BASH = a verified pinned MSYS bash (sha256 6cc575e9…), DSH_OPS_NIUBASH_ARCHIVE = the shipped frozen archive. Each PR branch was also built and its own suites were run before push; the counts below are from those runs.

CI required run: the pull_request event for this PR triggers ci.yml; paste the aggregate CI required run URL here once it finishes.

Environment

  • OS: Windows x64 25H2; Node.js v24.21.0; DSH 0.2.2-rc.1
  • Based on upstream main commit 58f6e281 (origin/main at submission)
  • Install channel: local source build (npm ci --ignore-scripts --offline, npm run build, npm run stage:niubash -- --offline --archive <frozen archive>)

…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.
…vailable (#409)

msys-2.0.dll prints a per-user section conflict as 'CreateFileMapping S-<user SID>.<n>, 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.
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.
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.
…ws 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.
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.
…rences (#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.
IsaacHuo added a commit to IsaacHuo/dsh-ops-pro that referenced this pull request Nov 20, 2026
shells-full-access-confinement, shells-msys-shared-section and
shells-niubash-prepared-boundary (absorbed with T-Auto#1002) only exercise
the Windows Niubash branch; under DSH_OPS_REQUIRE_RUNTIME=1 their
POSIX skips failed the Linux and macOS gates.
@Thatgfsj

Copy link
Copy Markdown
Collaborator

Superseded by #1033:按仓库约定把 #1023 与 #1002–#1008 合并为一个统一 PR(冲突已在 #1033 内解决,CI 在 #1033 上跑)。

@Thatgfsj Thatgfsj closed this Nov 20, 2026
Thatgfsj added a commit that referenced this pull request Nov 20, 2026
#1002 adds shells-full-access-confinement, shells-msys-shared-section and
shells-niubash-prepared-boundary; all three pin the Windows Niubash runtime
branch and skip elsewhere, but the gate's per-platform allow-list did not name
them, so the four POSIX legs reported them as disallowed skips (and
DSH_OPS_REQUIRE_RUNTIME=1 turned each into a suite failure). Name them beside
windows-security, niubash-consumer and niubash-security-host.

Refs #1032, #1033.
Nicholas023 added a commit that referenced this pull request Nov 20, 2026
chore(release): consolidate the OPS-PTC 18-card release with #1002–#1008 (#1000)
@Thatgfsj
Thatgfsj deleted the fix-shell-runtime-local branch November 20, 2026 15:46
WeiLinCool pushed a commit to WeiLinCool/dsh-ops that referenced this pull request Nov 20, 2026
-T-Auto#1008

Merge release/ops-ptc-18-cards on top of the seven fix branches and reconcile
the surfaces both sides rewrote:

- docs/CHANGELOG.md: union of both sides' Unreleased entries (no duplicates).
- src/publication/ptc.ts: keep the release's surface-aware teaching renderer and
  four-verdict refusal, port T-Auto#1008's T-Auto#929 ephemeral lesson channel and T-Auto#968's
  deferred loader pointer into it, and drop the P7 step-tail provider plus the
  compaction re-anchor that depended on logged history (superseded by the
  ephemeral channel; see T-Auto#929/T-Auto#998).
- src/publication/replacements.ts: keep both the T-Auto#962 per-agent fail-open latch
  and the release's hidden-name system-prompt retirement.
- src/publication/registrar.ts, src/consumer/mount.ts: union of the deferred
  advisor loop, the revoked verdict and the PTC keepOfficial handoff.
- tests: adapt the tier enumerations, the cost ledger and the teaching
  assertions to the merged surface (the T-Auto#753 ops_status diagnostics row and the
  ephemeral lesson channel), keeping one assertion per unchanged behaviour.
- docs: point the batching-guidance descriptions at the ephemeral inbox.

Refs T-Auto#1000, T-Auto#1032.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment