Skip to content

fix(remote): drop a remote artifact whose name cannot be a file name - #4718

Open
zerone0x wants to merge 1 commit into
callstack:mainfrom
zerone0x:fix/remote-artifact-nul-name
Open

zerone0x wants to merge 1 commit into
callstack:mainfrom
zerone0x:fix/remote-artifact-nul-name

Conversation

@zerone0x

@zerone0x zerone0x commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A remote daemon response that names a non-script artifact with a NUL byte in its destination crashed the client: resolveMaterializedArtifactPath built a path from artifact.fileName and the download's first fs call threw.

The client now checks the chosen destination before any filesystem work. A destination containing a NUL byte (from fileName or an echoed localPath), or a fileName that is not a string, drops that artifact. The response gains a typed droppedArtifacts: [{ field, reason: 'artifact_name_invalid' }] entry and a paired warnings line, mirroring scriptDeliveryFailure. droppedArtifacts is a client-owned field, so a daemon artifact cannot target it. The rest of the response, including the action's outcome, is kept. Script artifacts do not take this path, so they are unaffected.

Empty, . and .. names keep their existing fallback name. Wider peer-named-entry validation is left to #4669.

Files: 2 (packages/remote/src/daemon-artifacts.ts, one test).

Fixes #4661

Validation

Tested SHA: e99e7fecc7626a01d2a16ae5785dfe6f11d87f7e (base 6e18ea3).

  • pnpm exec vitest run --project unit-core packages/remote/src/__tests__/: the new test passes at head and fails at base (the NUL name crashes the client). This VM also shows 13 failures in the script-ancestry, script-download and script-hostile-daemon suites. They happen at base as well, so they come from the environment (tmp-directory ancestry) and not from this change.
  • capture/directory/test-command suites: 21/21 pass.
  • tsc over packages/remote/src (root tsconfig, noEmit): clean.
  • oxfmt --check on the changed files: clean.
  • oxlint and check:affected could not run here: oxlint crashes in its allocator on this small VM. CI is the authority for lint and the full gate.

Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

A daemon response naming a non-script artifact with a NUL byte in its
fileName (or localPath) crashed the client in the download's first fs call.
The client now drops that artifact before any filesystem work, records a
typed droppedArtifacts entry (reason artifact_name_invalid) and a warning,
and keeps the rest of the response, including the action's own outcome.

Fixes callstack#4661
@zerone0x
zerone0x force-pushed the fix/remote-artifact-nul-name branch from e99e7fe to 16c7e5e Compare November 18, 2026 20:13
@thymikee

Copy link
Copy Markdown
Member

At 16c7e5e, the change still has two delivery defects and needs live verification.

The destination check rejects NUL but accepts a peer-selected fallback name longer than the filesystem component limit. Opening it fails with ENAMETOOLONG and loses the answered action. Please apply a host-kit name admission rule to every peer-selected entry before filesystem work, disclose invalid names, and cover overlong names and the platform cases in its table.

The dropped reason exists only on an untyped remote response; screenshot normalization discards it. Node and default screenshot JSON consumers cannot reliably identify the dropped artifact by its typed reason, and the daemon path can still appear as successful output. Please own the disclosure in the shared response contract and carry it through client normalizers and machine output, preserving the warning and identifying unavailable paths.

The remote capture delivery change has no live verification at this head. Please run a remote device capture through the daemon client and a public output surface, including a malformed artifact response, and show successful action data, the typed dropped reason and warning, and no dropped file.

Not blocking: the regression could use a remote request with a malformed response through the daemon client and a public surface, asserting the kept action, typed disclosure and no artifact write; you can take or leave this suggestion.

Could a single host-kit peer-entry admission rule and shared typed delivery disclosure be used at materialization? The host-kit owner would first need to agree on the name policy and platform case table, since issue #4669 defers the broader write policy.

Coverage failed; please check its log for the failing assertion or threshold and compare it with main. The PR body describes validation at e99e7fe, not at this head. No conflicts are known. Before merge, please repair name admission and disclosure, provide live evidence at this head, and diagnose Coverage.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A NUL byte in a remote artifact file name crashes the client

2 participants