diff --git a/crates/goose/src/security/mod.rs b/crates/goose/src/security/mod.rs index 773233dd0..43e5f6e3b 100644 --- a/crates/goose/src/security/mod.rs +++ b/crates/goose/src/security/mod.rs @@ -156,44 +156,33 @@ impl SecurityManager { let sanitized_explanation = analysis_result.explanation.replace('\n', " | "); if analysis_result.is_malicious { - let above_threshold = analysis_result.confidence > config_threshold; let finding_id = format!("SEC-{}", Uuid::new_v4().simple()); let tool_call_json = serde_json::to_string(&tool_call).unwrap_or_else(|_| "{}".to_string()); - let action = if above_threshold { "BLOCK" } else { "LOG" }; - tracing::warn!( monotonic_counter.goose.prompt_injection_finding = 1, security.event_type = "prompt_injection_scan", - security.action = action, + security.action = "BLOCK", security.confidence = analysis_result.confidence, security.threshold = config_threshold, - security.above_threshold = above_threshold, security.threat_type = "command_injection", security.finding_id = %finding_id, security.explanation = %sanitized_explanation, tool.name = %tool_call.name, tool.request_id = %tool_request.id, tool.call_json = %tool_call_json, - "{}", - if above_threshold { - "prompt injection scan: finding above threshold" - } else { - "prompt injection scan: finding below threshold" - } + "prompt injection scan: finding above threshold" ); - if above_threshold { - results.push(SecurityResult { - is_malicious: analysis_result.is_malicious, - confidence: analysis_result.confidence, - explanation: analysis_result.explanation, - should_ask_user: true, // Always ask user for threats above threshold - finding_id, - tool_request_id: tool_request.id.clone(), - }); - } + results.push(SecurityResult { + is_malicious: analysis_result.is_malicious, + confidence: analysis_result.confidence, + explanation: analysis_result.explanation, + should_ask_user: true, + finding_id, + tool_request_id: tool_request.id.clone(), + }); } else if analysis_result.scanned { let tool_call_json = serde_json::to_string(&tool_call).unwrap_or_else(|_| "{}".to_string()); diff --git a/documentation/docs/guides/config-files.md b/documentation/docs/guides/config-files.md index 6a845f26a..1236bd0e6 100644 --- a/documentation/docs/guides/config-files.md +++ b/documentation/docs/guides/config-files.md @@ -66,7 +66,7 @@ The following settings can be configured at the root level of your config.yaml f | `GOOSE_AUTO_COMPACT_THRESHOLD` | Set the percentage threshold at which goose [automatically compacts your session](/docs/guides/sessions/smart-context-management#automatic-compaction). | Float between 0.0 and 1.0 (disabled at 0.0)| 0.8 | No | | `GOOSE_AUTO_COMPACT_TOKEN_LIMIT` | Absolute auto-compaction trigger; the earlier of this and the percentage threshold applies while auto-compaction is enabled. Controls when compaction starts, not a guaranteed maximum request size. | Positive integer | 225000 | No | | `SECURITY_PROMPT_ENABLED` | Enable [prompt injection detection](/docs/guides/security/prompt-injection-detection) to identify potentially harmful commands | true/false | false | No | -| `SECURITY_PROMPT_THRESHOLD` | Sensitivity threshold for prompt injection detection (higher = stricter) | Float between 0.01 and 1.0 | 0.8 | No | +| `SECURITY_PROMPT_THRESHOLD` | Sensitivity threshold for prompt injection detection (lower = stricter) | Float between 0.01 and 1.0 | 0.8 | No | | `SECURITY_PROMPT_CLASSIFIER_ENABLED` | Enable ML-based prompt injection detection for advanced threat identification | true/false | false | No | | `SECURITY_PROMPT_CLASSIFIER_ENDPOINT` | Classification endpoint URL for ML-based prompt injection detection | URL (e.g., "https://api.example.com/classify") | None | No | | `SECURITY_PROMPT_CLASSIFIER_TOKEN` | Authentication token for `SECURITY_PROMPT_CLASSIFIER_ENDPOINT` | String | None | No | diff --git a/documentation/docs/guides/environment-variables.md b/documentation/docs/guides/environment-variables.md index 1f4fbb78d..27f0bed7e 100644 --- a/documentation/docs/guides/environment-variables.md +++ b/documentation/docs/guides/environment-variables.md @@ -312,7 +312,7 @@ These variables control security features, credential storage, and anonymous usa | `GOOSE_ALLOWLIST` | Controls which extensions can be loaded | URL for [allowed extensions](/docs/guides/allowlist) list | Unset | | `GOOSE_DISABLE_KEYRING` | Disables the system keyring for secret storage | Set to any value (e.g., "1", "true", "yes") to disable. The actual value doesn't matter, only whether the variable is set. | Unset (keyring enabled) | | `SECURITY_PROMPT_ENABLED` | Enable [prompt injection detection](/docs/guides/security/prompt-injection-detection) to identify potentially harmful commands | true/false | false | -| `SECURITY_PROMPT_THRESHOLD` | Sensitivity threshold for prompt injection detection (higher = stricter) | Float between 0.01 and 1.0 | 0.8 | +| `SECURITY_PROMPT_THRESHOLD` | Sensitivity threshold for prompt injection detection (lower = stricter) | Float between 0.01 and 1.0 | 0.8 | | `SECURITY_PROMPT_CLASSIFIER_ENABLED` | Enable ML-based prompt injection detection for advanced threat identification | true/false | false | | `SECURITY_PROMPT_CLASSIFIER_ENDPOINT` | Classification endpoint URL for ML-based prompt injection detection | URL (e.g., "https://api.example.com/classify") | Unset | | `SECURITY_PROMPT_CLASSIFIER_TOKEN` | Authentication token for `SECURITY_PROMPT_CLASSIFIER_ENDPOINT` | String | Unset | @@ -324,7 +324,7 @@ These variables control security features, credential storage, and anonymous usa # Enable prompt injection detection with default threshold export SECURITY_PROMPT_ENABLED=true -# Enable with custom threshold (stricter) +# Enable with custom threshold (more lenient than default) export SECURITY_PROMPT_ENABLED=true export SECURITY_PROMPT_THRESHOLD=0.9 diff --git a/documentation/docs/guides/security/prompt-injection-detection.md b/documentation/docs/guides/security/prompt-injection-detection.md index 041296c19..781b29e27 100644 --- a/documentation/docs/guides/security/prompt-injection-detection.md +++ b/documentation/docs/guides/security/prompt-injection-detection.md @@ -96,18 +96,18 @@ Beyond prompt injection detection, goose automatically: ### Configuring Detection Threshold -The threshold (0.01-1.0) controls how strict detection is: +The threshold (0.01-1.0) controls how strict detection is. A tool call is flagged when its confidence score is at or above the threshold, so **lower values are more sensitive** and flag more aggressively: | Threshold | Sensitivity | Use When | |-----------|------------|----------| -| **0.01-0.50** | Very lenient | You're experienced and understand the risks | -| **0.50-0.70** | Balanced | General development work (good default) | -| **0.70-0.90** | Strict | Working with sensitive data or systems | -| **0.90-1.00** | Maximum | High-security environments | +| **0.01-0.30** | Maximum | High-security environments | +| **0.30-0.60** | Strict | Working with sensitive data or systems | +| **0.60-0.80** | Balanced | General development work (good default) | +| **0.80-1.00** | Very lenient | You're experienced and understand the risks | When the injection prompt detection feature is enabled, the default threshold is 0.8 (recommended for most users). -Lower thresholds mean fewer alerts but might miss threats. Higher thresholds catch more potential issues but may flag legitimate operations. You can control this sensitivity/convenience tradeoff based on your needs. +Lower thresholds catch more potential issues but may flag legitimate operations. Higher thresholds mean fewer alerts but might miss threats. You can control this sensitivity/convenience tradeoff based on your needs. ## Enhanced Detection with Machine Learning diff --git a/ui/desktop/src/components/settings/security/SecurityToggle.tsx b/ui/desktop/src/components/settings/security/SecurityToggle.tsx index 24ea1f62d..793299cad 100644 --- a/ui/desktop/src/components/settings/security/SecurityToggle.tsx +++ b/ui/desktop/src/components/settings/security/SecurityToggle.tsx @@ -19,7 +19,7 @@ const i18n = defineMessages({ }, thresholdDescription: { id: 'securityToggle.thresholdDescription', - defaultMessage: 'Higher values are more strict (0.01 = very lenient, 1.0 = maximum strict)', + defaultMessage: 'Lower values are more strict (0.01 = maximum strict, 1.0 = very lenient)', }, enableCommandInjection: { id: 'securityToggle.enableCommandInjection', diff --git a/ui/desktop/src/i18n/messages/de.json b/ui/desktop/src/i18n/messages/de.json index ec7aa8fc5..a5e750dea 100644 --- a/ui/desktop/src/i18n/messages/de.json +++ b/ui/desktop/src/i18n/messages/de.json @@ -3705,7 +3705,7 @@ "defaultMessage": "ML-Modelle verwenden, um potenzielle Prompt-Injektionen in Ihrem Chat zu erkennen" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Höhere Werte sind strenger (0,01 = sehr nachsichtig, 1,0 = maximal streng)" + "defaultMessage": "Niedrigere Werte sind strenger (0,01 = maximal streng, 1,0 = sehr nachsichtig)" }, "securityToggle.warpNotice": { "defaultMessage": "Die Erkennung von Befehlsinjektionen funktioniert am besten, wenn eine Verbindung zu WARP besteht (erforderlich, um den Klassifizierungsdienst zu erreichen)." diff --git a/ui/desktop/src/i18n/messages/en.json b/ui/desktop/src/i18n/messages/en.json index 245dd7933..73f9ec3cb 100644 --- a/ui/desktop/src/i18n/messages/en.json +++ b/ui/desktop/src/i18n/messages/en.json @@ -3810,7 +3810,7 @@ "defaultMessage": "Use ML models to detect potential prompt injection in your chat" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Higher values are more strict (0.01 = very lenient, 1.0 = maximum strict)" + "defaultMessage": "Lower values are more strict (0.01 = maximum strict, 1.0 = very lenient)" }, "securityToggle.warpNotice": { "defaultMessage": "Command injection detection works best when connected to WARP (required to reach the classification service)." diff --git a/ui/desktop/src/i18n/messages/es.json b/ui/desktop/src/i18n/messages/es.json index f50b7e6b7..ed393f9cc 100644 --- a/ui/desktop/src/i18n/messages/es.json +++ b/ui/desktop/src/i18n/messages/es.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Usa modelos de ML para detectar posibles inyecciones de prompt en tu chat" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Los valores más altos son más estrictos (0.01 = muy permisivo, 1.0 = máximo estricto)" + "defaultMessage": "Los valores más bajos son más estrictos (0.01 = máximo estricto, 1.0 = muy permisivo)" }, "securityToggle.warpNotice": { "defaultMessage": "La detección de inyección de comandos funciona mejor cuando estás conectado a WARP (necesario para llegar al servicio de clasificación)." diff --git a/ui/desktop/src/i18n/messages/fr.json b/ui/desktop/src/i18n/messages/fr.json index d712bfae2..43b6dc29a 100644 --- a/ui/desktop/src/i18n/messages/fr.json +++ b/ui/desktop/src/i18n/messages/fr.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Utiliser des modèles ML pour détecter une injection de prompt potentielle dans votre conversation" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Des valeurs plus élevées sont plus strictes (0,01 = très indulgent, 1,0 = strict maximum)" + "defaultMessage": "Des valeurs plus basses sont plus strictes (0,01 = strict maximum, 1,0 = très indulgent)" }, "securityToggle.warpNotice": { "defaultMessage": "La détection d'injection de commandes fonctionne mieux lorsqu'elle est connectée à WARP (requis pour atteindre le service de classification)." diff --git a/ui/desktop/src/i18n/messages/hi.json b/ui/desktop/src/i18n/messages/hi.json index e44897711..fd8abe5e6 100644 --- a/ui/desktop/src/i18n/messages/hi.json +++ b/ui/desktop/src/i18n/messages/hi.json @@ -3705,7 +3705,7 @@ "defaultMessage": "अपनी चैट में संभावित शीघ्र इंजेक्शन का पता लगाने के लिए एमएल मॉडल का उपयोग करें" }, "securityToggle.thresholdDescription": { - "defaultMessage": "उच्च मान अधिक सख्त होते हैं (0.01 = बहुत उदार, 1.0 = अधिकतम सख्त)" + "defaultMessage": "निम्न मान अधिक सख्त होते हैं (0.01 = अधिकतम सख्त, 1.0 = बहुत उदार)" }, "securityToggle.warpNotice": { "defaultMessage": "WARP से कनेक्ट होने पर कमांड इंजेक्शन डिटेक्शन सबसे अच्छा काम करता है (वर्गीकरण सेवा तक पहुंचने के लिए आवश्यक)।" diff --git a/ui/desktop/src/i18n/messages/id.json b/ui/desktop/src/i18n/messages/id.json index 8b292cdbf..1b8292887 100644 --- a/ui/desktop/src/i18n/messages/id.json +++ b/ui/desktop/src/i18n/messages/id.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Gunakan model ML untuk mendeteksi potensi injeksi prompt dalam obrolan Anda" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Nilai yang lebih tinggi lebih ketat (0,01 = sangat longgar, 1,0 = paling ketat)" + "defaultMessage": "Nilai yang lebih rendah lebih ketat (0,01 = paling ketat, 1,0 = sangat longgar)" }, "securityToggle.warpNotice": { "defaultMessage": "Deteksi injeksi perintah bekerja paling baik saat terhubung ke WARP (diperlukan untuk menjangkau layanan klasifikasi)." diff --git a/ui/desktop/src/i18n/messages/it.json b/ui/desktop/src/i18n/messages/it.json index 3c71fd850..636f8b45f 100644 --- a/ui/desktop/src/i18n/messages/it.json +++ b/ui/desktop/src/i18n/messages/it.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Usa modelli ML per rilevare potenziali iniezioni di prompt nella tua chat" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Valori più alti sono più rigidi (0,01 = molto permissivo, 1,0 = massimo rigore)" + "defaultMessage": "Valori più bassi sono più rigidi (0,01 = massimo rigore, 1,0 = molto permissivo)" }, "securityToggle.warpNotice": { "defaultMessage": "Il rilevamento dell'iniezione di comandi funziona al meglio quando si è connessi a WARP (necessario per raggiungere il servizio di classificazione)." diff --git a/ui/desktop/src/i18n/messages/ja.json b/ui/desktop/src/i18n/messages/ja.json index 6ff4d0dd1..ba09125f2 100644 --- a/ui/desktop/src/i18n/messages/ja.json +++ b/ui/desktop/src/i18n/messages/ja.json @@ -3705,7 +3705,7 @@ "defaultMessage": "MLモデルを使用してチャット内の潜在的なプロンプトインジェクションを検出します" }, "securityToggle.thresholdDescription": { - "defaultMessage": "値が高いほど厳格です(0.01 = 非常に緩い、1.0 = 最大限に厳格)" + "defaultMessage": "値が低いほど厳格です(0.01 = 最大限に厳格、1.0 = 非常に緩い)" }, "securityToggle.warpNotice": { "defaultMessage": "コマンドインジェクション検出は、WARPに接続していると最も効果的です(分類サービスに到達するために必要です)。" diff --git a/ui/desktop/src/i18n/messages/ko.json b/ui/desktop/src/i18n/messages/ko.json index 0c8922dc4..e33d861fb 100644 --- a/ui/desktop/src/i18n/messages/ko.json +++ b/ui/desktop/src/i18n/messages/ko.json @@ -3705,7 +3705,7 @@ "defaultMessage": "ML 모델을 사용하여 채팅에서 잠재적인 프롬프트 인젝션을 감지합니다." }, "securityToggle.thresholdDescription": { - "defaultMessage": "값이 높을수록 더 엄격합니다(0.01 = 매우 관대함, 1.0 = 가장 엄격)." + "defaultMessage": "값이 낮을수록 더 엄격합니다(0.01 = 가장 엄격, 1.0 = 매우 관대함)." }, "securityToggle.warpNotice": { "defaultMessage": "명령 인젝션 감지는 WARP에 연결했을 때 가장 잘 작동합니다. 분류 서비스에 연결하려면 WARP가 필요합니다." diff --git a/ui/desktop/src/i18n/messages/ms.json b/ui/desktop/src/i18n/messages/ms.json index cbdddba79..14b437621 100644 --- a/ui/desktop/src/i18n/messages/ms.json +++ b/ui/desktop/src/i18n/messages/ms.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Gunakan model ML untuk mengesan potensi suntikan gesaan dalam sembang anda" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Nilai yang lebih tinggi adalah lebih ketat (0.01 = sangat longgar, 1.0 = paling ketat)" + "defaultMessage": "Nilai yang lebih rendah adalah lebih ketat (0.01 = paling ketat, 1.0 = sangat longgar)" }, "securityToggle.warpNotice": { "defaultMessage": "Pengesanan suntikan arahan berfungsi paling baik apabila disambungkan ke WARP (diperlukan untuk mencapai perkhidmatan pengelasan)." diff --git a/ui/desktop/src/i18n/messages/pt.json b/ui/desktop/src/i18n/messages/pt.json index 266be24ac..fd6aa00bb 100644 --- a/ui/desktop/src/i18n/messages/pt.json +++ b/ui/desktop/src/i18n/messages/pt.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Usar modelos de ML para detetar potenciais injeções de prompts na sua conversa" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Valores mais altos são mais rigorosos (0,01 = muito tolerante, 1,0 = rigor máximo)" + "defaultMessage": "Valores mais baixos são mais rigorosos (0,01 = rigor máximo, 1,0 = muito tolerante)" }, "securityToggle.warpNotice": { "defaultMessage": "A deteção de injeção de comandos funciona melhor quando ligada ao WARP (necessário para aceder ao serviço de classificação)." diff --git a/ui/desktop/src/i18n/messages/ru.json b/ui/desktop/src/i18n/messages/ru.json index 827c55e60..659022ec1 100644 --- a/ui/desktop/src/i18n/messages/ru.json +++ b/ui/desktop/src/i18n/messages/ru.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Использовать ML-модели для обнаружения потенциального prompt injection в чате" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Чем выше значение, тем строже проверка (0.01 = очень мягко, 1.0 = максимально строго)" + "defaultMessage": "Чем ниже значение, тем строже проверка (0.01 = максимально строго, 1.0 = очень мягко)" }, "securityToggle.warpNotice": { "defaultMessage": "Обнаружение внедрения команд работает лучше всего при подключении к WARP (требуется для доступа к сервису классификации)." diff --git a/ui/desktop/src/i18n/messages/tr.json b/ui/desktop/src/i18n/messages/tr.json index 248a99318..bd540ce2f 100644 --- a/ui/desktop/src/i18n/messages/tr.json +++ b/ui/desktop/src/i18n/messages/tr.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Sohbetinize olası istem eklemeyi tespit etmek için makine öğrenimi modellerini kullanın" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Daha yüksek değerler daha katıdır (0,01 = çok yumuşak, 1,0 = maksimum katı)" + "defaultMessage": "Daha düşük değerler daha katıdır (0,01 = maksimum katı, 1,0 = çok yumuşak)" }, "securityToggle.warpNotice": { "defaultMessage": "Komut enjeksiyonu algılama, WARP bağlantısı olduğunda en iyi şekilde çalışır (sınıflandırma hizmetine erişmek için gereklidir)." diff --git a/ui/desktop/src/i18n/messages/vi.json b/ui/desktop/src/i18n/messages/vi.json index e614a09ee..5ca949d13 100644 --- a/ui/desktop/src/i18n/messages/vi.json +++ b/ui/desktop/src/i18n/messages/vi.json @@ -3705,7 +3705,7 @@ "defaultMessage": "Sử dụng các mô hình ML để phát hiện việc chèn lời nhắc tiềm ẩn trong cuộc trò chuyện của bạn" }, "securityToggle.thresholdDescription": { - "defaultMessage": "Giá trị cao hơn thì nghiêm ngặt hơn (0.01 = rất khoan dung, 1.0 = nghiêm ngặt tối đa)" + "defaultMessage": "Giá trị thấp hơn thì nghiêm ngặt hơn (0.01 = nghiêm ngặt tối đa, 1.0 = rất khoan dung)" }, "securityToggle.warpNotice": { "defaultMessage": "Phát hiện chèn lệnh hoạt động tốt nhất khi được kết nối với WARP (bắt buộc để truy cập dịch vụ phân loại)." diff --git a/ui/desktop/src/i18n/messages/zh-CN.json b/ui/desktop/src/i18n/messages/zh-CN.json index b98b47ed0..4276b31c6 100644 --- a/ui/desktop/src/i18n/messages/zh-CN.json +++ b/ui/desktop/src/i18n/messages/zh-CN.json @@ -3705,7 +3705,7 @@ "defaultMessage": "使用机器学习模型检测聊天中潜在的提示注入" }, "securityToggle.thresholdDescription": { - "defaultMessage": "值越高越严格(0.01 = 非常宽松,1.0 = 最严格)" + "defaultMessage": "值越低越严格(0.01 = 最严格,1.0 = 非常宽松)" }, "securityToggle.warpNotice": { "defaultMessage": "连接到 WARP 时,命令注入检测效果最佳(访问分类服务需要 WARP)。" diff --git a/ui/desktop/src/i18n/messages/zh-TW.json b/ui/desktop/src/i18n/messages/zh-TW.json index f05111c79..f3707e804 100644 --- a/ui/desktop/src/i18n/messages/zh-TW.json +++ b/ui/desktop/src/i18n/messages/zh-TW.json @@ -3705,7 +3705,7 @@ "defaultMessage": "使用 ML 模型偵測您聊天中潛在的提示注入" }, "securityToggle.thresholdDescription": { - "defaultMessage": "數值越高越嚴格(0.01 = 非常寬鬆,1.0 = 最嚴格)" + "defaultMessage": "數值越低越嚴格(0.01 = 最嚴格,1.0 = 非常寬鬆)" }, "securityToggle.warpNotice": { "defaultMessage": "連線至 WARP 時,指令注入偵測的效果最佳(為了連接分類服務所必需)。"