{"record":{"id":"a4f9b8d2ffefdc8b","repo":"diegosouzapw/OmniRoute","slug":"security-001","errorCode":"SECURITY_001","errorMessage":"Request blocked: potential prompt injection detected","messagePattern":"Request blocked: potential prompt injection detected","errorType":"http","errorClass":null,"httpStatus":400,"severity":"error","filePath":"src/app/api/v1/chat/completions/route.ts","lineNumber":178,"sourceCode":"        }\n\n        // Resolve model alias before forwarding to handleChat\n        if (parsedBody && typeof parsedBody === \"object\") {\n          await resolveModelAliasWithSeedFallbackOnBody(parsedBody).catch(() => {\n            /* swallow — fall through with original model */\n          });\n        }\n        admission.lease = structuralAdmission.lease;\n\n        const { blocked, result } = injectionGuard(parsedBody);\n        if (blocked) {\n          return finishAdmission(\n            new Response(\n              JSON.stringify({\n                error: {\n                  message: \"Request blocked: potential prompt injection detected\",\n                  type: \"injection_detected\",\n                  code: \"SECURITY_001\",\n                  detections: result.detections.length,\n                },\n              }),\n              { status: 400, headers: { ...CORS_HEADERS, \"Content-Type\": \"application/json\" } }\n            )\n          );\n        }\n      }\n    } catch (error) {\n      console.error(\"[SECURITY] Prompt injection guard failed:\", error);\n    }\n\n    // Gate the early SSE keepalive wrapper: only wrap when the client explicitly\n    // asks for streaming (body `stream: true`) or the Accept header forces SSE.\n    // The parsed body is passed through UNTOUCHED — the actual stream/JSON framing\n    // stays decided by chatCore/resolveStreamFlag (legacy streaming default and the\n    // per-key `streamDefaultMode: \"json\"` opt-in are preserved).\n    const parsedBodyIsRecord = isRecord(parsedBody);","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/app/api/v1/chat/completions/route.ts#L160-L196","documentation":"The prompt-injection guard ran on the parsed chat.completions body before forwarding and classified the content as a probable injection attempt, so admission stops with this blocked response instead of proxying to the provider. It is a deliberate security filter, not a provider fault.","triggerScenarios":"Thrown at src/app/api/v1/chat/completions/route.ts:178 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Remove injection-like patterns (role-override, instruction smuggling) from the prompt","If this is a false positive, adjust guard sensitivity/allowlist configuration","Send the request through an approved path with the guard explicitly relaxed"],"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"}