{"record":{"id":"87444413b91a3a81","repo":"santifer/career-ops","slug":"output-escapes-the-tracker-workspace-entryoutpu","errorCode":null,"errorMessage":"output escapes the tracker workspace: ${entryOutput}","messagePattern":"output escapes the tracker workspace: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"generate-pdf.mjs","lineNumber":1484,"sourceCode":"      const entryReport = (spec.reportNum ?? '').toString().trim();\n      if (entryReport && !/^\\d+$/.test(entryReport)) {\n        throw new Error(`invalid reportNum \"${entryReport}\" (use the numeric report number)`);\n      }\n\n      // Resolve manifest-supplied input/output relative to the manifest's own\n      // directory, not process.cwd(), so a manifest renders identically wherever\n      // the batch is launched from. Absolute paths in the manifest still win\n      // (resolve() ignores the base when the tail is absolute).\n      const entryInput = resolve(manifestDir, spec.input);\n      const entryOutput = resolve(manifestDir, spec.output);\n\n      // Path-containment guards (realpath-based): keep the read and write inside\n      // the tracker workspace even through a symlinked ancestor. A batch\n      // manifest that escapes the workspace is malformed/tampered and is\n      // recorded as a per-entry failure rather than read or written.\n      assertInsideWorkspace(entryInput, 'input');\n      if (!isWorkspaceOutputPath(entryOutput, workspaceRoot)) {\n        throw new Error(`output escapes the tracker workspace: ${entryOutput}`);\n      }\n\n      let html = await readFile(entryInput, 'utf-8');\n      // Same order as the single render: reorder first so the guard judges the\n      // document that will actually be printed. Without this the batch path\n      // rendered N CVs with cv.sections silently inert.\n      html = reorderCvSections(html, cvSectionOrder);\n      validateCvSectionOrder(html, cvMarkdown, { allowReorder: globals.allowReorder });\n      html = normalizeTextForATS(html).html;\n\n      entries.push({\n        _idx: i,\n        html,\n        outputPath: entryOutput,\n        format: entryFormat,\n        baseDir: dirname(entryInput),\n        reportNum: entryReport,\n        inputPath: entryInput,","sourceCodeStart":1466,"sourceCodeEnd":1502,"githubUrl":"https://github.com/santifer/career-ops/blob/aac998c7ed7248ea853b720ceeb1fdbeb322fc5d/generate-pdf.mjs#L1466-L1502","documentation":"In the batch PDF renderer, every entry's output path is checked with isWorkspaceOutputPath() against the tracker workspace root (realpath-based, symlink-aware). A manifest entry whose resolved output falls outside the workspace is treated as malformed or tampered and recorded as a per-entry failure instead of being written.","triggerScenarios":"A batch manifest entry with an output path that resolves outside the workspace root — e.g. '../leak.pdf', '/tmp/x.pdf', or a symlinked ancestor that retargets outside the tree.","commonSituations":"Reusing manifests across machines or launch directories where a relative output resolves differently; deliberate or accidental paths with ../ segments; workspace root moved or symlinked so previously-valid outputs now resolve outside.","solutions":["Change the entry's output to a path inside the tracker workspace (e.g. output/042.pdf).","If the file legitimately belongs elsewhere, render inside the workspace and move/copy it afterwards.","Verify where workspaceRoot resolves (realpath) — a symlinked launch directory can make relative outputs escape unintentionally."],"exampleFix":"// before (manifest entry)\n{ \"input\": \"cv.html\", \"output\": \"../shared/cv.pdf\" }\n// after\n{ \"input\": \"cv.html\", \"output\": \"output/cv.pdf\" }","handlingStrategy":"validation","validationCode":"import { resolve } from 'node:path';\nconst out = resolve(workspaceRoot, spec.output);\nif (!out.startsWith(workspaceRoot + '/')) {\n  throw new Error(`output must stay inside workspace: ${spec.output}`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  await renderEntry(spec);\n} catch (err) {\n  if (err.message.startsWith('output escapes the tracker workspace')) {\n    failures.push({ entry: spec, reason: err.message });\n  } else throw err;\n}","preventionTips":["Keep all manifest output paths relative to the workspace and starting without '..'.","Realpath the workspace root once and assert every entry output is contained in it.","Never generate output paths by concatenating user input."],"tags":["security","path-traversal","batch","workspace"],"backgroundTag":"path-traversal-blocked","analyzedSha":"aac998c7ed7248ea853b720ceeb1fdbeb322fc5d","analyzedAt":"2026-09-16T06:35:29.214Z","contentChangedAt":"2026-09-16T06:35:29.214Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}