{"record":{"id":"792d5c978f4f515f","repo":"openclaw/openclaw","slug":"crabbox-inspect-returned-an-invalid-desktop-home-p","errorCode":null,"errorMessage":"Crabbox inspect returned an invalid desktop home path","messagePattern":"Crabbox inspect returned an invalid desktop home path","errorType":"validation","errorClass":"WorkerProviderError","httpStatus":null,"severity":"error","filePath":"extensions/crabbox/src/crabbox-worker-desktop-setup.ts","lineNumber":16,"sourceCode":"import path from \"node:path\";\nimport { WorkerProviderError, type WorkerDesktopEndpoint } from \"openclaw/plugin-sdk/plugin-entry\";\n\nconst CRABBOX_WORKER_BROWSER_PATH = \"/usr/local/bin/openclaw-worker-browser\";\nconst CRABBOX_WORKER_TERMINAL_PATH = \"/usr/local/bin/openclaw-worker-terminal\";\nconst CRABBOX_WORKER_BROWSER_CDP_PORT = 9222;\n\nconst SSH_USER_PATTERN = /^(?:root|[a-z_][a-z0-9_-]{0,31})$/u;\n\nfunction resolveCrabboxWorkerHome(sshUser: string): string {\n  if (!SSH_USER_PATTERN.test(sshUser)) {\n    throw new WorkerProviderError(\"Crabbox inspect returned an invalid desktop SSH user\");\n  }\n  const home = sshUser === \"root\" ? \"/root\" : `/home/${sshUser}`;\n  if (!path.posix.isAbsolute(home) || path.posix.normalize(home) !== home) {\n    throw new WorkerProviderError(\"Crabbox inspect returned an invalid desktop home path\");\n  }\n  return home;\n}\n\nfunction browserLauncher(home: string, browserProfilePath: string): string[] {\n  return [\n    \"#!/bin/bash\",\n    \"set -euo pipefail\",\n    '[ \"$#\" -eq 0 ] || { echo \"openclaw-worker-browser does not accept arguments\" >&2; exit 64; }',\n    '[ -r /var/lib/crabbox/desktop.env ] || { echo \"Crabbox desktop environment is unavailable\" >&2; exit 1; }',\n    '[ -r /var/lib/crabbox/browser.env ] || { echo \"Crabbox browser environment is unavailable\" >&2; exit 1; }',\n    \". /var/lib/crabbox/desktop.env\",\n    \". /var/lib/crabbox/browser.env\",\n    '[ \"${CRABBOX_DESKTOP_ENV:-}\" = \"xfce\" ] || { echo \"Crabbox desktop environment is not XFCE\" >&2; exit 1; }',\n    '[ \"${DISPLAY:-}\" = \":99\" ] || { echo \"Crabbox XFCE display is not :99\" >&2; exit 1; }',\n    `export HOME=${home}`,\n    \"export DISPLAY\",\n    `export CRABBOX_BROWSER_PROFILE=${browserProfilePath}`,","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/openclaw/openclaw/blob/01804a75319da4b69c9ab98ceaa30477e22b8c0b/extensions/crabbox/src/crabbox-worker-desktop-setup.ts#L1-L34","documentation":"Thrown by resolveCrabboxWorkerHome() as a defensive guard when the computed home path (/root or /home/<user>) is not absolute or not in normalized form. Given SSH_USER_PATTERN is validated first, this branch is effectively unreachable under normal input; it exists to prevent path-traversal-style home paths from ever reaching the setup script if the username regex is ever widened.","triggerScenarios":"resolveCrabboxWorkerHome is called and, after the regex check, path.posix.isAbsolute(home)===false or path.posix.normalize(home)!==home. With the current regex this cannot occur for inputs that pass 1285; it would only fire if SSH_USER_PATTERN were loosened to allow traversal characters.","commonSituations":"Effectively unreachable today. Would surface only if a future edit to SSH_USER_PATTERN permits characters that break path normalization (e.g. '..' or symlinks), or if home derivation logic changes to incorporate user-controlled subpaths.","solutions":["Confirm the sshUser passed the SSH_USER_PATTERN check (see error 1285); if 1285 fired first, fix the username.","If you are editing this file and widened the regex, restore the strict pattern or add explicit traversal rejection before this check.","Report as a bug — this guard firing means the username regex contract is broken."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"function isAbsoluteNormalizedPosixPath(p: string): boolean {\n  return path.posix.isAbsolute(p) && path.posix.normalize(p) === p;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep SSH_USER_PATTERN strict — do not widen it to permit path-traversal characters.","If editing resolveCrabboxWorkerHome, re-run the desktop setup tests to confirm the path guards still hold.","Treat this error firing as a bug in the username regex contract, not an operational condition."],"tags":["crabbox","worker-provider","desktop","validation","path-traversal","defensive"],"backgroundTag":null,"analyzedSha":"01804a75319da4b69c9ab98ceaa30477e22b8c0b","analyzedAt":"2026-08-12T04:37:58.197Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}