<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Keypair — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/tags/keypair/</link><description>Trending threats, MITRE ATT&amp;CK coverage, and detection metadata — refreshed continuously.</description><generator>Hugo</generator><language>en</language><managingEditor>hello@craftedsignal.io</managingEditor><webMaster>hello@craftedsignal.io</webMaster><lastBuildDate>Thu, 19 Dec 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/tags/keypair/feed.xml" rel="self" type="application/rss+xml"/><item><title>Suspicious AWS EC2 Key Pair Import Activity</title><link>https://feed.craftedsignal.io/briefs/2024-12-aws-key-pair-import/</link><pubDate>Thu, 19 Dec 2024 00:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-12-aws-key-pair-import/</guid><description>The import of SSH key pairs into AWS EC2, as detected by CloudTrail logs, may indicate unauthorized access attempts, persistence establishment, or privilege escalation by an attacker.</description><content:encoded><![CDATA[<p>The unauthorized import of SSH key pairs into Amazon Elastic Compute Cloud (EC2) is a technique that malicious actors can leverage to gain unauthorized access to EC2 instances. By importing their own key pairs, attackers can bypass existing security measures and gain persistent access to compromised systems. This activity is often part of a broader attack campaign aimed at compromising sensitive data, disrupting services, or establishing a foothold within an organization&rsquo;s cloud infrastructure. The initial publication of the detection rule was in December 2024, highlighting the ongoing relevance of this technique in cloud security. Monitoring for this activity can help defenders identify and respond to potential security breaches in a timely manner.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains initial access to an AWS account, potentially through compromised credentials or exploiting a misconfigured IAM role.</li>
<li>The attacker attempts to enumerate existing EC2 instances to identify potential targets.</li>
<li>The attacker generates or obtains an SSH key pair, which they intend to use for unauthorized access.</li>
<li>The attacker uses the <code>ImportKeyPair</code> API call within the EC2 service to import the generated or obtained SSH key pair.</li>
<li>The attacker modifies the EC2 instance&rsquo;s configuration to associate the newly imported key pair with the instance. This might involve stopping and restarting the instance.</li>
<li>The attacker uses the imported SSH key pair to gain SSH access to the EC2 instance.</li>
<li>Once inside the instance, the attacker attempts to escalate privileges and move laterally within the AWS environment.</li>
<li>The attacker exfiltrates sensitive data, deploys malware, or disrupts critical services.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>A successful key pair import can lead to complete compromise of the affected EC2 instances, potentially impacting dozens of servers depending on the environment. Sensitive data stored on or accessible from these instances could be exfiltrated, leading to financial loss, reputational damage, and regulatory fines. Furthermore, compromised instances can be used as a launchpad for further attacks within the AWS environment, leading to a wider breach. The financial impact can range from tens of thousands to millions of dollars, depending on the scale of the breach and the sensitivity of the data compromised.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the provided Sigma rule to your SIEM to detect <code>ImportKeyPair</code> events in CloudTrail logs (logsource: aws, service: cloudtrail).</li>
<li>Review IAM policies to ensure that only authorized users and roles have the necessary permissions to import key pairs (eventSource: &rsquo;ec2.amazonaws.com&rsquo;, eventName: &lsquo;ImportKeyPair&rsquo;).</li>
<li>Investigate any detected <code>ImportKeyPair</code> events, validating the user identity, user agent, and source IP address to ensure they are expected (detection block).</li>
<li>Implement multi-factor authentication (MFA) for all AWS accounts to reduce the risk of credential compromise.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>aws</category><category>cloudtrail</category><category>ec2</category><category>keypair</category><category>initial-access</category><category>persistence</category><category>privilege-escalation</category></item><item><title>Suspicious AWS EC2 Key Pair Creation from Non-Cloud AS</title><link>https://feed.craftedsignal.io/briefs/2024-01-aws-ec2-keypair-creation/</link><pubDate>Wed, 03 Jan 2024 12:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-01-aws-ec2-keypair-creation/</guid><description>An AWS EC2 CreateKeyPair event triggered by a new principal originating from a network autonomous system (AS) organization not associated with major cloud providers, indicating potential unauthorized access or persistence activity.</description><content:encoded><![CDATA[<p>This alert identifies suspicious activity related to the creation of EC2 key pairs within an AWS environment. Specifically, it focuses on instances where a new IAM principal (user) creates an EC2 key pair from a network source (IP address) whose autonomous system organization is not commonly associated with major cloud providers like Amazon, Google, or Microsoft. Adversaries often create key pairs for persistence or to enable unauthorized access to EC2 instances, potentially leading to data exfiltration or further malicious activities. The rule uses a new terms approach to baseline user activity, reducing noise from repeated actions while still flagging the initial suspicious key pair creation. This activity is flagged as suspicious due to originating from outside trusted ASNs.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains initial access to an AWS account, potentially through compromised credentials or a misconfigured IAM role.</li>
<li>The attacker attempts to enumerate existing EC2 instances and associated key pairs.</li>
<li>The attacker uses the <code>CreateKeyPair</code> API call to generate a new SSH key pair within the AWS account. The request originates from a network with an autonomous system organization not attributed to common cloud providers.</li>
<li>The attacker stores the private key material for later use in accessing EC2 instances.</li>
<li>The attacker may then use the new key pair to launch new EC2 instances or import the key to existing instances. This can be done through <code>RunInstances</code> or <code>ImportKeyPair</code> operations.</li>
<li>The attacker uses the new key pair to SSH into the newly created or compromised EC2 instances.</li>
<li>Once inside the instances, the attacker performs malicious activities, such as data exfiltration, lateral movement, or installing malware.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation can lead to unauthorized access to EC2 instances, potentially compromising sensitive data and disrupting services. A compromised AWS account can allow the attacker to steal data, establish persistence, and move laterally within the cloud environment. The lack of expected cloud provider ASN for the source IP of the <code>CreateKeyPair</code> event raises the risk profile.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the Sigma rule &ldquo;AWS EC2 CreateKeyPair from Non-Cloud AS Organization&rdquo; to your SIEM and tune the <code>source.as.organization.name</code> exclusions based on your environment.</li>
<li>Review AWS CloudTrail logs for any <code>CreateKeyPair</code> events and correlate with other suspicious activity, as mentioned in the investigation steps in this brief.</li>
<li>Implement stricter IAM policies to limit the ability to create key pairs to only authorized users and roles.</li>
<li>Monitor for <code>RunInstances</code> or <code>ImportKeyPair</code> events using the newly created key names as identified from <code>aws.cloudtrail.request_parameters</code> / <code>response_elements</code>.</li>
<li>Enable and review AWS Config rules to detect and remediate misconfigurations related to IAM and EC2 key pair management.</li>
</ul>
]]></content:encoded><category domain="severity">medium</category><category domain="type">advisory</category><category>aws</category><category>ec2</category><category>keypair</category><category>persistence</category><category>credential_access</category><category>lateral_movement</category></item></channel></rss>