{"record":{"id":"7685fc4f494e4168","repo":"stablyai/orca","slug":"computer-screenshot-temp-path-is-not-owned-by-the","errorCode":null,"errorMessage":"Computer screenshot temp path is not owned by the current user: ${outputDir}","messagePattern":"Computer screenshot temp path is not owned by the current user: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/computer-format.ts","lineNumber":113,"sourceCode":"    // data when disk, permissions, or path validation would otherwise fail --json.\n    return response\n  }\n}\n\nconst COMPUTER_SCREENSHOT_TTL_MS = 24 * 60 * 60 * 1000\nconst COMPUTER_SCREENSHOT_CLEANUP_INTERVAL_MS = 60 * 60 * 1000\nconst COMPUTER_SCREENSHOT_CLEANUP_MARKER = '.last-cleanup'\n\nfunction computerScreenshotTempDir(): string {\n  const outputDir =\n    process.env.ORCA_COMPUTER_SCREENSHOT_TMPDIR || join(tmpdir(), 'orca-computer-use')\n  mkdirSync(outputDir, { recursive: true, mode: 0o700 })\n  const stat = lstatSync(outputDir)\n  if (!stat.isDirectory() || stat.isSymbolicLink()) {\n    throw new Error(`Unsafe computer screenshot temp path: ${outputDir}`)\n  }\n  if (typeof process.getuid === 'function' && stat.uid !== process.getuid()) {\n    throw new Error(`Computer screenshot temp path is not owned by the current user: ${outputDir}`)\n  }\n  chmodSync(outputDir, 0o700)\n  return outputDir\n}\n\nfunction cleanupComputerScreenshots(outputDir: string): void {\n  const now = Date.now()\n  const markerPath = join(outputDir, COMPUTER_SCREENSHOT_CLEANUP_MARKER)\n  try {\n    // Why: agents can call computer-use CLI commands in loops; a marker keeps\n    // temp cleanup from becoming a synchronous directory scan per screenshot.\n    if (statSync(markerPath).mtimeMs > now - COMPUTER_SCREENSHOT_CLEANUP_INTERVAL_MS) {\n      return\n    }\n  } catch {\n    // Missing or unreadable marker means this process should attempt cleanup.\n  }\n","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/stablyai/orca/blob/1136503c6a231a16dce8f921f6fadb63d181e8db/src/cli/computer-format.ts#L95-L131","documentation":"Thrown by computerScreenshotTempDir() when lstatSync shows the directory is not owned by the current process uid (checked only where process.getuid exists, i.e. POSIX). The 0700 directory would otherwise protect the owner's files, but if another uid owns it that protection does not apply to the running agent, leaking screenshots or allowing tampering. This is a TOCTOU-style ownership guard complementing the directory/symlink check.","triggerScenarios":"The screenshot temp dir exists but is owned by a different uid than process.getuid() — e.g. created by root or another user before the current process ran, or after a sudo/non-sudo mixup.","commonSituations":"Running Orca once under sudo then again as a normal user, a system service creating the dir as root, multi-user machines, or containers where the uid differs between image-build and runtime.","solutions":["Delete the existing directory so the current user recreates it with correct ownership: `rm -rf <path>`.","Run the Orca process under the same uid that owns the target directory.","Set ORCA_COMPUTER_SCREENSHOT_TMPDIR to a per-user path under your home or XDG_RUNTIME_DIR."],"exampleFix":"# before: dir owned by root\nls -ld /tmp/orca-computer-use   # drwx------ root root\n\n# after\nsudo rm -rf /tmp/orca-computer-use  # let current user recreate","handlingStrategy":"validation","validationCode":"import { lstatSync } from 'node:fs'\n\nfunction assertOwnedByCurrentUid(p: string): void {\n  if (typeof process.getuid === 'function') {\n    const st = lstatSync(p)\n    if (st.uid !== process.getuid()) {\n      throw new Error(`${p} owned by uid ${st.uid}, expected ${process.getuid()}`)\n    }\n  }\n}","typeGuard":"function isOwnedByCurrentUid(p: string): boolean {\n  try {\n    return typeof process.getuid !== 'function' || lstatSync(p).uid === process.getuid()\n  } catch {\n    return false\n  }\n}","tryCatchPattern":null,"preventionTips":["Run Orca under a consistent uid across invocations.","Avoid mixing sudo and non-sudo for the same temp dir.","Point the temp dir to a per-user path under $HOME or XDG_RUNTIME_DIR."],"tags":["security","filesystem","computer-use","permissions"],"backgroundTag":null,"analyzedSha":"1136503c6a231a16dce8f921f6fadb63d181e8db","analyzedAt":"2026-08-12T23:15:58.167Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}