Skip to content

Commit 6f83bf1

Browse files
committed
fix(mxc): reject unsupported foreground attachment before provisioning
Signed-off-by: Drew Newberry <anewberry@nvidia.com>
1 parent 30bc3c9 commit 6f83bf1

4 files changed

Lines changed: 34 additions & 3 deletions

File tree

‎crates/openshell-driver-mxc/README.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ branch's `MXC agent launched` acknowledgement only after native spawn succeeds.
3939

4040
The driver resolves its gateway endpoint and TLS server-name defaults from
4141
generic gateway inputs. The host supervisor authenticates its gateway session
42-
and retains main-process attachment independently of the optional Unix SSH
43-
adapter. TCP readiness remains gated by authenticated session acceptance.
42+
and retains main-process I/O. MXC has no foreground attachment adapter; create
43+
command workloads with `--detach`. Preflight rejects foreground attachment
44+
before provisioning. TCP readiness remains gated by authenticated session acceptance.
4445

4546
Windows boundary execution is implemented by the `openshell-mxc-boundary`
4647
library behind the dedicated `openshell-windows-sandbox.exe`. The compute driver does not

‎crates/openshell-driver-mxc/src/driver.rs‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,15 @@ impl MxcComputeBackend {
291291
}
292292

293293
pub fn validate_sandbox_create(&self, sandbox: &DriverSandbox) -> Result<(), tonic::Status> {
294+
if sandbox
295+
.spec
296+
.as_ref()
297+
.is_some_and(|spec| spec.await_main_process_attachment)
298+
{
299+
return Err(tonic::Status::failed_precondition(
300+
"MXC does not support foreground attachment to the main process. Create the sandbox with --detach.",
301+
));
302+
}
294303
openshell_core::resource_admission::check_sandbox_driver_config(
295304
self.config.allow_driver_config,
296305
sandbox,
@@ -1364,6 +1373,24 @@ mod tests {
13641373
assert!(!backend.config.state_dir.exists());
13651374
}
13661375

1376+
#[tokio::test]
1377+
async fn foreground_attachment_is_rejected_before_provisioning() {
1378+
let (backend, mut sandbox, _dir) = preflight_fixture();
1379+
sandbox.spec.as_mut().unwrap().command =
1380+
vec!["cmd.exe".into(), "/c".into(), "exit 0".into()];
1381+
sandbox.spec.as_mut().unwrap().await_main_process_attachment = true;
1382+
let error = backend.validate_sandbox_create(&sandbox).unwrap_err();
1383+
assert_eq!(error.code(), tonic::Code::FailedPrecondition);
1384+
assert!(error.message().contains("--detach"));
1385+
let error = backend.create_sandbox(&sandbox).await.unwrap_err();
1386+
assert_eq!(error.code(), tonic::Code::FailedPrecondition);
1387+
assert!(error.message().contains("foreground attachment"));
1388+
assert!(backend.get_sandbox(&sandbox.id).await.is_none());
1389+
assert!(!backend.config.state_dir.exists());
1390+
sandbox.spec.as_mut().unwrap().await_main_process_attachment = false;
1391+
assert!(backend.validate_sandbox_create(&sandbox).is_ok());
1392+
}
1393+
13671394
#[test]
13681395
fn resource_admission_is_unsupported_and_acknowledged() {
13691396
let config = MxcComputeConfig::default();

‎crates/openshell-server/src/compute/mod.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8804,7 +8804,7 @@ mod tests {
88048804
});
88058805

88068806
let error = runtime
8807-
.validate_sandbox_create_with_runtime_inputs(&sandbox, &runtime_inputs)
8807+
.validate_sandbox_create_with_runtime_inputs(&sandbox, &runtime_inputs, false)
88088808
.await
88098809
.expect_err("an unsupported driver must reject the effective UI policy");
88108810

‎docs/how-it-works/gateways/configuration.mdx‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,6 +1239,9 @@ runtime-selected profile.
12391239

12401240
The MXC driver is Windows-only and opt-in. It links into the gateway and invokes Microsoft MXC through `wxc-exec.exe`. The driver starts `openshell-supervisor --role=isolation-backend` on the host and `openshell-windows-sandbox.exe` inside each ProcessContainer. The standard authenticated Sandbox Protocol and supervisor session provide lifecycle, exec, forwarding, provider refresh, and network policy.
12411241

1242+
MXC does not support foreground attachment to the main process. Use `--detach`
1243+
when creating a command workload; foreground requests fail during preflight.
1244+
12421245
The dedicated `openshell-windows-sandbox.exe` uses a Windows boundary library for process operations and forwarding. It replaces the generic sandbox binary in the Windows runtime pair; the supervisor remains a separate host process, not part of the compute driver. No separate supervisor-relay executable is required. Set `wxc_exec_path` to an absolute path; configuration preflight rejects an omitted or relative path. Existing MXC configurations that explicitly select `openshell-sandbox.exe` must update `sandbox_binary_path` to the Windows executable.
12431246

12441247
The Windows sandbox initiates its authenticated control connection to a generation-scoped loopback listener in the host isolation backend. This follows the Windows relay's connection direction without changing host firewall rules. TLS identity verification and supervisor bearer authentication remain required.

0 commit comments

Comments
 (0)