Sensitive content in user prompt
The Sensitive content in user prompt policy detects sensitive data - such as credentials, PII, financial information, and government IDs - in user messages before they reach the AI model. Administrators define regex-based pattern groups to identify content that should not appear in prompts, and choose whether to flag matches for review or block the interaction.
This policy scans user prompts only. It does not scan AI-generated responses or retrieved data.
Prerequisites and roles
Prerequisites and roles
To identify and manage sensitive content in user prompts, have one of the following roles:
| Role | Responsibilities |
|---|---|
| Super Admin | Sets up security features, assigns elevated roles. Can assign the Sensitive Content Moderator (SCM) role. |
| Sensitive Content Moderator (SCM) | Configures pattern groups, reviews findings, and manages enforcement actions. |
Only a Super Admin or SCM can see the Glean Protect admin menu and configure this policy.
Pattern groups
A pattern group is a collection of related regex patterns organized by category. For example, a "Credentials & Secrets" group might contain patterns for AWS keys, JWT tokens, and private keys.
Each pattern group has:
- Name - a descriptive label shown in the admin UI and findings
- Description (optional) - context about what the group detects
- Patterns - one or more regex patterns, each individually toggleable
Templates
Glean provides pre-built pattern group templates for common sensitive content categories. Templates are copies. Once you add a template, you fully own the patterns and can modify, enable, or disable them independently.
| Template | Patterns included | Example matches |
|---|---|---|
| Credentials & Secrets | Generic API Key/Secret, Vendor-Prefixed API Key, Bearer Token, JWT Token, AWS Access Key ID, Basic Auth Header, Private Key (PEM) | AKIA1234ABCD5678EFGH, eyJhbGci... |
| PII | Email Address, US Phone Number, IPv4 Address | user@company.com, (555) 123-4567 |
| Financial Data | Credit Card Number, IBAN Code | 4XXX-XXXX-XXXX-1234 |
| Government IDs | US SSN, US ITIN, UK NINO, India Aadhaar, Canada SIN | 123-45-6789 |
All template patterns start disabled. You choose which to enable after copying.
Steps
Here's how to add patterns you want to detect in user prompts:
- In the Admin Console, navigate to Glean Protect > AI Security > Policies.
- Select Sensitive content in user prompt.
- Click Add pattern group and select a template (or create a custom group).
- Enable the patterns you want to detect.
- Choose an enforcement action (Flag for review or Block).
- Click Save.
Enforcement options
Target
Use Target to choose where the policy is applied. You can select one or more:
- Glean Assistant - applies to all Glean chat messages.
- Interactive agents - applies to interactive (chat-based) agents.
- Automatically triggered agents - applies to scheduled or content-triggered agents.
Action
| Action | Behavior | Use when |
|---|---|---|
| Flag for review (Monitor) | The prompt proceeds normally. A finding is created for admin review in the Findings tab. | You want visibility without disrupting users. Recommended for initial rollout. |
| Block the run | The prompt is rejected immediately. The user sees a policy violation message. The agent run is terminated. | You need strict enforcement for highly sensitive content (e.g., production API keys). |
Regex-based matching can produce false positives - for example, a phone number pattern might match an order ID, or a credit card pattern might match a long numeric string in a document reference. Always start with Flag for review mode to evaluate match quality before switching to Block. Overly broad patterns in Block mode will disrupt users with incorrect rejections.
Enforcement applies to all pattern groups collectively. You cannot set different actions per group.
How to configure
Add a pattern group from a template
- Navigate to the Sensitive content policy page.
- Click Add pattern group.
- In the modal, click a template card (e.g., "Credentials & Secrets").
- The pattern group drawer opens pre-filled with the template's patterns.
- Toggle on the patterns you want to enable.
- Optionally modify the name, description, or patterns.
- Click Add.
- Click Save on the policy page to apply.
Create a custom pattern group
- Click Add pattern group.
- Click Create custom pattern group.
- Enter a name (required) and optional description.
- Click + Add pattern to add regex patterns:
- Name - descriptive label for the pattern
- Pattern (Regex) - the RE2 regex expression
- Toggle patterns on/off as needed.
- Click Add.
- Click Save on the policy page to apply.
Test patterns before enabling
- Open the pattern group drawer.
- Enter sample text in the Text to test area.
- Click View results.
- Review which patterns matched and what text they detected.
- Adjust patterns as needed before enabling enforcement.
Review findings
When patterns match in Monitor mode:
- Navigate to Glean Protect > AI Security > Findings.
- Filter by Policy: Sensitive content in user prompt.
- Click a finding to see:
- Snippet - the user's message that triggered the match
- Matches - which pattern groups and patterns fired
- Surface - whether it was Glean Chat or an Agent
- Conversation link - jump to the full conversation for context
Pattern syntax
Patterns use RE2 regex syntax (full reference). RE2 provides linear-time matching performance, making it safe for real-time scanning.
Supported features:
- Character classes:
[A-Z],[0-9],\d,\w,\s - Quantifiers:
*,+,?,{n},{n,m} - Alternation:
| - Grouping:
(?:...)(non-capturing) - Anchors:
\b(word boundary),^,$ - Case-insensitive:
(?i)
Not supported:
- Lookaheads:
(?=...),(?!...) - Lookbehinds:
(?<=...),(?<!...) - Backreferences:
\1,\2
If you receive an error about "unsupported Perl syntax", your pattern likely uses a feature not available in RE2.
Limits
| Resource | Limit |
|---|---|
| Pattern groups per policy | 10 |
| Patterns per group | 10 |
| Pattern regex length | 500 characters |
| Test input text length | 2,000 characters |
Best practices
- Start with Monitor mode. Enable patterns in Flag for Review mode first. Review findings for 1-2 weeks to identify false positives before switching to Block.
- Be specific with patterns. Broad patterns generate noise. Prefer patterns with structural markers (separators, prefixes, specific lengths) over patterns that match any N-digit number.
- Use templates as a starting point. Templates provide well-tested patterns. Copy and customize rather than writing from scratch.
- Organize by sensitivity. Create separate groups for content that requires different levels of urgency when reviewing findings.
- Test before enabling. Always use the test feature to validate patterns against representative sample text before enabling them for production traffic.