GCP Vertex AI Response Blocked by Safety Filters

Detects Vertex AI GenerateContent responses whose candidate finish_reason is SAFETY. That value is emitted when Gemini safety filters stop generation. Unlike textual refusals (finish_reason STOP), SAFETY means the provider blocked or truncated the completion.

Elastic rule (View on GitHub)

  1[metadata]
  2creation_date = "2026/10/02"
  3integration = ["gcp_vertexai"]
  4maturity = "production"
  5min_stack_comments = "gcp_vertexai prompt_response_logs requires integration 1.4.0+ (Kibana ^9.2.0)."
  6min_stack_version = "9.4.0"
  7updated_date = "2026/11/03"
  8
  9[rule]
 10author = ["Elastic"]
 11description = """
 12Detects Vertex AI GenerateContent responses whose candidate finish_reason is SAFETY. That value is emitted when Gemini
 13safety filters stop generation. Unlike textual refusals (finish_reason STOP), SAFETY means the provider blocked or
 14truncated the completion.
 15"""
 16false_positives = [
 17    """
 18    Aggressive safetySettings (for example BLOCK_LOW_AND_ABOVE) on red-team or content-moderation workloads can produce
 19    frequent SAFETY finishes. Exclude those projects or models, or require concurrent HIGH/MEDIUM ratings.
 20    """,
 21]
 22from = "now-60m"
 23interval = "10m"
 24language = "esql"
 25license = "Elastic License v2"
 26name = "GCP Vertex AI Response Blocked by Safety Filters"
 27note = """## Triage and analysis
 28
 29### Investigating GCP Vertex AI Response Blocked by Safety Filters
 30
 31A GenerateContent candidate ended with `finish_reason` SAFETY — Gemini safety filters blocked or
 32truncated the completion. Unlike textual refusals (STOP with "I cannot…"), SAFETY is a provider-side
 33block and often co-occurs with elevated harm-category ratings.
 34
 35#### Possible investigation steps
 36
 37- Read the rejected prompt in
 38  `gcp.vertexai.prompt_response_logs.full_request.contents.parts.text`.
 39- Check `safety_ratings.category`, `probability`, and `severity` on the same document. HIGH or
 40  MEDIUM increases confidence the prompt was harmful rather than a strict-threshold FP.
 41- Note `safety_settings.threshold` / `category` on the request. Nearby `BLOCK_NONE` from the same
 42  project can indicate an attempt to weaken filters after blocks.
 43- Pivot to `logs-gcp_vertexai.auditlogs-*` GenerateContent for `source.ip` and `client.user.email`.
 44- Check for bursts: many SAFETY finishes from one principal often means automated probing.
 45
 46### False positive analysis
 47
 48- Authorized policy-test or content-moderation harnesses that intentionally probe filters,
 49  especially with aggressive thresholds such as BLOCK_LOW_AND_ABOVE. Exclude those projects.
 50
 51### Response and remediation
 52
 53- Confirm the caller is approved for safety testing; otherwise revoke Vertex credentials and review
 54  IAM.
 55- If probing is confirmed, hunt for successful completions (STOP) after threshold changes and for
 56  related jailbreak / BLOCK_NONE alerts.
 57"""
 58references = [
 59    "https://www.elastic.co/docs/reference/integrations/gcp_vertexai",
 60    "https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/configure-safety-filters",
 61]
 62risk_score = 47
 63rule_id = "59ebf5b6-942a-441e-9d18-9ba71d134c63"
 64setup = """## Setup
 65
 66Requires GCP Vertex AI prompt_response_logs with full_response.candidates.finish_reason from BigQuery
 67request/response logging.
 68"""
 69severity = "medium"
 70tags = [
 71    "Domain: GenAI",
 72    "Domain: Cloud",
 73    "Data Source: GCP Vertex AI",
 74    "Data Source: GCP",
 75    "Data Source: Google Cloud Platform",
 76    "Platform: GCP",
 77    "Service: GCP Vertex AI",
 78    "Use Case: Policy Violation",
 79    "Use Case: Threat Detection",
 80    "Tactic: Defense Evasion",
 81    "Threat: Unauthorized AI Usage",
 82    "Resources: Investigation Guide",
 83    "Rule Type: ES|QL",
 84]
 85timestamp_override = "event.ingested"
 86type = "esql"
 87
 88query = '''
 89from logs-gcp_vertexai.prompt_response_logs-* metadata _id, _version, _index
 90| where
 91    data_stream.dataset == "gcp_vertexai.prompt_response_logs" and
 92    MV_CONTAINS(gcp.vertexai.prompt_response_logs.full_response.candidates.finish_reason, "SAFETY")
 93| keep
 94    _id,
 95    _version,
 96    _index,
 97    @timestamp,
 98    cloud.project.id,
 99    gcp.vertexai.prompt_response_logs.model,
100    gcp.vertexai.prompt_response_logs.api_method,
101    gcp.vertexai.prompt_response_logs.full_request.contents.parts.text,
102    gcp.vertexai.prompt_response_logs.full_request.safety_settings.category,
103    gcp.vertexai.prompt_response_logs.full_request.safety_settings.threshold,
104    gcp.vertexai.prompt_response_logs.full_response.candidates.finish_reason,
105    gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.category,
106    gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.probability,
107    gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.severity
108'''
109
110[[rule.threat_mappings]]
111framework = "MITRE ATLAS"
112version = "2026.08"
113[[rule.threat_mappings.threat]]
114framework = "MITRE ATLAS"
115
116[rule.threat_mappings.threat.tactic]
117id = "AML.TA0007"
118name = "Defense Evasion"
119reference = "https://atlas.mitre.org/tactics/AML.TA0007/"
120
121[rule.investigation_fields]
122field_names = [
123    "cloud.project.id",
124    "gcp.vertexai.prompt_response_logs.model",
125    "gcp.vertexai.prompt_response_logs.api_method",
126    "gcp.vertexai.prompt_response_logs.full_request.contents.parts.text",
127    "gcp.vertexai.prompt_response_logs.full_request.safety_settings.category",
128    "gcp.vertexai.prompt_response_logs.full_request.safety_settings.threshold",
129    "gcp.vertexai.prompt_response_logs.full_response.candidates.finish_reason",
130    "gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.category",
131    "gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.probability",
132    "gcp.vertexai.prompt_response_logs.full_response.candidates.safety_ratings.severity",
133]

Triage and analysis

Investigating GCP Vertex AI Response Blocked by Safety Filters

A GenerateContent candidate ended with finish_reason SAFETY — Gemini safety filters blocked or truncated the completion. Unlike textual refusals (STOP with "I cannot…"), SAFETY is a provider-side block and often co-occurs with elevated harm-category ratings.

Possible investigation steps

  • Read the rejected prompt in gcp.vertexai.prompt_response_logs.full_request.contents.parts.text.
  • Check safety_ratings.category, probability, and severity on the same document. HIGH or MEDIUM increases confidence the prompt was harmful rather than a strict-threshold FP.
  • Note safety_settings.threshold / category on the request. Nearby BLOCK_NONE from the same project can indicate an attempt to weaken filters after blocks.
  • Pivot to logs-gcp_vertexai.auditlogs-* GenerateContent for source.ip and client.user.email.
  • Check for bursts: many SAFETY finishes from one principal often means automated probing.

False positive analysis

  • Authorized policy-test or content-moderation harnesses that intentionally probe filters, especially with aggressive thresholds such as BLOCK_LOW_AND_ABOVE. Exclude those projects.

Response and remediation

  • Confirm the caller is approved for safety testing; otherwise revoke Vertex credentials and review IAM.
  • If probing is confirmed, hunt for successful completions (STOP) after threshold changes and for related jailbreak / BLOCK_NONE alerts.

References

Related rules

to-top