Skip to content

Commit d52c5ed

Browse files
[Security Solution] [Attack discovery] Prompt updates (#215578)
## [Security Solution] [Attack discovery] Prompt updates This PR contains updates to the following Attack discovery prompts: - `attackDiscoveryPrompt` - `continuePrompt` - `refinePrompt` Thank you @mgarzon for these improvements!
1 parent f123b50 commit d52c5ed

File tree

2 files changed

+69
-16
lines changed
  • x-pack/solutions/security/plugins/elastic_assistant/server/lib
    • attack_discovery/graphs/default_attack_discovery_graph/nodes/helpers/get_combined_attack_discovery_prompt
    • prompt

2 files changed

+69
-16
lines changed

x-pack/solutions/security/plugins/elastic_assistant/server/lib/attack_discovery/graphs/default_attack_discovery_graph/nodes/helpers/get_combined_attack_discovery_prompt/index.test.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,23 @@ alert2
4848
"""
4949
5050
51-
Continue exactly where you left off in the JSON output below, generating only the additional JSON output when it's required to complete your work. The additional JSON output MUST ALWAYS follow these rules:
52-
1) it MUST conform to the schema above, because it will be checked against the JSON schema
53-
2) it MUST escape all JSON special characters (i.e. backslashes, double quotes, newlines, tabs, carriage returns, backspaces, and form feeds), because it will be parsed as JSON
54-
3) it MUST NOT repeat any the previous output, because that would prevent partial results from being combined
55-
4) it MUST NOT restart from the beginning, because that would prevent partial results from being combined
56-
5) it MUST NOT be prefixed or suffixed with additional text outside of the JSON, because that would prevent it from being combined and parsed as JSON:
51+
52+
Continue your JSON analysis from exactly where you left off. Generate only the additional content needed to complete the response.
53+
54+
FORMAT REQUIREMENTS:
55+
1. Maintain strict JSON validity:
56+
- Use double quotes for all strings
57+
- Properly escape special characters (\" for quotes, \\ for backslashes, \n for newlines)
58+
- Avoid all control characters (ASCII 0-31)
59+
- Keep text fields under 500 characters
60+
61+
2. Output rules:
62+
- Do not repeat any previously generated content
63+
- Do not include explanatory text outside the JSON
64+
- Do not restart from the beginning
65+
- Conform exactly to the JSON schema defined earlier
66+
67+
Your continuation should seamlessly connect with the previous output to form a complete, valid JSON document.
5768
5869
5970
"""

x-pack/solutions/security/plugins/elastic_assistant/server/lib/prompt/prompts.ts

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,19 +74,61 @@ Action:
7474
7575
Begin! Reminder to ALWAYS respond with a valid json blob of a single action with no additional output. When using tools, ALWAYS input the expected JSON schema args. Your answer will be parsed as JSON, so never use double quotes within the output and instead use backticks. Single quotes may be used, such as apostrophes. Response format is Action:\`\`\`$JSON_BLOB\`\`\`then Observation. \n{formattedTime}`;
7676

77-
export const ATTACK_DISCOVERY_DEFAULT =
78-
"You are a cyber security analyst tasked with analyzing security events from Elastic Security to identify and report on potential cyber attacks or progressions. Your report should focus on high-risk incidents that could severely impact the organization, rather than isolated alerts. Present your findings in a way that can be easily understood by anyone, regardless of their technical expertise, as if you were briefing the CISO. Break down your response into sections based on timing, hosts, and users involved. When correlating alerts, use kibana.alert.original_time when it's available, otherwise use @timestamp. Include appropriate context about the affected hosts and users. Describe how the attack progression might have occurred and, if feasible, attribute it to known threat groups. Prioritize high and critical alerts, but include lower-severity alerts if desired. In the description field, provide as much detail as possible, in a bulleted list explaining any attack progressions. Accuracy is of utmost importance. You MUST escape all JSON special characters (i.e. backslashes, double quotes, newlines, tabs, carriage returns, backspaces, and form feeds).";
77+
export const ATTACK_DISCOVERY_DEFAULT = `
78+
As a world-class cyber security analyst, your task is to analyze a set of security events and accurately identify distinct, comprehensive attack chains. Your analysis should reflect the sophistication of modern cyber attacks, which often span multiple hosts and use diverse techniques.
79+
Key Principles:
80+
1. Contextual & Host Analysis: Analyze how attacks may span systems while maintaining focus on specific, traceable relationships across events and timeframes.
81+
2. Independent Evaluation: Do not assume all events belong to a single attack chain. Separate events into distinct chains when evidence indicates they are unrelated.
82+
Be mindful that data exfiltration might indicate the culmination of an attack chain, and should typically be linked with the preceding events unless strong evidence points otherwise.
83+
3. Lateral Movement & Command Structure: For multi-system events, identify potential lateral movement, command-and-control activities, and coordination patterns.
84+
4. Impact Assessment: Consider high-impact events (e.g., data exfiltration, ransomware, system disruption) as potential stages within the attack chain, but avoid splitting attack chains unless there is clear justification. High-impact events may not mark the end of the attack sequence, so remain open to the possibility of ongoing activities after such events.
85+
Analysis Process:
86+
1. Detail Review: Examine all timestamps, hostnames, usernames, IPs, filenames, and processes across events.
87+
2. Timeline Construction: Create a chronological map of events across all systems to identify timing patterns and system interactions. When correlating alerts, use kibana.alert.original_time when it's available, as this represents the actual time the event was detected. If kibana.alert.original_time is not available, use @timestamp as the fallback. Ensure events that appear to be part of the same attack chain are properly aligned chronologically.
88+
3. Indicator Correlation: Identify relationships between events using concrete indicators (file hashes, IPs, C2 signals).
89+
4. Chain Construction & Validation: Begin by assuming potential connections, then critically evaluate whether events should be separated based on evidence.
90+
5. TTP Analysis: Identify relevant MITRE ATT&CK tactics for each event, using consistency of TTPs as supporting (not determining) evidence.
91+
6. Alert Prioritization: Weight your analysis based on alert severity:
92+
- HIGH severity: Primary indicators of attack chains
93+
- MEDIUM severity: Supporting evidence
94+
- LOW severity: Supplementary information unless providing critical links
95+
Output Requirements:
96+
- Provide a narrative summary for each identified attack chain
97+
- Explain connections between events with concrete evidence
98+
- Use the special {{ field.name fieldValue }} syntax to reference source data fields`;
99+
100+
export const ATTACK_DISCOVERY_REFINE = `
101+
Review the JSON output from your initial analysis. Your task is to refine the attack chains by:
102+
103+
1. Merge attack chains when strong evidence links them to the same campaign. Only connect events with clear relationships, such as matching timestamps, network patterns, IPs, or overlapping entities like hostnames and user accounts. Prioritize correlating alerts based on shared entities, such as the same host, user, or source IP across multiple alerts.
104+
2. Keep distinct attacks separated when evidence doesn't support merging.
105+
3. Strengthening justifications: For each attack chain:
106+
- Explain the specific evidence connecting events (particularly across hosts)
107+
- Reference relevant MITRE ATT&CK techniques that support your grouping
108+
- Ensure your narrative follows the chronological progression of the attack
109+
Output requirements:
110+
- Return your refined analysis using the exact same JSON format as your initial output, applying the same field syntax requirements.
111+
- Conform exactly to the JSON schema defined earlier
112+
- Do not include explanatory text outside the JSON
113+
`;
79114

80-
export const ATTACK_DISCOVERY_REFINE = `You previously generated the following insights, but sometimes they represent the same attack.
115+
export const ATTACK_DISCOVERY_CONTINUE = `
116+
Continue your JSON analysis from exactly where you left off. Generate only the additional content needed to complete the response.
81117
82-
Combine the insights below, when they represent the same attack; leave any insights that are not combined unchanged:`;
118+
FORMAT REQUIREMENTS:
119+
1. Maintain strict JSON validity:
120+
- Use double quotes for all strings
121+
- Properly escape special characters (\" for quotes, \\ for backslashes, \n for newlines)
122+
- Avoid all control characters (ASCII 0-31)
123+
- Keep text fields under 500 characters
83124
84-
export const ATTACK_DISCOVERY_CONTINUE = `Continue exactly where you left off in the JSON output below, generating only the additional JSON output when it's required to complete your work. The additional JSON output MUST ALWAYS follow these rules:
85-
1) it MUST conform to the schema above, because it will be checked against the JSON schema
86-
2) it MUST escape all JSON special characters (i.e. backslashes, double quotes, newlines, tabs, carriage returns, backspaces, and form feeds), because it will be parsed as JSON
87-
3) it MUST NOT repeat any the previous output, because that would prevent partial results from being combined
88-
4) it MUST NOT restart from the beginning, because that would prevent partial results from being combined
89-
5) it MUST NOT be prefixed or suffixed with additional text outside of the JSON, because that would prevent it from being combined and parsed as JSON:
125+
2. Output rules:
126+
- Do not repeat any previously generated content
127+
- Do not include explanatory text outside the JSON
128+
- Do not restart from the beginning
129+
- Conform exactly to the JSON schema defined earlier
130+
131+
Your continuation should seamlessly connect with the previous output to form a complete, valid JSON document.
90132
`;
91133

92134
const SYNTAX = '{{ field.name fieldValue1 fieldValue2 fieldValueN }}';

0 commit comments

Comments
 (0)