AWS EC2 ImportKeyPair Activity Monitoring (CloudTrail)

Flags CloudTrail EC2 ImportKeyPair events that may indicate newly imported SSH key access setup.

FreeReviewedSigma · Medium · v5
Product
aws
Service
cloudtrail
Author
Ivan Saakov (SigmaHQ), DRL 1.1
Published
2024-12-19
Updated
2026-07-31
title: AWS EC2 ImportKeyPair Activity Monitoring (CloudTrail)
id: 041b85cd-0706-460d-ba25-4a42ab39fcae
status: experimental
description: This rule flags CloudTrail events where AWS EC2 ImportKeyPair is called to import an SSH key pair. Importing keys can enable attackers to establish or expand access to EC2 instances, potentially supporting initial access, persistence, or privilege escalation. The detection relies on CloudTrail telemetry fields matching eventSource ec2.amazonaws.com and eventName ImportKeyPair.
references:
  - https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_ImportKeyPair.html
  - https://github.com/SigmaHQ/sigma/blob/master/rules/cloud/aws/cloudtrail/aws_ec2_import_key_pair_activity.yml
author: Ivan Saakov, Huntrule Team
date: 2024-12-19
tags:
  - attack.initial-access
  - attack.stealth
  - attack.t1078
  - attack.persistence
  - attack.privilege-escalation
logsource:
  product: aws
  service: cloudtrail
detection:
  selection:
    eventSource: ec2.amazonaws.com
    eventName: ImportKeyPair
  condition: selection
falsepositives:
  - Legitimate administrative actions by authorized users importing keys for valid purposes.
  - Automated processes for infrastructure setup may trigger this alert.
  - Verify the user identity, user agent, and source IP address to ensure they are expected.
level: medium
license: DRL-1.1
related:
  - id: 92f84194-8d9a-4ee0-8699-c30bfac59780
    type: derived