{"record":{"id":"8c0c368696b4c3c5","repo":"diegosouzapw/OmniRoute","slug":"invalid-backup-id-path-traversal-detected","errorCode":null,"errorMessage":"Invalid backup ID: path traversal detected","messagePattern":"Invalid backup ID: path traversal detected","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/lib/db/backup.ts","lineNumber":384,"sourceCode":"  const backupDir = getBackupDir();\n\n  // Validate format: must be db_<timestamp>_<reason>.sqlite, no path separators\n  if (\n    !backupId.startsWith(\"db_\") ||\n    !backupId.endsWith(\".sqlite\") ||\n    backupId.includes(path.sep) ||\n    backupId.includes(\"/\")\n  ) {\n    throw new Error(\"Invalid backup ID\");\n  }\n\n  const backupPath = path.resolve(backupDir, backupId);\n  // Prevent path traversal: resolved path must stay within backupDir\n  if (\n    !backupPath.startsWith(path.resolve(backupDir) + path.sep) &&\n    backupPath !== path.resolve(backupDir)\n  ) {\n    throw new Error(\"Invalid backup ID: path traversal detected\");\n  }\n\n  if (!fs.existsSync(backupPath)) {\n    throw new Error(`Backup not found: ${backupId}`);\n  }\n\n  // Validate backup integrity\n  try {\n    const { tryOpenSync } = await import(\"@/lib/db/adapters/driverFactory\");\n    const testDb = tryOpenSync(backupPath, { readonly: true });\n    if (!testDb) {\n      throw new Error(\"Backup file is corrupt: could not open\");\n    }\n    let result: Array<{ integrity_check?: string }>;\n    try {\n      result = testDb.pragma(\"integrity_check\") as Array<{ integrity_check?: string }>;\n    } finally {\n      testDb.close();","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/backup.ts#L366-L402","documentation":"Error \"Invalid backup ID: path traversal detected\" thrown in diegosouzapw/OmniRoute.","triggerScenarios":"Thrown at src/lib/db/backup.ts:384 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","schemaVersion":2},"datasetVersion":"2026-08-25T21:54:21.419Z"}