<?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>EC2 — CraftedSignal Threat Feed</title><link>https://feed.craftedsignal.io/products/ec2/</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, 11 Jul 2024 00:00:00 +0000</lastBuildDate><atom:link href="https://feed.craftedsignal.io/products/ec2/feed.xml" rel="self" type="application/rss+xml"/><item><title>Malicious Usage of AWS IMDS Credentials Outside of Expected Services</title><link>https://feed.craftedsignal.io/briefs/2024-07-aws-imds-abuse/</link><pubDate>Thu, 11 Jul 2024 00:00:00 +0000</pubDate><author>hello@craftedsignal.io</author><guid isPermaLink="true">https://feed.craftedsignal.io/briefs/2024-07-aws-imds-abuse/</guid><description>Compromised EC2 instances may be leveraged to exfiltrate and misuse AWS Instance Metadata Service (IMDS) credentials to perform actions outside of the expected AWS Simple Systems Manager (SSM) service, indicating potential lateral movement or data exfiltration.</description><content:encoded><![CDATA[<p>This activity focuses on the potential misuse of AWS Instance Metadata Service (IMDS) credentials. When an EC2 instance is compromised, an attacker can extract the temporary credentials stored within the IMDS. These credentials, associated with an assumed role, grant the attacker the ability to interact with other AWS services. The abnormal use of these credentials outside of the expected AWS Simple Systems Manager (SSM) service may indicate malicious activity such as lateral movement, data exfiltration, or resource compromise. This is particularly concerning when the compromised instance is being used as a pivot point to access other AWS resources.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An EC2 instance is compromised through an initial access vector (e.g., software vulnerability, misconfiguration, or credential compromise).</li>
<li>The attacker gains access to the compromised EC2 instance&rsquo;s operating system.</li>
<li>The attacker queries the IMDS endpoint (http://169.254.169.254/latest/meta-data/iam/security-credentials/) to obtain temporary AWS credentials associated with the instance&rsquo;s IAM role.</li>
<li>The attacker configures their local AWS CLI or SDK with the exfiltrated credentials.</li>
<li>The attacker attempts to perform actions against other AWS services using the exfiltrated credentials.</li>
<li>The attacker attempts to escalate privileges or move laterally within the AWS environment.</li>
<li>The attacker attempts to access, modify, or exfiltrate sensitive data from other AWS services.</li>
<li>The attacker maintains persistence by creating new IAM users or roles with excessive permissions.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation can lead to unauthorized access to sensitive data stored in AWS services such as S3, DynamoDB, and RDS. This could result in data breaches, financial loss, and reputational damage. Attackers can also leverage the compromised credentials to pivot to other AWS resources, potentially impacting critical infrastructure and services. Organizations with lax security configurations and overly permissive IAM roles are at higher risk.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the Sigma rule &ldquo;Malicious Usage Of IMDS Credentials Outside Of AWS Infrastructure&rdquo; to your SIEM and tune for your environment to detect anomalous use of IMDS credentials.</li>
<li>Review and restrict IAM roles assigned to EC2 instances to follow the principle of least privilege, limiting the scope of potential damage from credential exfiltration.</li>
<li>Monitor CloudTrail logs for unusual API calls originating from EC2 instances with assumed roles, specifically those not related to SSM.</li>
<li>Harden EC2 instances to prevent initial compromise by applying security patches, configuring strong authentication, and regularly scanning for vulnerabilities.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>attack.privilege-escalation</category><category>attack.initial-access</category><category>attack.persistence</category><category>attack.stealth</category><category>attack.t1078</category><category>attack.t1078.002</category></item><item><title>AWS EC2 Stop, Start, and User Data Modification Correlation</title><link>https://feed.craftedsignal.io/briefs/2024-01-03-aws-ec2-user-data-modification/</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-03-aws-ec2-user-data-modification/</guid><description>Detection of a sequence of AWS EC2 management API calls indicative of malicious modification of instance user data to execute arbitrary code upon instance restart, potentially leading to privilege escalation and persistence.</description><content:encoded><![CDATA[<p>This detection identifies a specific sequence of AWS EC2 API calls suggesting malicious intent. An adversary may update the <code>userData</code> attribute of an EC2 instance and then restart the instance to execute malicious scripts with elevated privileges (root on Linux, SYSTEM on Windows). The technique involves modifying instance attributes to inject malicious code or scripts, followed by stopping and starting the instance to trigger execution of the modified user data. This can lead to privilege escalation, persistence, or other malicious activities within the AWS environment. The detection focuses on the correlation of <code>StopInstances</code>, <code>StartInstances</code>, and <code>ModifyInstanceAttribute</code> events that reference <code>userData</code> within a 5-minute window. The rule groups these events by instance ID, username, account ID, source IP, and user agent, triggering an alert only when all three distinct API calls are observed within the same group. This aims to reduce false positives by requiring the complete sequence of actions associated with this technique.</p>
<h2 id="attack-chain">Attack Chain</h2>
<ol>
<li>An attacker gains initial access to an AWS account with sufficient permissions to manage EC2 instances (e.g., via compromised credentials or an IAM role).</li>
<li>The attacker identifies a target EC2 instance.</li>
<li>The attacker uses the <code>ModifyInstanceAttribute</code> API call to update the <code>userData</code> attribute of the target instance, injecting malicious code or scripts.</li>
<li>The attacker uses the <code>StopInstances</code> API call to stop the target EC2 instance.</li>
<li>The attacker uses the <code>StartInstances</code> API call to start the target EC2 instance.</li>
<li>Upon instance start, the modified <code>userData</code> script executes with elevated privileges, potentially installing malware, establishing persistence, or performing other malicious actions.</li>
<li>The attacker may use the compromised instance to further explore the AWS environment, escalate privileges, or exfiltrate data.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation can lead to unauthorized code execution within the AWS environment. Attackers can gain elevated privileges on the compromised EC2 instance, potentially leading to full control of the instance and the ability to access sensitive data or resources within the AWS account. This can result in data breaches, service disruptions, and financial losses. The modification of user data allows for persistent malicious code execution each time the instance restarts.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the following Sigma rules to your SIEM to detect the described attack pattern, and tune them to your environment.</li>
<li>Review CloudTrail logs for <code>ModifyInstanceAttribute</code> events with <code>userData</code> to identify potentially malicious modifications.</li>
<li>Monitor EC2 instance state transitions (stop/start) in conjunction with user data modifications.</li>
<li>Implement least privilege IAM policies to restrict access to EC2 management APIs.</li>
<li>Use AWS Secrets Manager or Parameter Store to manage secrets instead of embedding them in <code>userData</code>.</li>
<li>Investigate any alerts generated by the Sigma rules and correlate them with other security events.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>aws</category><category>ec2</category><category>user-data</category><category>privilege-escalation</category><category>persistence</category><category>execution</category></item><item><title>AWS EC2 Instance Profile Associated with Running Instance</title><link>https://feed.craftedsignal.io/briefs/2024-01-aws-ec2-instance-profile-association/</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-instance-profile-association/</guid><description>An attacker may escalate privileges by associating a compromised EC2 instance with a more privileged IAM instance profile.</description><content:encoded><![CDATA[<p>This threat brief focuses on the potential for privilege escalation and lateral movement within Amazon Web Services (AWS) environments by abusing the ability to associate or replace IAM instance profiles on running EC2 instances. An attacker with the necessary permissions (<code>ec2:AssociateIamInstanceProfile</code> or <code>ec2:ReplaceIamInstanceProfile</code> and typically <code>iam:PassRole</code>) can elevate the privileges of a compromised EC2 instance. This is achieved by attaching a more privileged IAM role to the instance, granting the attacker access to resources and permissions beyond their initial scope. The event is logged in AWS CloudTrail, providing a critical detection opportunity for security teams.</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 vulnerable application.</li>
<li>The attacker identifies a running EC2 instance with limited privileges.</li>
<li>The attacker identifies or creates a more privileged IAM role that grants broader access to AWS resources.</li>
<li>The attacker uses the <code>AssociateIamInstanceProfile</code> or <code>ReplaceIamInstanceProfile</code> API calls to associate the privileged IAM role with the target EC2 instance. This requires appropriate IAM permissions.</li>
<li>The EC2 instance&rsquo;s metadata service now provides credentials for the newly associated IAM role.</li>
<li>The attacker leverages the elevated privileges to access sensitive data or resources, potentially including other EC2 instances, databases, or storage buckets.</li>
<li>The attacker moves laterally within the AWS environment, compromising additional resources and escalating their access.</li>
<li>The attacker achieves their objective, such as exfiltrating data, deploying malicious code, or disrupting services.</li>
</ol>
<h2 id="impact">Impact</h2>
<p>Successful exploitation allows attackers to elevate privileges within the AWS environment, potentially leading to unauthorized access to sensitive data, lateral movement to other systems, and disruption of critical services. The impact could range from data breaches and financial losses to reputational damage and regulatory fines. Identifying and responding to these events quickly is crucial to minimizing potential damage.</p>
<h2 id="recommendation">Recommendation</h2>
<ul>
<li>Deploy the Sigma rule &ldquo;AWS EC2 Instance Profile Associated with Running Instance&rdquo; to your SIEM using AWS CloudTrail logs to detect suspicious activity.</li>
<li>Review and harden IAM permissions related to <code>ec2:AssociateIamInstanceProfile</code> and <code>ec2:ReplaceIamInstanceProfile</code> to limit who can modify instance profiles.</li>
<li>Enable CloudTrail logging for all regions in your AWS account to ensure comprehensive audit coverage.</li>
<li>Implement least privilege principles for IAM roles assigned to EC2 instances to minimize the impact of potential privilege escalation.</li>
<li>Investigate any alerts generated by the Sigma rule, focusing on the source IP address, user identity, and the IAM role associated with the instance profile.</li>
</ul>
]]></content:encoded><category domain="severity">high</category><category domain="type">advisory</category><category>aws</category><category>privilege-escalation</category><category>lateral-movement</category></item></channel></rss>