---
title: Injection Detection (NeMo Guardrail)
type: guardrail
provider: nvidia
category: safety
source: 'https://github.com/NVIDIA-NeMo/Guardrails'
license: Apache-2.0
tags:
  - guardrail
  - nemo
  - rails
  - colang
dateAdded: '2026-05-10'
featured: false
origin: official
language: en
description: >-
  flow injection detection """ Reject, omit, or sanitize injection attempts from
  the bot. This rail operates on the $bot_message. """ response = await I
---

```coffee
flow injection detection
  """
  Reject, omit, or sanitize injection attempts from the bot.
  This rail operates on the $bot_message.
  """
  response = await InjectionDetectionAction(text=$bot_message)
  join_separator = ", "
  injection_detection_action = $config.rails.config.injection_detection.action

  if response["is_injection"]
    if $config.enable_rails_exceptions
      send InjectionDetectionRailException(message="Output not allowed. The output was blocked by the 'injection detection' flow.")
    else if injection_detection_action == "reject"
      bot "I'm sorry, the desired output triggered rule(s) designed to mitigate exploitation of {{ response.detections | join(join_separator) }}."
      abort
    else if injection_detection_action == "omit" or injection_detection_action == "sanitize"
      $bot_message = response["text"]
  else
    $bot_message = response["text"]
```
