{"record":{"id":"ad575884237d67a2","repo":"diegosouzapw/OmniRoute","slug":"plugin-manifest-name-integrity-mismatch-expe","errorCode":null,"errorMessage":"Plugin '${manifest.name}' integrity mismatch: expected ${integrityField}, got ${actual}","messagePattern":"Plugin '(.+?)' integrity mismatch: expected (.+?), got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/plugins/loader.ts","lineNumber":159,"sourceCode":"export async function loadPlugin(\n  entryPoint: string,\n  manifest: PluginManifestWithDefaults\n): Promise<LoadedPlugin> {\n  // Integrity check: if the manifest declares an integrity field, verify the entry point.\n  // Missing integrity is OK for backward compatibility; mismatched integrity is a fatal error.\n  const integrityField = (manifest as unknown as Record<string, unknown>).integrity;\n  if (typeof integrityField === \"string\" && integrityField.length > 0) {\n    let source: string;\n    try {\n      source = await readFile(entryPoint, \"utf-8\");\n    } catch (err: unknown) {\n      throw new Error(\n        `Plugin '${manifest.name}' integrity check failed: cannot read entry point — ${err instanceof Error ? err.message : String(err)}`\n      );\n    }\n    const actual = computeIntegrity(source);\n    if (actual !== integrityField) {\n      throw new Error(\n        `Plugin '${manifest.name}' integrity mismatch: expected ${integrityField}, got ${actual}`\n      );\n    }\n  }\n\n  const permissions = manifest.requires.permissions;\n\n  // IMPORTANT-6: Write the host script with O_EXCL (wx flag) so the open fails if\n  // anything already exists at that path, defeating symlink/pre-create races (TOCTOU).\n  // mode 0o600 ensures no other OS user can read or replace the script.\n  // On EEXIST collision (astronomically unlikely with UUID but theoretically possible),\n  // retry once with a fresh UUID.\n  let hostScriptPath: string;\n  {\n    // .mjs extension forces ESM execution regardless of package.json type field\n    const tryWrite = async (id: string): Promise<string> => {\n      const p = join(tmpdir(), `omniroute-plugin-host-${id}.mjs`);\n      await writeFile(p, PLUGIN_HOST_SCRIPT, { encoding: \"utf-8\", mode: 0o600, flag: \"wx\" });","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/plugins/loader.ts#L141-L177","documentation":"loadPlugin computed the SHA/declared integrity of the entry-point source and it does not match manifest.integrity. A mismatch is fatal — the plugin files were modified or corrupted after the manifest was written, possibly tampered.","triggerScenarios":"Thrown at src/lib/plugins/loader.ts:159 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reinstall the plugin from a trusted source to restore matching files","Recompute the integrity hash only if you intentionally modified the plugin","Investigate the host for unauthorized file changes before trusting the plugin","Refresh the marketplace entry if the published checksum changed"],"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"}