OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials
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.
Elastic rule (View on GitHub)
1[metadata]
2creation_date = "2026/10/06"
3integration = ["openai_chatgpt_enterprise"]
4maturity = "production"
5updated_date = "2026/10/16"
6
7[rule]
8author = ["Elastic"]
9description = """
10Detects ChatGPT Enterprise Codex prompt or response text that matches known credential patterns. Secrets pasted into
11Codex sessions can be retained in compliance logs and may be reused by agent tool calls.
12"""
13false_positives = ["Developers may paste example keys while debugging or documenting integrations."]
14from = "now-9m"
15language = "esql"
16license = "Elastic License v2"
17name = "OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials"
18note = """## Triage and analysis
19
20### Investigating OpenAI ChatGPT Enterprise Codex Prompt Containing Credentials
21
22A 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.
23
24Escalate 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.
25
26#### Possible investigation steps
27
28- Read the prompt and response text on the alert and decide whether the match is a live secret, an example key, or incidental text.
29- Identify the user, Codex client, and session identifiers on the alert.
30- Check for nearby Codex tool calls, MCP activity, or access-token creation in the same session.
31- If the assistant response echoes the secret, treat that as additional exposure.
32
33### False positive analysis
34
35- Developers sometimes paste example keys while debugging or documenting integrations. Confirm the value is live before rotating it.
36
37### Response and remediation
38
39- If the credential is live, rotate or revoke it and review use of that credential after the prompt time.
40- Review Codex tool activity in the same session and remove residual copies from shared artifacts where possible.
41- Restrict who can read compliance logs that retain prompt text, because the alert may contain secret material.
42"""
43references = [
44 "https://www.elastic.co/docs/reference/integrations/openai_chatgpt_enterprise",
45 "https://platform.openai.com/docs/compliance",
46]
47risk_score = 73
48rule_id = "de41effc-9966-4cae-a5bb-2773bf7f641f"
49setup = """## Setup
50
51This rule requires the OpenAI ChatGPT Enterprise integration to collect compliance logs into Elasticsearch.
52
53https://www.elastic.co/docs/reference/integrations/openai_chatgpt_enterprise
54"""
55severity = "high"
56tags = [
57 "Domain: GenAI",
58 "Platform: OpenAI",
59 "Data Source: OpenAI ChatGPT Enterprise",
60 "Service: OpenAI ChatGPT Enterprise",
61 "Use Case: Threat Detection",
62 "Resources: Investigation Guide",
63 "Rule Type: ES|QL",
64 "Tactic: Credential Access",
65 "Mitre Atlas: AML.T0055",
66]
67timestamp_override = "event.ingested"
68type = "esql"
69
70query = '''
71from logs-openai_chatgpt_enterprise.codex_log-* metadata _id, _version, _index
72| eval Esql.prompt_text = coalesce(openai_chatgpt_enterprise.codex_log.event_details.prompt_text, "")
73| eval Esql.response_text = coalesce(openai_chatgpt_enterprise.codex_log.event_details.response_text, "")
74| where
75 data_stream.dataset == "openai_chatgpt_enterprise.codex_log" and
76 event.action == "prompt_response_received" and
77 (
78 (
79 Esql.prompt_text is not null and
80 Esql.prompt_text != "" and
81 not Esql.prompt_text like "*AKIAIOSFODNN7EXAMPLE*" and
82 not Esql.prompt_text like "*ASIAIOSFODNN7EXAMPLE*" and
83 not Esql.prompt_text like "*ghp_example*" and
84 not Esql.prompt_text like "*sk-ant-api03-test*" and
85 (
86
87 Esql.prompt_text rlike """.*(AKIA|ASIA)[A-Z0-9]{16}.*""" or
88 Esql.prompt_text rlike """.*gh[pousr]_[A-Za-z0-9]{36}.*""" or
89 Esql.prompt_text rlike """.*github_pat_[A-Za-z0-9_]+.*""" or
90 Esql.prompt_text rlike """.*-----BEGIN [A-Z ]*PRIVATE KEY-----.*""" or
91 Esql.prompt_text rlike """.*xox[baprs]-[0-9]+-[0-9]+-[A-Za-z0-9]+.*""" or
92 Esql.prompt_text rlike """.*sk_live_[A-Za-z0-9]+.*""" or
93 Esql.prompt_text rlike """.*AIza[-A-Za-z0-9_]+.*""" or
94 Esql.prompt_text rlike """.*npm_[A-Za-z0-9]{36}.*""" or
95 Esql.prompt_text rlike """.*sk-ant-[A-Za-z0-9-]+.*""" or
96 Esql.prompt_text rlike """.*sk-[A-Za-z0-9]{20,}.*""" or
97 Esql.prompt_text rlike """.*hvs[.][A-Za-z0-9]+.*""" or
98 Esql.prompt_text rlike """.*dckr_pat_[-A-Za-z0-9_]+.*""" or
99 Esql.prompt_text rlike """.*SG[.][-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*""" or
100 Esql.prompt_text rlike """.*(AccountKey=|SharedAccessKey=)[-A-Za-z0-9+/=]+.*""" or
101 Esql.prompt_text rlike """.*eyJ[-A-Za-z0-9_]+[.]eyJ[-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*"""
102 )
103 )
104 or
105 (
106 Esql.response_text is not null and
107 Esql.response_text != "" and
108 not Esql.response_text like "*AKIAIOSFODNN7EXAMPLE*" and
109 not Esql.response_text like "*ASIAIOSFODNN7EXAMPLE*" and
110 not Esql.response_text like "*ghp_example*" and
111 not Esql.response_text like "*sk-ant-api03-test*" and
112 (
113
114 Esql.response_text rlike """.*(AKIA|ASIA)[A-Z0-9]{16}.*""" or
115 Esql.response_text rlike """.*gh[pousr]_[A-Za-z0-9]{36}.*""" or
116 Esql.response_text rlike """.*github_pat_[A-Za-z0-9_]+.*""" or
117 Esql.response_text rlike """.*-----BEGIN [A-Z ]*PRIVATE KEY-----.*""" or
118 Esql.response_text rlike """.*xox[baprs]-[0-9]+-[0-9]+-[A-Za-z0-9]+.*""" or
119 Esql.response_text rlike """.*sk_live_[A-Za-z0-9]+.*""" or
120 Esql.response_text rlike """.*AIza[-A-Za-z0-9_]+.*""" or
121 Esql.response_text rlike """.*npm_[A-Za-z0-9]{36}.*""" or
122 Esql.response_text rlike """.*sk-ant-[A-Za-z0-9-]+.*""" or
123 Esql.response_text rlike """.*sk-[A-Za-z0-9]{20,}.*""" or
124 Esql.response_text rlike """.*hvs[.][A-Za-z0-9]+.*""" or
125 Esql.response_text rlike """.*dckr_pat_[-A-Za-z0-9_]+.*""" or
126 Esql.response_text rlike """.*SG[.][-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*""" or
127 Esql.response_text rlike """.*(AccountKey=|SharedAccessKey=)[-A-Za-z0-9+/=]+.*""" or
128 Esql.response_text rlike """.*eyJ[-A-Za-z0-9_]+[.]eyJ[-A-Za-z0-9_]+[.][-A-Za-z0-9_]+.*"""
129 )
130 )
131 )
132| keep
133 _id, _version, _index, @timestamp, event.action, user.id, user.email,
134 openai_chatgpt_enterprise.codex_log.client_id,
135 openai_chatgpt_enterprise.codex_log.event_details.session_id,
136 openai_chatgpt_enterprise.codex_log.event_details.prompt_text,
137 openai_chatgpt_enterprise.codex_log.event_details.response_text,
138 gen_ai.request.model, data_stream.*
139'''
140
141
142[[rule.threat]]
143framework = "MITRE ATT&CK"
144[[rule.threat.technique]]
145id = "T1552"
146name = "Unsecured Credentials"
147reference = "https://attack.mitre.org/techniques/T1552/"
148
149
150[rule.threat.tactic]
151id = "TA0006"
152name = "Credential Access"
153reference = "https://attack.mitre.org/tactics/TA0006/"
154[[rule.threat_mappings]]
155framework = "MITRE ATLAS"
156version = "2026.08"
157[[rule.threat_mappings.threat]]
158framework = "MITRE ATLAS"
159[[rule.threat_mappings.threat.technique]]
160id = "AML.T0055"
161name = "Unsecured Credentials"
162reference = "https://atlas.mitre.org/techniques/AML.T0055/"
163
164
165[rule.threat_mappings.threat.tactic]
166id = "AML.TA0013"
167name = "Credential Access"
168reference = "https://atlas.mitre.org/tactics/AML.TA0013/"
169
170[rule.investigation_fields]
171field_names = [
172 "@timestamp",
173 "user.id",
174 "user.email",
175 "openai_chatgpt_enterprise.codex_log.event_details.session_id",
176 "openai_chatgpt_enterprise.codex_log.event_details.prompt_text",
177 "openai_chatgpt_enterprise.codex_log.client_id",
178]
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
Related rules
- OpenAI ChatGPT Enterprise Assistant Advises Credential Rotation After Suspected Exposure
- OpenAI ChatGPT Enterprise Conversation Message Containing Credentials
- OpenAI ChatGPT Enterprise Multiple Authentication Failures
- OpenAI ChatGPT Enterprise User Activity From High Number of Countries
- OpenAI ChatGPT Enterprise Account Owner Role Assigned