fix(io): retain cleanup ownership and honor cancellation
Keep failed JSON read handles in the existing server resource scope and fail admission until cleanup succeeds. Thread cancellation through every process CLI input read and replace timer-driven cancellation checks with a shared first-read gate. Classify authenticated standalone Evidence as wrong-kind input while preserving tampered-record integrity failures and actionable messages across ledger, CLI, and MCP consumers. Record unrelated CS_RESTRICT process neighbors as unverified without weakening related-process ownership checks. Update stale ADB fixtures for the actual shell protocol. Validated focused CLI, MCP, filesystem, ownership, and error projection tests; static, docs, and duplication gates pass. The host-level CS_RESTRICT load reproduction was not run. Refs #2050, #2035, #2064.
This commit is contained in:
@@ -805,17 +805,21 @@ const TOKEN_READ_RETRY_DELAY_MS = 40;
|
||||
/** Darwin reports this when the kernel withholds a platform binary's environment. */
|
||||
const PLATFORM_BINARY_ENVIRONMENT_WITHHELD =
|
||||
"platform_binary_environment_withheld";
|
||||
/** Darwin reports this when the kernel withholds a restricted process environment. */
|
||||
const RESTRICTED_PROCESS_ENVIRONMENT_WITHHELD =
|
||||
"restricted_process_environment_withheld";
|
||||
|
||||
const currentProcessUid = (): number | undefined =>
|
||||
typeof process.getuid === "function" ? process.getuid() : undefined;
|
||||
|
||||
/**
|
||||
* Whether the operating system provably withheld this candidate's run token:
|
||||
* current macOS omits the environment of Apple platform binaries from
|
||||
* KERN_PROCARGS2 and fails with EINVAL for processes owned by another
|
||||
* account, and neither class can be token-verified by any caller. Such a
|
||||
* candidate is recorded as unverified instead of failing an otherwise clean
|
||||
* capture; every other unreadable candidate stays fail-closed.
|
||||
* current macOS omits the environment of Apple platform binaries and
|
||||
* CS_RESTRICT processes from KERN_PROCARGS2, and fails with EINVAL for
|
||||
* processes owned by another account. These classes cannot be token-verified
|
||||
* by this caller. An unrelated candidate is recorded as unverified instead
|
||||
* of failing an otherwise clean capture; every related or otherwise
|
||||
* unreadable candidate stays fail-closed.
|
||||
*/
|
||||
const environmentWithheldFromInspection = (
|
||||
entry: ProcessTableEntry,
|
||||
@@ -824,7 +828,10 @@ const environmentWithheldFromInspection = (
|
||||
const uid = currentProcessUid();
|
||||
if (uid !== undefined && entry.uid !== undefined && entry.uid !== uid)
|
||||
return true;
|
||||
return diagnostic === PLATFORM_BINARY_ENVIRONMENT_WITHHELD;
|
||||
return (
|
||||
diagnostic === PLATFORM_BINARY_ENVIRONMENT_WITHHELD ||
|
||||
diagnostic === RESTRICTED_PROCESS_ENVIRONMENT_WITHHELD
|
||||
);
|
||||
};
|
||||
|
||||
const scanTokenOwnedProcesses = async (
|
||||
|
||||
Reference in New Issue
Block a user