{"record":{"id":"34906ca08a669d29","repo":"zeroclaw-labs/zeroclaw","slug":"refusing-to-mount-filesystem-root-into-docker","errorCode":null,"errorMessage":"Refusing to mount filesystem root (/) into docker runtime","messagePattern":"Refusing to mount filesystem root \\(/\\) into docker runtime","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/zeroclaw-config/src/platform/docker.rs","lineNumber":53,"sourceCode":"    }\n\n    fn workspace_mount_path(&self, workspace_dir: &Path) -> Result<PathBuf> {\n        let resolved = workspace_dir.canonicalize().map_err(|source| {\n            DockerWorkspaceMountError::WorkspacePath {\n                path: workspace_dir.display().to_string(),\n                source,\n            }\n        })?;\n\n        if !resolved.is_absolute() {\n            anyhow::bail!(\n                \"Docker runtime requires an absolute workspace path, got: {}\",\n                resolved.display()\n            );\n        }\n\n        if resolved == Path::new(\"/\") {\n            anyhow::bail!(\"Refusing to mount filesystem root (/) into docker runtime\");\n        }\n\n        if self.config.allowed_workspace_roots.is_empty() {\n            return Ok(resolved);\n        }\n\n        let allowed_roots = self\n            .config\n            .allowed_workspace_roots\n            .iter()\n            .map(|root| {\n                Path::new(root).canonicalize().map_err(|source| {\n                    DockerWorkspaceMountError::AllowedRoot {\n                        path: root.clone(),\n                        source,\n                    }\n                })\n            })","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/zeroclaw-labs/zeroclaw/blob/88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc/crates/zeroclaw-config/src/platform/docker.rs#L35-L71","documentation":"A deliberate safety guard in workspace_mount_path: if the resolved workspace is exactly /, the docker runtime refuses to build the command rather than bind-mounting the host's entire filesystem into the container. It runs before the allowed_workspace_roots check, so no allowlist configuration can override it.","triggerScenarios":"workspace_dir resolves to / — set explicitly, produced by resolving \".\" while the process cwd is /, or reached through a symlink chain whose canonicalized target is the filesystem root. Fires inside build_shell_command_inner via workspace_mount_path.","commonSituations":"Typo'd workspace_dir = \"/\"; CI or container environments where the workspace symlink points at /; running zeroclaw from the root directory with a relative workspace.","solutions":["Point the workspace at a real subdirectory such as /workspace or /home/me/work.","Inspect the symlink chain with readlink -f <path> and fix the link that escapes to /.","If the process cwd is /, run from the project directory or pass an absolute subpath."],"exampleFix":"# before\nworkspace_dir = \"/\"   # refused: mounting filesystem root\n\n# after\nworkspace_dir = \"/home/me/zeroclaw/workspace\"","handlingStrategy":"validation","validationCode":"let resolved = std::fs::canonicalize(&workspace_dir)?;\nif resolved == std::path::Path::new(\"/\") {\n    return Err(anyhow::anyhow!(\"workspace resolves to /; pick a subdirectory\"));\n}","typeGuard":null,"tryCatchPattern":"match docker_runtime.build_shell_command_inner(cmd) {\n    Err(e) if e.to_string().contains(\"filesystem root\") => {\n        // workspace or a symlink escapes to /; fix the path or symlink chain\n    }\n    other => other,\n}","preventionTips":["Never configure / as a workspace; it is refused unconditionally.","Check readlink -f on workspace paths in containerized setups where symlinks point at /.","Add a config lint that rejects workspace values of \"/\" before runtime creation."],"tags":["docker","security","workspace","mount"],"backgroundTag":"docker-root-mount-refused","analyzedSha":"88bb9c8533fc57ed7a03e36ca7c9ed2bf8336dcc","analyzedAt":"2026-08-23T01:07:41.857Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}