{"record":{"id":"efba852c5fed4ebe","repo":"abhigyanpatwari/GitNexus","slug":"refusing-world-writable-auto-sync-clone-root-ro","errorCode":null,"errorMessage":"Refusing world-writable auto-sync clone root: ${root}","messagePattern":"Refusing world-writable auto-sync clone root: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/auto-sync/path-security.ts","lineNumber":276,"sourceCode":"export async function assertDirectoryOwnerAndPermissions(root: string): Promise<void> {\n  const stat = await fs.stat(root);\n  if (!stat.isDirectory()) throw new Error(`auto-sync clone root is not a directory: ${root}`);\n  // POSIX uid/mode have no meaning on Windows, and this runs on every tick for\n  // every project, so throwing here failed 100% of repos forever while `watch\n  // status` still read `running`. Skip the ownership assertions rather than the\n  // whole feature: the caller's other guards — dangerous-root rejection\n  // (including the Windows system roots), symlink refusal, realpath containment\n  // and the GitNexus-internal-root check — all still apply, and managed git runs\n  // with `core.hooksPath` pinned to the null device.\n  if (process.platform === 'win32') return;\n  if (typeof process.getuid === 'function' && stat.uid !== process.getuid()) {\n    throw new Error(`auto-sync clone root is owned by uid ${stat.uid}, not current process uid`);\n  }\n  const mode = stat.mode & 0o777;\n  const groupWritable = (mode & 0o020) !== 0;\n  const worldWritable = (mode & 0o002) !== 0;\n  if (worldWritable) {\n    throw new Error(`Refusing world-writable auto-sync clone root: ${root}`);\n  }\n  if (groupWritable) {\n    throw new Error(`Refusing group-writable auto-sync clone root: ${root}`);\n  }\n}\n\nfunction assertContainedOrSame(root: string, child: string, message: string): void {\n  const rel = path.relative(root, child);\n  if (rel.startsWith('..') || path.isAbsolute(rel)) throw new Error(message);\n}\n","sourceCodeStart":258,"sourceCodeEnd":287,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/0d1aed942f0e8b5d3bac27519fff441aceea722d/gitnexus/src/core/auto-sync/path-security.ts#L258-L287","documentation":"Thrown by assertDirectoryOwnerAndPermissions (POSIX only) when the clone-root directory's permission mode has the other-write bit set (mode & 0o002). A world-writable directory lets any local user add, remove, or replace cloned repositories, which auto-sync would then pull and index — a privilege-escalation vector into the analysis pipeline. The guard rejects the directory rather than downgrading expectations.","triggerScenarios":"Thrown at gitnexus/src/core/auto-sync/path-security.ts:276 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["chmod o-w <root> to clear the world-write bit (e.g. chmod 755)","Run chmod -R o-w over the clone root if subdirectories inherited the permissive mode","Avoid /tmp-style shared locations; use a dedicated directory with restrictive permissions"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0d1aed942f0e8b5d3bac27519fff441aceea722d","analyzedAt":"2026-09-08T00:40:44.970Z","contentChangedAt":"2026-09-08T00:40:44.970Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}