---
title: Sensitive Data 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-04-08'
featured: false
origin: official
language: en
description: >-
  INPUT RAILS flow detect sensitive data on input """Check if the user input has
  any sensitive data.""" $has_sensitive_data = await DetectSensitiveDataA
---

```coffee
# INPUT RAILS

flow detect sensitive data on input
  """Check if the user input has any sensitive data."""
  $has_sensitive_data = await DetectSensitiveDataAction(source="input", text=$user_message)

  if $has_sensitive_data
    bot inform answer unknown
    abort


flow mask sensitive data on input
  """Mask any sensitive data found in the user input."""
  global $user_message
  $user_message = await MaskSensitiveDataAction(source="input", text=$user_message)


# OUTPUT RAILS


flow detect sensitive data on output
  """Check if the bot output has any sensitive data."""
  $has_sensitive_data = await DetectSensitiveDataAction(source="output", text=$bot_message)

  if $has_sensitive_data
    bot inform answer unknown
    abort


flow mask sensitive data on output
  """Mask any sensitive data found in the bot output."""
  global $bot_message
  $bot_message = await MaskSensitiveDataAction(source="output", text=$bot_message)


# RETRIEVAL RAILS


flow detect sensitive data on retrieval
  """Check if the relevant chunks from the knowledge base have any sensitive data."""
  $has_sensitive_data = await DetectSensitiveDataAction(source="retrieval", text=$relevant_chunks)

  if $has_sensitive_data
    bot inform answer unknown
    abort


flow mask sensitive data on retrieval
  """Mask any sensitive data found in the relevant chunks from the knowledge base."""
  global $relevant_chunks
  $relevant_chunks = await MaskSensitiveDataAction(source="retrieval", text=$relevant_chunks)
```
