New to FORGE? Start a free 30-day trial

Prompt Safety Validation

Updated on Oct 1, 2026

Forge scans input for prompt injection patterns before it sends content to the AI agent. Detection protects against instructions hidden in issues, tickets, modifier files such as edit.md, or custom prompts. This page describes the built-in rules and how to handle false positives.

How it works

  1. Before composing a prompt, Forge checks the input against the detection rules.
  2. A match with severity error blocks the command. A match with severity warn is logged, and the command continues.
  3. Matches inside Markdown code fences are skipped by the default allowlist.
  4. Forge logs each detection with the rule ID, rule name, source, matched content, and position, and records whether you bypassed the check.

Example output (abbreviated):

Error: Prompt injection attempt detected

Detected patterns:
 …

This content was blocked because it contains patterns commonly
used in prompt injection attacks.

To proceed anyway (not recommended):
 …

Security implications of bypassing:
 - AI agent may execute hidden instructions
 - Bypass attempts are logged for security audit

Built-in rules

Rule IDSeverityDetects
invisible-unicodeerrorZero-width spaces, direction overrides, and other invisible characters
ignore-instructionserror"Ignore previous instructions" and similar phrases
forget-instructionserrorAttempts to clear the AI's memory or context
new-roleerror"You are now a…", "act as…", "pretend to be…"
system-tagerrorSystem markers such as system:, <system>, [SYSTEM]
delimiter-injectionerrorLLM prompt delimiters such as ### SYSTEM or `<
jailbreak-attempterrorKnown jailbreak phrases
role-overrideerror"Your new role…", "from now on you…"
rm-recursivewarnrm -rf commands
format-drivewarnDisk format commands (format c:, mkfs)
drop-tablewarnSQL DROP TABLE, DROP DATABASE, DROP SCHEMA
delete-sql-no-wherewarnSQL DELETE FROM without WHERE
git-force-pushwarngit push --force
curl-pipe-basherrorDownloads piped to a shell (curl … | sh)
chmod-777warnchmod 777
base64-payloadwarnLong base64-like strings that may hide instructions

Handle false positives

Legitimate content can trigger detection, for example security documentation, training material, or code examples with shell commands.

Bypass the check for one run

bash
frg issue draft --bypass-safety-checks

The help text for --bypass-safety-checks says:

WARNING: This flag should only be used when you have manually verified the input is safe. Bypassed attempts are logged for security audit.

Add allowlist entries

  1. Export the built-in configuration:
bash
frg config export --security

This creates .forge/config/.prompt-safety.toml with the built-in rules and the default allowlist.

  1. Add entries to the [allowlist] section:
toml
[allowlist]
# Content containing these exact strings is allowed
strings = [
"example: rm -rf in documentation",
]

# If a regex matches, detection is skipped
regexes = [
"```[\\s\\S]*?```",
]

# Paths to exclude from validation
paths = [
".forge/prompts/examples/",
"test/fixtures/",
"docs/security-training/",
]
  1. Validate the configuration:
bash
frg config validate

Keep allowlist entries specific. A broad regular expression can hide a real attack.

Lower a rule's severity

In the exported file, change a rule's severity from "error" to "warn" so matches are logged but don't block the command.

Configuration reference

File: .forge/config/.prompt-safety.toml. If the file doesn't exist or can't be loaded, Forge uses the built-in defaults.

KeyDescriptionDefault
schema_versionConfiguration schema version."1.0.0"
[settings] enabledTurns prompt safety validation on or off.true
[settings] default_severitySeverity for rules that don't set one: "error" or "warn"."error"
[[rules]] idUnique rule identifier.—
[[rules]] nameHuman-readable name.—
[[rules]] descriptionWhat the rule detects.—
[[rules]] patternRegular expression to match. Use (?i) for case-insensitive matching.—
[[rules]] severity"error" blocks the command; "warn" logs and continues.default_severity
[[rules]] tagsCategory labels, for example ["injection", "override"].—
[allowlist] stringsExact strings to allow.[]
[allowlist] regexesRegular expressions; if one matches, detection is skipped.Markdown code fences
[allowlist] pathsPaths to exclude from validation..forge/prompts/examples/, test/fixtures/

In TOML basic strings ("…"), escape backslashes in patterns, for example "\\s+".

Custom rule example:

toml
[[rules]]
id = "internal-override"
name = "Internal Override Phrase"
description = "Detects the phrase our red team uses in injection tests"
pattern = "(?i)disregard\\s+the\\s+ticket\\s+above"
severity = "error"
tags = ["injection", "override"]

Review detections

Forge writes a log entry for each detection, including whether it was blocked (Prompt injection detected and BLOCKED) or bypassed (Prompt injection detected but BYPASSED by user). Review bypass events regularly.

See Also