Skip to content

Document how cmd.exe interprets wxc-exec arguments after -- - #1926

Open
Elliot (theelliotm) wants to merge 4 commits into
mainfrom
user/emichlin/cmd-argv-quoting-docs
Open

Elliot (theelliotm) wants to merge 4 commits into
mainfrom
user/emichlin/cmd-argv-quoting-docs

Conversation

@theelliotm

@theelliotm Elliot (theelliotm) commented Dec 3, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

wxc-exec.exe turns the arguments after -- into a single command line. On IsolationSession and Windows Sandbox, that command line runs through cmd.exe /c. Quoting doesn't stop cmd from expanding %VAR%, and stray quotes can make &, | and similar characters act as shell syntax. None of this was documented, and the cmdline.rs Rustdoc said the quoting kept arguments from being read as shell syntax.

This PR adds a "wxc-exec Command Arguments" section to docs/schema.md. It explains how arguments are quoted on each backend, what cmd still interprets, and why escaping values for cmd first doesn't work. It tells callers to check values they don't control, such as user-supplied file names, against a strict allowlist. The Windows Sandbox guide and the container lifecycle doc link to the new section, and the cmdline.rs Rustdoc now describes what the quoting actually does.

No behavior changes. W365Agents isn't affected because it launches the command line without cmd.exe.

🔗 References

  • src/mxc-sdk/src/core/mxc_common/cmdline.rs (CommandLineContext::for_backend, append_windows_cmd)
  • src/mxc-sdk/src/backends/isolation_session/common/process_options.rs (/c {})
  • src/mxc-sdk/src/bin/windows_sandbox_guest/executor.rs (cmd.exe /C + raw_arg)
  • src/mxc-sdk/src/backends/w365agents/exec/payload.rs (shell: "raw")

🔍 Validation

  • cargo fmt --all -- --check and cargo doc -p mxc-sdk --no-deps -q (from src/): passed, no warnings.
  • Ran each described case through cmd /c on Windows to confirm it, including an embedded \" exposing & in a later argument, quote removal exposing & in a middle argument, and a pre-escaped a^&b reaching the program unchanged.
  • Checked that the new links and anchors resolve.
  • No runtime tests: documentation and Rustdoc only.

✅ Checklist

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

  • Bug fix
  • Feature
  • Task

Elliot (theelliotm) and others added 2 commits December 3, 2026 15:50
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83e19dbb-1bf5-41ad-80f0-47fe416d8093
Copilot AI max review requested due to automatic review settings December 3, 2026 23:55
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The documentation gives incorrect backend-specific quoting guidance, understates command-wide operator exposure, and suggests escaping that is insufficient when arguments are quoted again.

3 open issues
What changed in this PR

Documents existing cmd.exe handling of wxc-exec.exe arguments after -- on IsolationSession and Windows Sandbox. Runtime behavior is unchanged.

Changes:

  • Explains expansion, quote handling, and risks from untrusted arguments.
  • Links backend and lifecycle documentation to the shared guidance.
  • Corrects Rustdoc claims about shell safety.
File Description
src/​mxc-sdk/​src/​core/​mxc_common/​cmdline.rs Clarifies quoting limitations in Rustdoc.
docs/​schema.md Adds command-argument behavior and safety guidance.
docs/​development/​architecture/​container-lifecycle.md Links lifecycle execution guidance to argument documentation.
docs/​backends/​windows-sandbox/​windows-sandbox.md Notes shell execution and links argument guidance.

Review effort: Max

Comment thread docs/schema.md Resolved
Comment thread docs/schema.md Resolved
Comment thread docs/schema.md Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83e19dbb-1bf5-41ad-80f0-47fe416d8093
Copilot AI max review requested due to automatic review settings December 4, 2026 00:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The documentation omits W365Agents from the WindowsCommandProcessor quoting rules and fails to distinguish quoting from cmd.exe invocation.

No open issues 🎉

1 previously missed issue

In code that hasn't changed since last review

Low severity Correct W365Agents quoting guidance for raw-shell payloads

docs/​schema.md:415

W365Agents uses WindowsCommandProcessor too, so it quotes cmd operators even though its payload uses shell: "raw" and does not add cmd.exe. The current list gives its callers the wrong quoting rule; include W365Agents and distinguish quoting from shell invocation. The same distinction is missing in src/mxc-sdk/src/core/mxc_common/cmdline.rs:27–28.

3 resolved since last review

Review effort: Max

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 83e19dbb-1bf5-41ad-80f0-47fe416d8093
Copilot AI max review requested due to automatic review settings December 4, 2026 23:39
@theelliotm
Elliot (theelliotm) marked this pull request as ready for review December 4, 2026 23:41
@theelliotm
Elliot (theelliotm) requested a review from a team as a code owner December 4, 2026 23:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

Human assessment is needed to evaluate security-sensitive gaps in the quoting guidance for explicitly launched command processors and Hyperlight’s execution of guest-runtime source.

No open issues 🎉

Review effort: Max

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.

2 participants