{"record":{"id":"2931d6e51e0249c1","repo":"paperclipai/paperclip","slug":"opencode-qualified-opencode-version-runner-owne","errorCode":null,"errorMessage":"OpenCode ${QUALIFIED_OPENCODE_VERSION} runner-owned executable binding is unavailable; refusing ambient PATH or PAPERCLIP_OPENCODE_COMMAND fallback","messagePattern":"OpenCode (.+?) runner-owned executable binding is unavailable; refusing ambient PATH or PAPERCLIP_OPENCODE_COMMAND fallback","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/paperclip-runner/src/cli/opencode-proxy-command.ts","lineNumber":78,"sourceCode":"      const currentUid = process.getuid?.();\n      snapshotIsValid =\n        metadata.isFile() &&\n        !metadata.isSymbolicLink() &&\n        metadata.nlink === 1 &&\n        (metadata.mode & 0o777) === 0o500 &&\n        directoryMetadata.isDirectory() &&\n        !directoryMetadata.isSymbolicLink() &&\n        (directoryMetadata.mode & 0o777) === 0o700 &&\n        currentUid !== undefined &&\n        metadata.uid === currentUid &&\n        directoryMetadata.uid === currentUid &&\n        (expected === undefined ||\n          (metadata.dev === expected.dev && metadata.ino === expected.ino));\n    } catch {\n      snapshotIsValid = false;\n    }\n    if (!snapshotIsValid) {\n      throw new Error(\n        `OpenCode ${QUALIFIED_OPENCODE_VERSION} runner-owned executable binding is unavailable; refusing ambient PATH or PAPERCLIP_OPENCODE_COMMAND fallback`,\n      );\n    }\n    return metadata!;\n  };\n  if (\n    process.platform === \"darwin\" &&\n    isAbsolute(command) &&\n    basename(command) === \"launch\" &&\n    /^\\.paperclip-verified-executable-[0-9a-f]{32}$/.test(\n      basename(dirname(command)),\n    )\n  ) {\n    const initialMetadata = validateMacSnapshot();\n    let sourceFd: number;\n    try {\n      sourceFd = openSync(command, \"r\");\n    } catch {","sourceCodeStart":60,"sourceCodeEnd":96,"githubUrl":"https://github.com/paperclipai/paperclip/blob/5716fe907e596ce73501408fc6efdb19fb61edf2/packages/paperclip-runner/src/cli/opencode-proxy-command.ts#L60-L96","documentation":"trustedOpenCodeLaunchBinding only accepts the executable binding injected by runnerd (an inherited /proc/self/fd descriptor on Linux, or a verified mac executable snapshot). On macOS it validates the path with lstat: a regular, non-symlink file owned by the current uid, mode 0500, nlink 1, inside a 0700 non-symlink directory named .paperclip-verified-executable-<hash>. If that strict snapshot fails, the proxy refuses any ambient PATH lookup or PAPERCLIP_OPENCODE_COMMAND fallback and fails closed.","triggerScenarios":"On darwin, validateMacSnapshot() fails: the verified path was already consumed/deleted (unlinkSync after a prior launch), the directory or file permissions/ownership changed, the path is a symlink, nlink != 1, or lstat throws because the file is gone. Reached via materializeForSpawn/afterSpawn when the verified file was unlinked after initial validation.","commonSituations":"Launching OpenCode twice — the first launch unlinks the verified executable, so the second launch finds nothing; running the proxy as a different user than runnerd; an antivirus/cleanup process deleting the temp verified dir; filesystem that doesn't honor the expected modes; manually invoking the proxy without the runnerd-injected argument.","solutions":["Re-run through runnerd so it re-materializes a fresh runner-owned verified executable binding for this launch","Do not invoke the proxy directly with a stale path; always pass the current --paperclip-trusted-opencode-executable argument runnerd provides","Ensure the same uid runs the proxy as the one that materialized the binding","Do not set PAPERCLIP_OPENCODE_COMMAND expecting a fallback — it is deliberately ignored","Check that no cleanup process removed .paperclip-verified-executable-* directories mid-run"],"exampleFix":"// before (second launch reusing consumed path)\nconst binding = trustedOpenCodeLaunchBinding([TRUSTED_OPENCODE_EXECUTABLE_ARG, staleMacPath]);\n// after (get a fresh binding from runnerd)\nconst freshPath = await runnerd.materializeVerifiedOpenCodeExecutable();\nconst binding = trustedOpenCodeLaunchBinding([TRUSTED_OPENCODE_EXECUTABLE_ARG, freshPath]);","handlingStrategy":"validation","validationCode":"import { lstatSync } from \"node:fs\";\nfunction canUseTrustedBinding(command) {\n  if (process.platform !== \"darwin\") return true;\n  try {\n    const st = lstatSync(command);\n    const dir = lstatSync(require(\"node:path\").dirname(command));\n    const uid = process.getuid?.();\n    return st.isFile() && !st.isSymbolicLink() && st.nlink === 1 &&\n      (st.mode & 0o777) === 0o500 &&\n      dir.isDirectory() && !dir.isSymbolicLink() &&\n      (dir.mode & 0o777) === 0o700 &&\n      uid !== undefined && st.uid === uid && dir.uid === uid;\n  } catch {\n    return false;\n  }\n}\nif (!canUseTrustedBinding(args[1])) {\n  await runnerd.materializeVerifiedOpenCodeExecutable(); // re-bind before launching\n}","typeGuard":"function isValidVerifiedExecutablePath(command) {\n  return process.platform === \"darwin\" &&\n    typeof command === \"string\" && require(\"node:path\").isAbsolute(command) &&\n    require(\"node:path\").basename(command) === \"launch\" &&\n    /^\\.paperclip-verified-executable-[0-9a-f]{32}$/.test(require(\"node:path\").basename(require(\"node:path\").dirname(command)));\n}","tryCatchPattern":"try {\n  const binding = trustedOpenCodeLaunchBinding(args);\n  spawnViaBinding(binding);\n} catch (error) {\n  if (error instanceof Error && error.message.includes(\"runner-owned executable binding is unavailable\")) {\n    // binding consumed or invalid; request a fresh one from runnerd\n    const fresh = await runnerd.materializeVerifiedOpenCodeExecutable();\n    spawnViaBinding(trustedOpenCodeLaunchBinding([TRUSTED_OPENCODE_EXECUTABLE_ARG, fresh]));\n    return;\n  }\n  throw error;\n}","preventionTips":["Never reuse a verified executable path across launches — it is one-shot","Always launch through runnerd rather than invoking the proxy manually","Never rely on PAPERCLIP_OPENCODE_COMMAND; the proxy deliberately ignores it","Keep proxy and runnerd on the same QUALIFIED_OPENCODE_VERSION"],"tags":["macos","security","fail-closed","opencode"],"backgroundTag":"trusted-executable-binding-unavailable","analyzedSha":"5716fe907e596ce73501408fc6efdb19fb61edf2","analyzedAt":"2026-09-02T18:44:00.616Z","contentChangedAt":"2026-09-02T18:44:00.616Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}