{"record":{"id":"75212ffe6ef9eaf3","repo":"diegosouzapw/OmniRoute","slug":"skill-file-path-escapes-the-skill-workspace","errorCode":null,"errorMessage":"Skill file path escapes the skill workspace","messagePattern":"Skill file path escapes the skill workspace","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/skills/builtins.ts","lineNumber":81,"sourceCode":"function getWorkspaceRoot(context: { apiKeyId: string }) {\n  return path.join(resolveDataDir(), \"skills\", \"workspaces\", getContextId(context));\n}\n\nfunction resolveWorkspacePath(inputPath: string, context: { apiKeyId: string }) {\n  if (path.isAbsolute(inputPath)) {\n    throw new Error(\"Skill file paths must be relative to the skill workspace\");\n  }\n\n  const segments = inputPath.split(/[\\\\/]+/).filter(Boolean);\n  if (segments.some((segment) => FORBIDDEN_PATH_SEGMENTS.has(segment.toLowerCase()))) {\n    throw new Error(\"Skill file path contains a restricted segment\");\n  }\n\n  const root = path.resolve(getWorkspaceRoot(context));\n  const resolved = path.resolve(root, inputPath);\n  const relative = path.relative(root, resolved);\n  if (!relative || relative.startsWith(\"..\") || path.isAbsolute(relative)) {\n    throw new Error(\"Skill file path escapes the skill workspace\");\n  }\n\n  return { root, resolved, relative };\n}\n\nfunction normalizePositiveInteger(value: unknown, fallback: number, max: number) {\n  if (value === undefined || value === null) return fallback;\n  const parsed = Number(value);\n  if (!Number.isInteger(parsed) || parsed <= 0) return fallback;\n  return Math.min(parsed, max);\n}\n\nfunction sanitizeHeaders(headers: unknown) {\n  if (!headers || typeof headers !== \"object\" || Array.isArray(headers)) return undefined;\n\n  const sanitized: Record<string, string> = {};\n  for (const [key, value] of Object.entries(headers as Record<string, unknown>)) {\n    const normalizedKey = key.trim();","sourceCodeStart":63,"sourceCodeEnd":99,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/skills/builtins.ts#L63-L99","documentation":"Path-containment guard in resolveWorkspacePath: the relative path passed the earlier checks, but resolving it against the workspace root produces a result outside that root — i.e. the input used ../ sequences to escape the per-API-key workspace. The resolution is refused to preserve workspace isolation between API keys.","triggerScenarios":"Thrown at src/lib/skills/builtins.ts:81 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove ../ segments that climb out of the workspace root","Reference files that actually live inside the skill workspace"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}