Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
[metadata]
creation_date = "2026/11/25"
integration = ["aws"]
maturity = "production"
updated_date = "2026/11/25"

[rule]
author = ["Elastic"]
description = """
Detects an AWS Systems Manager (SSM) Session Manager session targeting one EC2 or hybrid managed node followed by a
successful "CreateDataChannel" request for the same session from a different managed node. This mismatch can indicate
that credentials from a compromised node were used to join another node's session.
"""
false_positives = [
"""
A custom session broker or management integration might intentionally create a data channel from a node other than
the session target. Confirm the session architecture and expected IAM role before adding a narrow exception.
""",
]
from = "now-35m"
interval = "5m"
language = "esql"
license = "Elastic License v2"
name = "AWS SSM Data Channel Created for Session Targeted to Another Node"
note = """## Triage and analysis

### Investigating AWS SSM Data Channel Created for Session Targeted to Another Node

This rule correlates a successful `StartSession` event with a successful `CreateDataChannel` event for the returned
session ID. During normal Session Manager operation, the agent on the targeted managed node uses that node's credentials
to create the data channel. The rule alerts when the instance or hybrid-node identity at the end of the channel caller's
`user.id` differs from the `StartSession` target.

Managed-node roles commonly receive `ssmmessages:CreateDataChannel` on all resources. A caller with credentials from one
node may therefore be able to request a data-channel token for a different node's active session without receiving
`StartSession` or `ResumeSession` permission. A mismatch is a strong lateral-movement signal, but the alert does not by
itself prove that the returned token was used to open the channel.

### Possible investigation steps

- Compare `Esql.start_target_values` with `Esql.create_data_channel_caller_node_values` and confirm that they identify
different managed nodes. Use `Esql.session_id` to retrieve the original CloudTrail events.
- Identify the `StartSession` initiator, document name, session parameters, and source address. Determine whether the
session was interactive and whether the initiator expected it to reach the recorded target.
- Review preceding failed `StartSession`, `ResumeSession`, and `DescribeSessions` requests from the channel caller's
identity and source address. Search for discovery of active session identifiers.
- Identify subsequent `OpenDataChannel` events for the session and review the associated source address and user agent.
- Investigate the source managed node for instance metadata credential access and direct SSM messaging API calls.
- Review Session Manager audit logs, shell history, and commands executed during the affected session.

### False positive analysis

- Determine whether an approved session broker intentionally creates channels on behalf of other managed nodes.
- Do not exclude all instance-profile activity or all `CreateDataChannel` events. Normal agents generate these events;
the cross-node correlation provides the signal.
- If long-running sessions are expected, increase the lookback to the configured maximum session duration.

### Response and remediation

- Isolate both the source managed node and the target session's node if cross-instance access is confirmed.
- Terminate the affected Session Manager session and revoke or replace the source node's instance profile credentials.
- Review all sessions and channel events involving the source role for additional affected nodes.
- Restrict discovery of active session identifiers and monitor the four `ssmmessages` channel operations granted to
managed-node roles.
"""
references = [
"https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager.html",
"https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-getting-started-instance-profile.html",
"https://docs.aws.amazon.com/aws-managed-policy/latest/reference/AmazonSSMManagedInstanceCore.html",
]
risk_score = 47
rule_id = "7ef2f6e2-b94e-434f-8aa9-e145acd17b74"
severity = "medium"
tags = [
"Domain: Cloud",
"Data Source: AWS",
"Data Source: Amazon Web Services",
"Data Source: AWS SSM",
"Data Source: AWS EC2",
"Use Case: Threat Detection",
"Tactic: Lateral Movement",
"Rule Type: ES|QL",
"Resources: Investigation Guide",
]
timestamp_override = "event.ingested"
type = "esql"

query = '''
FROM logs-aws.cloudtrail-*
| WHERE event.dataset == "aws.cloudtrail"
AND event.provider == "ssm.amazonaws.com"
AND event.action IN ("StartSession", "CreateDataChannel")
AND event.outcome == "success"
| GROK aws.cloudtrail.response_elements
"""%{GREEDYDATA}sessionId=(?<Esql.start_session_id>[^,}]+)%{GREEDYDATA}"""
| GROK aws.cloudtrail.request_parameters
"""%{GREEDYDATA}sessionId=(?<Esql.create_data_channel_session_id>[^,}]+)%{GREEDYDATA}"""
| GROK aws.cloudtrail.request_parameters
"""%{GREEDYDATA}target=(?<Esql.start_target>[^,}]+)%{GREEDYDATA}"""
| GROK user.id
"""%{GREEDYDATA}:(?<Esql.create_data_channel_caller_node>(?:i|mi)-.+)"""
| EVAL Esql.is_start_session = event.action == "StartSession"
| EVAL Esql.is_create_data_channel = event.action == "CreateDataChannel"
| EVAL Esql.session_id = COALESCE(
Esql.start_session_id,
Esql.create_data_channel_session_id
)
| EVAL Esql.managed_node = CASE(
Esql.is_start_session,
Esql.start_target,
Esql.create_data_channel_caller_node
)
| WHERE Esql.session_id IS NOT NULL
AND Esql.managed_node LIKE ("i-*", "mi-*")
| STATS
Esql.start_session_event_count = SUM(CASE(Esql.is_start_session, 1, 0)),
Esql.create_data_channel_event_count = SUM(CASE(Esql.is_create_data_channel, 1, 0)),
Esql.managed_node_count = COUNT_DISTINCT(Esql.managed_node),
Esql.first_start_session_event = MIN(CASE(Esql.is_start_session, @timestamp, null)),
Esql.first_create_data_channel_event = MIN(CASE(Esql.is_create_data_channel, @timestamp, null)),
Esql.start_target_values = VALUES(CASE(Esql.is_start_session, Esql.start_target, null)),
Esql.create_data_channel_caller_node_values = VALUES(
CASE(Esql.is_create_data_channel, Esql.create_data_channel_caller_node, null)
),
Esql.source_ip_values = VALUES(CASE(Esql.is_create_data_channel, source.ip, null)),
Esql.user_agent_original_values = VALUES(CASE(Esql.is_create_data_channel, user_agent.original, null)),
Esql_priv.start_session_principal_arn_values = VALUES(
CASE(Esql.is_start_session, aws.cloudtrail.user_identity.arn, null)
),
Esql_priv.create_data_channel_principal_arn_values = VALUES(
CASE(Esql.is_create_data_channel, aws.cloudtrail.user_identity.arn, null)
)
BY cloud.account.id, cloud.region, Esql.session_id
| WHERE Esql.start_session_event_count >= 1
AND Esql.create_data_channel_event_count >= 1
AND Esql.managed_node_count >= 2
AND Esql.first_create_data_channel_event >= Esql.first_start_session_event
AND DATE_DIFF(
"minutes",
Esql.first_start_session_event,
Esql.first_create_data_channel_event
) <= 30
| KEEP cloud.account.id, cloud.region, Esql.*, Esql_priv.*
'''

[rule.investigation_fields]
field_names = [
"Esql.session_id",
"Esql.first_start_session_event",
"Esql.first_create_data_channel_event",
"Esql.start_target_values",
"Esql.create_data_channel_caller_node_values",
"Esql_priv.start_session_principal_arn_values",
"Esql_priv.create_data_channel_principal_arn_values",
"Esql.source_ip_values",
"Esql.user_agent_original_values",
"cloud.account.id",
"cloud.region",
]

[[rule.threat]]
framework = "MITRE ATT&CK"

[[rule.threat.technique]]
id = "T1021"
name = "Remote Services"
reference = "https://attack.mitre.org/techniques/T1021/"

[[rule.threat.technique.subtechnique]]
id = "T1021.007"
name = "Cloud Services"
reference = "https://attack.mitre.org/techniques/T1021/007/"

[rule.threat.tactic]
id = "TA0008"
name = "Lateral Movement"
reference = "https://attack.mitre.org/tactics/TA0008/"
Loading