Webhook icon
Schedule icon
WorkingDirectory icon
Script icon
Process icon
If icon
Loop icon
StructuredOutputCompletion icon
Parallel icon
Create icon
SlackIncomingWebhook icon

Firewall AI Agent Inputs Against Prompt Injection

Webhook firewall for AI agent inputs detecting prompt injection with LLM-judged triage, quarantine, GitHub issues, and Slack alerts.

Categories
AI

Diagram unavailable

We could not build the topology for this blueprint. The flow itself is valid, use the YAML on the left to run it.

Prompt injection is the top risk for LLM applications, and most agent stacks have no gate between the incoming prompt and the model. A single "ignore your instructions" buried in user input, a pasted chat log, or a tool result can hijack the agent. This blueprint firewalls every inbound prompt: a detection engine flags instruction overrides, prompt-extraction probes, role-play jailbreaks, and delimiter smuggling, borderline findings are judged by Gemini to separate real attacks from coincidental wording, confirmed attacks are quarantined before the model ever sees them, and the attempt escalates to a GitHub issue plus a Slack alert. Clean prompts are recorded as passed, giving security an auditable trail.

How it works

  1. on_agent_input (io.kestra.plugin.core.trigger.Webhook) receives each inbound prompt from the agent gateway on a keyed URL before the model is invoked; a disabled daily_fixture_replay Schedule shows the cron pattern for replaying a recorded fixture unattended.
  2. collect_inputs (io.kestra.plugin.scripts.python.Script) writes the payload's prompts to inputs.jsonl, falling back to a built-in fixture (with seeded attacks) for manual test runs.
  3. scan_inputs (Python) runs the detection engine: instruction-override phrases, prompt-extraction probes, role-play jailbreak patterns, and fake system delimiters. Findings below min_severity are dropped, and the list is emitted through the outputs protocol.
  4. triage (io.kestra.plugin.core.flow.If) branches on the finding count: a clean prompt goes straight to record_clean_run.
  5. judge_findings (io.kestra.plugin.core.flow.Loop, concurrencyLimit: 3) sends each finding to judge_finding (io.kestra.plugin.gemini.StructuredOutputCompletion) for an attack/benign verdict with a rationale, so coincidental wording never triggers a quarantine.
  6. quarantine_and_escalate (io.kestra.plugin.core.flow.Parallel) runs three branches at once: quarantine_inputs copies the offending prompts with their reasons attached; raise_issue (io.kestra.plugin.github.issues.Create) opens a labeled tracking issue; notify_slack (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) pages the security channel.

What you get

  • A real injection screen for the input channel: the leg of agent security the gallery was missing (tool calls and outputs already have blueprints).
  • LLM-judged triage that suppresses coincidental matches before they block anyone.
  • Quarantined prompts preserved for review, never sent to the model, with raw findings kept for forensics.
  • GitHub issues plus Slack alerts on the same run, and an auditable clean-run record for compliance.

Who it's for

  • AI security engineers and platform teams running customer-facing agents, copilots, or support automation.
  • Trust & safety teams who need evidence that inbound prompts are screened for injection.
  • Teams relying on the model to "just ignore" hostile instructions, which is not a control.

Why orchestrate this with Kestra

A script can run the patterns, but it can't gate a run declaratively: Kestra's keyed webhook makes the firewall event-driven, the Loop with concurrencyLimit throttles the LLM judging under quota, Parallel keeps quarantine, ticketing, and alerting independent, and every execution is an auditable record of what was screened, what was blocked, and what was done. Retries and secret masking come free; a middleware snippet gives you none of that.

Prerequisites

  • An agent gateway able to POST inbound prompts to a webhook before invoking the model, or manual runs against the built-in fixture.
  • A Google Gemini API key for the judging step.
  • A GitHub token with issue-write scope on the tracking repository.
  • A Slack incoming webhook URL for the security channel.

Secrets

  • INPUT_FIREWALL_WEBHOOK_KEY: key for the inbound webhook URL (required).
  • GEMINI_API_KEY: API key for the per-finding attack/benign judgments (required).
  • GITHUB_TOKEN: token used to open the tracking issue (required).
  • SLACK_WEBHOOK_URL: incoming webhook for the security-channel alert (required).

Quick start

  1. Add the four secrets above to your Kestra namespace.
  2. Import this blueprint and run it manually. The built-in fixture contains seeded attacks, so you should see findings, judgments, a quarantine file, and (with the secrets set) a real issue and Slack message.
  3. Point your agent gateway at the on_agent_input webhook URL with payload shape {"inputs": [{"run_id": "...", "agent": "...", "channel": "...", "text": "..."}]}.
  4. Tune min_severity, then enable the daily_fixture_replay trigger if you want a scheduled safety net.

How to extend

  • Add multilingual injection patterns or a dedicated classifier for your threat model.
  • Feed confirmed attacks into a blocklist so repeat offenders are rejected without LLM judging.
  • Route critical findings to PagerDuty instead of Slack.
  • Mirror the flow for tool-result inputs, which are the other major injection vector.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.