AI Threat Detection & Risk Policy
Relevant source files
The following files were used as context for generating this wiki page:
- server/design/risk/design.go
- server/internal/assistants/managed_assistant_instructions.txt
- client/dashboard/src/pages/security/PolicyStart.tsx
- client/dashboard/src/lib/insights-suggestions.ts
- examples/functions-approve/src/functions.ts
- server/internal/plugins/platform_mcp_skills/create-guardrail-from-description/SKILL.md
The AI Threat Detection and Risk Policy system provides a security layer for AI interactions. It scans chat messages, tool calls, and agent behaviors for issues such as sensitive data exposure, prompt injection, and unauthorized Model Context Protocol (MCP) usage. The system enforces organizational governance by flagging, warning, or blocking actions that violate defined risk policies.
Sources: server/design/risk/design.go:9-10, server/internal/assistants/managed_assistant_instructions.txt:41-45, README.md
Policy Architecture and Types
Risk policies serve as the primary configuration for the threat detection system. Each policy belongs to a project and defines specific detectors to enable and actions to take when a match occurs.
Policy Classifications
The system supports two primary categories of policies:
- Standard Policies: Use deterministic detection engines such as regex-based secret scanners (gitleaks), PII entity detectors (presidio), and custom logic for destructive tools or shadow MCPs.
- Prompt-based Policies: Employ an LLM judge to evaluate messages against specific guardrail instructions.
Sources: server/design/risk/design.go:21-25, client/dashboard/src/pages/security/PolicyStart.tsx:556-560
This diagram shows the relationship between different detector types and the available enforcement actions.
Sources: server/design/risk/design.go:21-65, client/dashboard/src/pages/security/PolicyStart.tsx:32-43
Detection Sources and Categories
The system classifies findings into several detector families (sources). These are mapped to user-friendly categories for dashboard reporting and filtering.
| Source | Category / Description | Detection Method |
|---|---|---|
gitleaks | Secrets & Credentials | Regex-based scanning for API keys and tokens. |
presidio | PII Entities | Detection of emails, SSNs, and credit cards. |
prompt_injection | Injection Attempts | LLM-based analysis of malicious prompt attempts. |
shadow_mcp | Shadow AI / Unapproved MCP | Detection of calls to MCP servers not on approved lists. |
destructive_tool | Destructive Actions | Matching tool calls against destructive intent patterns. |
llm_analyzer | LLM Analysis | Higher-level behavioral analysis by the platform. |
Sources: server/internal/assistants/managed_assistant_instructions.txt:41-45, server/design/risk/design.go:503-516, client/dashboard/src/lib/insights-suggestions.ts:79-85
Enforcement and Mitigation
When a policy detects a risk, the system executes one of five configured actions.
Enforcement Actions
- Flag: Logs the finding for review in the "Watchdog" dashboard without interrupting the user session.
- Warn: Challenges the user with a message, requiring them to acknowledge the risk before proceeding.
- Block: Immediately terminates the prompt or tool call.
- Quarantine: Blocks the action and freezes the entire session for administrator review.
- Require Approval: Intercepts the tool call and holds it until a designated administrator approves the execution.
Sources: server/design/risk/design.go:61-65, client/dashboard/src/pages/security/PolicyStart.tsx:38-43, examples/functions-approve/src/functions.ts:13-18
Risk Exclusions
Exclusions allow administrators to suppress false positives. These can be scoped globally (project-wide) or bound to a specific policy.
- Match Types: Support for exact values, regex patterns, rule IDs, and source families.
- Built-in Exclusions: A library of known-safe values (e.g., test credit cards) that are suppressed automatically.
Sources: server/design/risk/design.go:648-662, server/design/risk/design.go:127-140
Approval Workflows
The require_approval action initiates a specific workflow for high-risk tool calls. This is often implemented as a proxy/interceptor pattern.
The sequence shows the interception of a protected tool call requiring external validation.
Sources: examples/functions-approve/src/functions.ts:133-145, examples/functions-approve/readme.md:104-125
Approval Configuration
Administrators must define approval_config when using the require_approval action. This specifies which principals (users or roles) are authorized to approve the held calls. A decision can be an approve or deny, and an approver cannot be the same person who initiated the call.
Sources: server/design/risk/design.go:88-89, server/design/risk/design.go:768-774
Policy Management API
The system provides a robust API for programmatic policy administration.
Key Endpoints
| Method | Endpoint | Description |
|---|---|---|
POST | /rpc/risk.createPolicy | Creates a standard or prompt-based policy. |
GET | /rpc/risk.listResults | Fetches scan findings with optional filters for chat_id, user_id, or category. |
POST | /rpc/risk.suggestPolicy | Maps a natural-language description to a policy draft using LLM analysis. |
POST | /rpc/risk.unmaskResult | Reveals plaintext of a redacted finding (audited action). |
GET | /rpc/risk.getSignals | Returns clustered risk signals ranked by severity. |
Sources: server/design/risk/design.go:17-106, server/design/risk/design.go:210-250, server/design/risk/design.go:534-550
Summary
The AI Threat Detection & Risk Policy module provides an integrated security layer for AI-driven environments. By combining deterministic regex/PII scanning with flexible LLM-based guardrails and human-in-the-loop approval workflows, the system enables secure scaling of AI usage. Administrators can define granular policies, manage exceptions via exclusions, and monitor the overall security posture through real-time risk signals and a centralized Watchdog dashboard.
Sources: README.md, server/design/risk/design.go:10-15