Skip to main content
drupalreleases
Release: Cms 2.2.3 — Update released for Drupal core (2.2.3)! Release: Easy Breadcrumb 2.0.11 — Minor update available for module easy_breadcrumb (2.0.11). Release: Menu Link Attributes 8.x-1.9 — Minor update available for module menu_link_attributes (8.x-1.9). Release: Bootstrap 8.x-3.42 — Minor update available for theme bootstrap (8.x-3.42). Release: PhotoSwipe - Responsive JavaScript Modal Image Gallery 5.0.11 — Minor update available for module photoswipe (5.0.11). Release: Search API attachments 10.0.13 — Minor update available for module search_api_attachments (10.0.13). Release: amazee.ai Private AI Provider 1.4.6 — Minor update available for module ai_provider_amazeeio (1.4.6). Release: amazee.ai Private AI Provider 1.3.10 — Minor update available for module ai_provider_amazeeio (1.3.10). Module Revived: Bootstrap 8.x-3.41 — Theme bootstrap updated after 6 months of inactivity (8.x-3.41). Security Coverage: Component Library — Module component_library now has official Drupal security advisory coverage.

Ai Recipe Guardrails Prompt Safety

Security covered

Part of the AI ecosystem · 340 projects

View on drupal.org

This Drupal recipe installs AI guardrails to protect public AI interactions from malicious input and harmful requests. It uses a combination of regular expressions and AI topic classification to prevent injection attacks and filter out sensitive or risky topics like legal or medical advice before they are processed by AI.

A Drupal recipe that installs a set of AI guardrails to protect public-facing AI interactions from two distinct categories of risk: structurally malicious input (injection attacks) and semantically harmful requests (topics with legal or reputational exposure). Apply this recipe as a baseline safety layer on any site where the AI module processes untrusted user input.

What This Recipe Does

This recipe installs ten individual guardrails and two guardrail sets into a Drupal site running the AI module.

Guardrail Set: Prompt Safety — Security

Contains seven guardrails applied to the pre-generate phase (user input). It covers two layers of protection:

  • Regex-based (six guardrails): fast, zero-cost checks that detect structurally malicious strings such as <script> tags, inline event handlers, javascript: URLs, dangerous HTML tags, CSS expression injection, and JavaScript execution function calls.
  • AI-based (one guardrail): topic classification that detects semantic prompt manipulation like jailbreak attempts, system prompt overrides, and role hijacking, where rigid patterns are insufficient because attack phrasing constantly evolves.

Guardrail Set: Prompt Safety — Liability

Contains three guardrails applied to the pre-generate phase (user input). All three use AI topic classification to detect requests covering domains where an automated response creates legal or reputational risk for the site operator:

  • Legal Advice: contract interpretation, litigation strategy, regulatory compliance.
  • Medical Advice: diagnosis, treatment recommendations, medication guidance.
  • Sensitive Topics: politically and socially divisive subjects (elections, religion, war, etc.).

When to use this recipe:

  • Any public-facing AI interaction (chatbots, AI assistants, content generation tools)
  • Sites where users can submit free-text prompts that reach an AI provider
  • Environments that need a documented, auditable safety baseline before deploying AI features

Requirements

  • Drupal 11.2 or later
  • drupal/ai ^1.3
  • A configured AI provider that supports topic classification (required by the four restrict_to_topic guardrails)

How to Apply

Run the following Drush command from your Drupal root:


drush recipe ../recipes/ai_recipe_guardrails_prompt_safety 

The recipe does not configure a specific AI provider or model. The restrict_to_topic guardrails will use whichever provider and model your site has set as the default for the AI module.

Configuration Installed

Guardrail Sets

Machine name Label Guardrails included Phase prompt_safety_security Prompt Safety: Security 7 (see below) Pre-generate prompt_safety_liability Prompt Safety: Liability 3 (see below) Pre-generate

Stop threshold for both sets: 0.8

Guardrails

Machine name Label Plugin security_script_tag_injection Security: Script Tag Injection regexp_guardrail security_dangerous_html_tags Security: Dangerous HTML Tags regexp_guardrail security_html_event_handler_injection Security: HTML Event Handler Injection regexp_guardrail security_javascript_protocol Security: JavaScript Protocol regexp_guardrail security_javascript_execution_functions Security: JavaScript Execution Functions regexp_guardrail security_css_expression_injection Security: CSS Expression Injection regexp_guardrail security_prompt_manipulation Security: Prompt Manipulation restrict_to_topic liability_legal_advice Liability: Legal Advice restrict_to_topic liability_medical_advice Liability: Medical Advice restrict_to_topic liability_sensitive_topics Liability: Sensitive Topics restrict_to_topic

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
1
Tracked since
Mar 2026
Latest release
6 months ago
Releases (12 mo)
1 ▲ from 0
Maintenance
Slowing

Releases

Version Type Core Release date
1.0.0 Stable Mar 23, 2026