OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials


Description

Detects ChatGPT Enterprise Codex prompt or response text that matches known credential patterns. Secrets pasted into Codex sessions can be retained in compliance logs and may be reused by agent tool calls.

Query · esql

from logs-openai_chatgpt_enterprise.codex_log-* metadata _id, _version, _index
| eval Esql.prompt_text = coalesce(openai_chatgpt_enterprise.codex_log.event_details.prompt_text, "")
| eval Esql.response_text = coalesce(openai_chatgpt_enterprise.codex_log.event_details.response_text, "")
| where
    data_stream.dataset == "openai_chatgpt_enterprise.codex_log" and
    event.action == "prompt_response_received" and
    (
        (
        Esql.prompt_text is not null and
        Esql.prompt_text != "" and
        not Esql.prompt_text like "*AKIAIOSFODNN7EXAMPLE*" and
        not Esql.prompt_text like "*ASIAIOSFODNN7EXAMPLE*" and
        not Esql.prompt_text like "*ghp_example*" and
        not Esql.prompt_text like "*sk-ant-api03-test*" and
        (

        Esql.prompt_text rlike """.*(AKIA|ASIA)[A-Z0-9]{16}.*""" or
        Esql.prompt_text rlike """.*gh[pousr]_[A-Za-z0-9]{36}.*""" or
        Esql.prompt_text rlike """.*github_pat_[A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*-----BEGIN [A-Z ]*PRIVATE KEY-----.*""" or
        Esql.prompt_text rlike """.*xox[baprs]-[0-9]+-[0-9]+-[A-Za-z0-9]+.*""" or
        Esql.prompt_text rlike """.*sk_live_[A-Za-z0-9]+.*""" or
        Esql.prompt_text rlike """.*AIza[-A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*npm_[A-Za-z0-9]{36}.*""" or
        Esql.prompt_text rlike """.*sk-ant-[A-Za-z0-9-]+.*""" or
        Esql.prompt_text rlike """.*sk-[A-Za-z0-9]{20,}.*""" or
        Esql.prompt_text rlike """.*hvs[.][A-Za-z0-9]+.*""" or
        Esql.prompt_text rlike """.*dckr_pat_[-A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*SG[.][-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*(AccountKey=|SharedAccessKey=)[-A-Za-z0-9+/=]+.*""" or
        Esql.prompt_text rlike """.*eyJ[-A-Za-z0-9_]+[.]eyJ[-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*"""
        )
    )
        or
        (
        Esql.response_text is not null and
        Esql.response_text != "" and
        not Esql.response_text like "*AKIAIOSFODNN7EXAMPLE*" and
        not Esql.response_text like "*ASIAIOSFODNN7EXAMPLE*" and
        not Esql.response_text like "*ghp_example*" and
        not Esql.response_text like "*sk-ant-api03-test*" and
        (

        Esql.response_text rlike """.*(AKIA|ASIA)[A-Z0-9]{16}.*""" or
        Esql.response_text rlike """.*gh[pousr]_[A-Za-z0-9]{36}.*""" or
        Esql.response_text rlike """.*github_pat_[A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*-----BEGIN [A-Z ]*PRIVATE KEY-----.*""" or
        Esql.response_text rlike """.*xox[baprs]-[0-9]+-[0-9]+-[A-Za-z0-9]+.*""" or
        Esql.response_text rlike """.*sk_live_[A-Za-z0-9]+.*""" or
        Esql.response_text rlike """.*AIza[-A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*npm_[A-Za-z0-9]{36}.*""" or
        Esql.response_text rlike """.*sk-ant-[A-Za-z0-9-]+.*""" or
        Esql.response_text rlike """.*sk-[A-Za-z0-9]{20,}.*""" or
        Esql.response_text rlike """.*hvs[.][A-Za-z0-9]+.*""" or
        Esql.response_text rlike """.*dckr_pat_[-A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*SG[.][-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*(AccountKey=|SharedAccessKey=)[-A-Za-z0-9+/=]+.*""" or
        Esql.response_text rlike """.*eyJ[-A-Za-z0-9_]+[.]eyJ[-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*"""
        )
    )
    )
| keep
    _id, _version, _index, @timestamp, event.action, user.id, user.email,
    openai_chatgpt_enterprise.codex_log.client_id,
    openai_chatgpt_enterprise.codex_log.event_details.session_id,
    openai_chatgpt_enterprise.codex_log.event_details.prompt_text,
    openai_chatgpt_enterprise.codex_log.event_details.response_text,
    gen_ai.request.model, data_stream.*

Investigation fields

Pivot points the source recommends for triage.

  • @timestamp
  • user.id
  • user.email
  • openai_chatgpt_enterprise.codex_log.event_details.session_id
  • openai_chatgpt_enterprise.codex_log.event_details.prompt_text
  • openai_chatgpt_enterprise.codex_log.client_id

Implementation guide

This rule requires the OpenAI ChatGPT Enterprise integration to collect compliance logs into Elasticsearch.

https://www.elastic.co/docs/reference/integrations/openai_chatgpt_enterprise

Known false positives

  • Developers may paste example keys while debugging or documenting integrations.

Analyst notes

Investigating OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials

A Codex prompt or response matched a known credential pattern. Secrets pasted into Codex can be retained in compliance logs and may be reused by later tool calls in the same session.

Escalate when the value appears live, when tool or MCP activity follows the prompt, or when the same user repeats credential-like content. Close as a false positive for clearly synthetic or documentation examples.

Possible investigation steps

  • Read the prompt and response text on the alert and decide whether the match is a live secret, an example key, or incidental text.
  • Identify the user, Codex client, and session identifiers on the alert.
  • Check for nearby Codex tool calls, MCP activity, or access-token creation in the same session.
  • If the assistant response echoes the secret, treat that as additional exposure.

False positive analysis

  • Developers sometimes paste example keys while debugging or documenting integrations. Confirm the value is live before rotating it.

Response and remediation

  • If the credential is live, rotate or revoke it and review use of that credential after the prompt time.
  • Review Codex tool activity in the same session and remove residual copies from shared artifacts where possible.
  • Restrict who can read compliance logs that retain prompt text, because the alert may contain secret material.
Raw source OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials · Elastic TOML
Esc
Published by elastic/detection-rules ↗, licensed under Elastic License 2.0 ↗. Reproduced here unmodified.
[metadata]
creation_date = "2026/10/06"
integration = ["openai_chatgpt_enterprise"]
maturity = "production"
updated_date = "2026/10/16"

[rule]
author = ["Elastic"]
description = """
Detects ChatGPT Enterprise Codex prompt or response text that matches known credential patterns. Secrets pasted into
Codex sessions can be retained in compliance logs and may be reused by agent tool calls.
"""
false_positives = ["Developers may paste example keys while debugging or documenting integrations."]
from = "now-9m"
language = "esql"
license = "Elastic License v2"
name = "OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials"
note = """## Triage and analysis

### Investigating OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials

A Codex prompt or response matched a known credential pattern. Secrets pasted into Codex can be retained in compliance logs and may be reused by later tool calls in the same session.

Escalate when the value appears live, when tool or MCP activity follows the prompt, or when the same user repeats credential-like content. Close as a false positive for clearly synthetic or documentation examples.

#### Possible investigation steps

- Read the prompt and response text on the alert and decide whether the match is a live secret, an example key, or incidental text.
- Identify the user, Codex client, and session identifiers on the alert.
- Check for nearby Codex tool calls, MCP activity, or access-token creation in the same session.
- If the assistant response echoes the secret, treat that as additional exposure.

### False positive analysis

- Developers sometimes paste example keys while debugging or documenting integrations. Confirm the value is live before rotating it.

### Response and remediation

- If the credential is live, rotate or revoke it and review use of that credential after the prompt time.
- Review Codex tool activity in the same session and remove residual copies from shared artifacts where possible.
- Restrict who can read compliance logs that retain prompt text, because the alert may contain secret material.
"""
references = [
    "https://www.elastic.co/docs/reference/integrations/openai_chatgpt_enterprise",
    "https://platform.openai.com/docs/compliance",
]
risk_score = 73
rule_id = "de41effc-9966-4cae-a5bb-2773bf7f641f"
setup = """## Setup

This rule requires the OpenAI ChatGPT Enterprise integration to collect compliance logs into Elasticsearch.

https://www.elastic.co/docs/reference/integrations/openai_chatgpt_enterprise
"""
severity = "high"
tags = [
    "Domain: GenAI",
    "Platform: OpenAI",
    "Data Source: OpenAI ChatGPT Enterprise",
    "Service: OpenAI ChatGPT Enterprise",
    "Use Case: Threat Detection",
    "Resources: Investigation Guide",
    "Rule Type: ES|QL",
    "Tactic: Credential Access",
    "Mitre Atlas: AML.T0055",
]
timestamp_override = "event.ingested"
type = "esql"

query = '''
from logs-openai_chatgpt_enterprise.codex_log-* metadata _id, _version, _index
| eval Esql.prompt_text = coalesce(openai_chatgpt_enterprise.codex_log.event_details.prompt_text, "")
| eval Esql.response_text = coalesce(openai_chatgpt_enterprise.codex_log.event_details.response_text, "")
| where
    data_stream.dataset == "openai_chatgpt_enterprise.codex_log" and
    event.action == "prompt_response_received" and
    (
        (
        Esql.prompt_text is not null and
        Esql.prompt_text != "" and
        not Esql.prompt_text like "*AKIAIOSFODNN7EXAMPLE*" and
        not Esql.prompt_text like "*ASIAIOSFODNN7EXAMPLE*" and
        not Esql.prompt_text like "*ghp_example*" and
        not Esql.prompt_text like "*sk-ant-api03-test*" and
        (

        Esql.prompt_text rlike """.*(AKIA|ASIA)[A-Z0-9]{16}.*""" or
        Esql.prompt_text rlike """.*gh[pousr]_[A-Za-z0-9]{36}.*""" or
        Esql.prompt_text rlike """.*github_pat_[A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*-----BEGIN [A-Z ]*PRIVATE KEY-----.*""" or
        Esql.prompt_text rlike """.*xox[baprs]-[0-9]+-[0-9]+-[A-Za-z0-9]+.*""" or
        Esql.prompt_text rlike """.*sk_live_[A-Za-z0-9]+.*""" or
        Esql.prompt_text rlike """.*AIza[-A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*npm_[A-Za-z0-9]{36}.*""" or
        Esql.prompt_text rlike """.*sk-ant-[A-Za-z0-9-]+.*""" or
        Esql.prompt_text rlike """.*sk-[A-Za-z0-9]{20,}.*""" or
        Esql.prompt_text rlike """.*hvs[.][A-Za-z0-9]+.*""" or
        Esql.prompt_text rlike """.*dckr_pat_[-A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*SG[.][-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*""" or
        Esql.prompt_text rlike """.*(AccountKey=|SharedAccessKey=)[-A-Za-z0-9+/=]+.*""" or
        Esql.prompt_text rlike """.*eyJ[-A-Za-z0-9_]+[.]eyJ[-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*"""
        )
    )
        or
        (
        Esql.response_text is not null and
        Esql.response_text != "" and
        not Esql.response_text like "*AKIAIOSFODNN7EXAMPLE*" and
        not Esql.response_text like "*ASIAIOSFODNN7EXAMPLE*" and
        not Esql.response_text like "*ghp_example*" and
        not Esql.response_text like "*sk-ant-api03-test*" and
        (

        Esql.response_text rlike """.*(AKIA|ASIA)[A-Z0-9]{16}.*""" or
        Esql.response_text rlike """.*gh[pousr]_[A-Za-z0-9]{36}.*""" or
        Esql.response_text rlike """.*github_pat_[A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*-----BEGIN [A-Z ]*PRIVATE KEY-----.*""" or
        Esql.response_text rlike """.*xox[baprs]-[0-9]+-[0-9]+-[A-Za-z0-9]+.*""" or
        Esql.response_text rlike """.*sk_live_[A-Za-z0-9]+.*""" or
        Esql.response_text rlike """.*AIza[-A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*npm_[A-Za-z0-9]{36}.*""" or
        Esql.response_text rlike """.*sk-ant-[A-Za-z0-9-]+.*""" or
        Esql.response_text rlike """.*sk-[A-Za-z0-9]{20,}.*""" or
        Esql.response_text rlike """.*hvs[.][A-Za-z0-9]+.*""" or
        Esql.response_text rlike """.*dckr_pat_[-A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*SG[.][-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*""" or
        Esql.response_text rlike """.*(AccountKey=|SharedAccessKey=)[-A-Za-z0-9+/=]+.*""" or
        Esql.response_text rlike """.*eyJ[-A-Za-z0-9_]+[.]eyJ[-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*"""
        )
    )
    )
| keep
    _id, _version, _index, @timestamp, event.action, user.id, user.email,
    openai_chatgpt_enterprise.codex_log.client_id,
    openai_chatgpt_enterprise.codex_log.event_details.session_id,
    openai_chatgpt_enterprise.codex_log.event_details.prompt_text,
    openai_chatgpt_enterprise.codex_log.event_details.response_text,
    gen_ai.request.model, data_stream.*
'''


[[rule.threat]]
framework = "MITRE ATT&CK"
[[rule.threat.technique]]
id = "T1552"
name = "Unsecured Credentials"
reference = "https://attack.mitre.org/techniques/T1552/"


[rule.threat.tactic]
id = "TA0006"
name = "Credential Access"
reference = "https://attack.mitre.org/tactics/TA0006/"
[[rule.threat_mappings]]
framework = "MITRE ATLAS"
version = "2026.08"
[[rule.threat_mappings.threat]]
framework = "MITRE ATLAS"
[[rule.threat_mappings.threat.technique]]
id = "AML.T0055"
name = "Unsecured Credentials"
reference = "https://atlas.mitre.org/techniques/AML.T0055/"


[rule.threat_mappings.threat.tactic]
id = "AML.TA0013"
name = "Credential Access"
reference = "https://atlas.mitre.org/tactics/AML.TA0013/"

[rule.investigation_fields]
field_names = [
    "@timestamp",
    "user.id",
    "user.email",
    "openai_chatgpt_enterprise.codex_log.event_details.session_id",
    "openai_chatgpt_enterprise.codex_log.event_details.prompt_text",
    "openai_chatgpt_enterprise.codex_log.client_id",
]

Detection rules belong to the projects that publish them and remain under their own licenses. This site indexes and links to them; it claims no rights in them.