diegosouzapw/OmniRoute · error

SECURITY_001

SECURITY_001

Error message

Request blocked: potential prompt injection detected

What it means

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.

Solutions

  1. Remove injection-like patterns (role-override, instruction smuggling) from the prompt
  2. If this is a false positive, adjust guard sensitivity/allowlist configuration
  3. Send the request through an approved path with the guard explicitly relaxed
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/app/api/v1/chat/completions/route.ts:178 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/a4f9b8d2ffefdc8b. Report an issue: GitHub.

Appendix: source

Thrown at src/app/api/v1/chat/completions/route.ts:178

        }

        // Resolve model alias before forwarding to handleChat
        if (parsedBody && typeof parsedBody === "object") {
          await resolveModelAliasWithSeedFallbackOnBody(parsedBody).catch(() => {
            /* swallow — fall through with original model */
          });
        }
        admission.lease = structuralAdmission.lease;

        const { blocked, result } = injectionGuard(parsedBody);
        if (blocked) {
          return finishAdmission(
            new Response(
              JSON.stringify({
                error: {
                  message: "Request blocked: potential prompt injection detected",
                  type: "injection_detected",
                  code: "SECURITY_001",
                  detections: result.detections.length,
                },
              }),
              { status: 400, headers: { ...CORS_HEADERS, "Content-Type": "application/json" } }
            )
          );
        }
      }
    } catch (error) {
      console.error("[SECURITY] Prompt injection guard failed:", error);
    }

    // Gate the early SSE keepalive wrapper: only wrap when the client explicitly
    // asks for streaming (body `stream: true`) or the Accept header forces SSE.
    // The parsed body is passed through UNTOUCHED — the actual stream/JSON framing
    // stays decided by chatCore/resolveStreamFlag (legacy streaming default and the
    // per-key `streamDefaultMode: "json"` opt-in are preserved).
    const parsedBodyIsRecord = isRecord(parsedBody);

View on GitHub (pinned to a179ffed5b)