fbpx

Four use cases for GuardDuty Malware Protection On-demand malware scan

Amazon GuardDuty is a threat detection service that continuously monitors your Amazon Web Services (AWS) accounts and workloads for malicious activity and delivers detailed security findings for visibility and remediation. GuardDuty Malware Protection helps detect the presence of malware by performing agentless scans of the Amazon Elastic Block Store (Amazon EBS) volumes that are attached to Amazon Elastic Compute Cloud (Amazon EC2) instances and container workloads. GuardDuty findings for identified malware provide additional insights of potential threats related to EC2 instances and containers running on an instance. Malware findings can also provide additional context for EC2 related threats identified by GuardDuty such as observed cryptocurrency-related activity and communication with a command and control server. Examples of malware categories that GuardDuty Malware Protection helps identify include ransomware, cryptocurrency mining, remote access, credential theft, and phishing. In this blog post, we provide an overview of the On-demand malware scan feature in GuardDuty and walk through several use cases where you can use On-demand malware scanning.

   <p>GuardDuty offers two types of malware scanning for EC2 instances: <a href="https://docs.aws.amazon.com/guardduty/latest/ug/gdu-initiated-malware-scan.html" target="_blank" rel="noopener">GuardDuty-initiated malware scans</a> and <a href="https://docs.aws.amazon.com/guardduty/latest/ug/on-demand-malware-scan.html" target="_blank" rel="noopener">On-demand malware scans</a>. GuardDuty initiated malware scans are launched after GuardDuty generates an <a href="https://docs.aws.amazon.com/guardduty/latest/ug/gd-findings-initiate-malware-protection-scan.html" target="_blank" rel="noopener">EC2 finding</a> that indicates behavior typical of malware on an EC2 instance or container workload. The initial EC2 finding helps to provide insight that a specific threat is being observed based on <a href="https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_data-sources.html#guardduty_vpc" target="_blank" rel="noopener">VPC Flow Logs</a> and <a href="https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_data-sources.html#guardduty_dns" target="_blank" rel="noopener">DNS logs</a>. Performing a malware scan on the instance goes beyond what can be observed from log activity and helps to provide additional context at the instance file system level, showing a connection between malware and the observed network traffic. This additional context can also help you determine your response and remediation steps for the identified threat.</p> 
   <p>There are multiple use cases where you would want to scan an EC2 instance for malware even when there’s no GuardDuty EC2 finding for the instance. This could include scanning as part of a security investigation or scanning certain instances on a regular schedule. You can use the On-demand malware scan feature to scan an EC2 instance when you want, providing flexibility in how you maintain the security posture of your EC2 instances. </p> 
   <h2>On-demand malware scanning</h2> 
   <p>To perform <a href="https://docs.aws.amazon.com/guardduty/latest/ug/on-demand-malware-scan.html" target="_blank" rel="noopener">on-demand malware scanning,</a> your account must have GuardDuty enabled. If the service-linked role (SLR) permissions for Malware Protection don’t exist in the account the first time that you submit an on-demand scan, the SLR for Malware Protection will automatically be created. An on-demand malware scan is initiated by providing the Amazon Resource Name (ARN) of the EC2 instance to scan. The malware scan of the instance is performed using the same <a href="https://docs.aws.amazon.com/guardduty/latest/ug/on-demand-malware-scan.html#how-odmalscan-works-in-gdu" target="_blank" rel="noopener">functionality</a> as GuardDuty-initiated scans. The malware scans that GuardDuty performs are agentless and the feature is designed in a way that it won’t affect the performance of your resources.</p> 
   <p>An on-demand malware scan can be initiated through the GuardDuty <strong>Malware Protection</strong> section of the AWS Management Console for GuardDuty or through the <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_StartMalwareScan.html" target="_blank" rel="noopener">StartMalwareScan</a> API. On-demand malware scans can be initiated from the GuardDuty <a href="https://docs.aws.amazon.com/guardduty/latest/ug/guardduty_organizations.html" target="_blank" rel="noopener">delegated administrator</a> account for EC2 instances in a member account where GuardDuty is enabled, or the scan can be initiated from a member account or a stand-alone account for Amazon EC2 instances within that account. High-level details for every malware scan that GuardDuty runs are reported in the <strong>Malware scans</strong> section of the GuardDuty console. The <strong>Malware scans</strong> section identifies which EC2 instance the scan was initiated for, the status of the scan (completed, running, skipped, or failed), the result of the scan (clean or infected), and when the malware scan was initiated. This summary information on malware scans is also available through the <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_DescribeMalwareScans.html" target="_blank" rel="noopener">DescribeMalwareScans</a> API.</p> 
   <p>When an on-demand scan detects malware on an EC2 instance, a new GuardDuty finding is created. This finding lists the details about the impacted EC2 instance, where malware was found in the instance file system, how many occurrences of malware were found, and details about the actual malware. Additionally, if malware was found in a Docker container, the finding also lists details about the container and, if the EC2 instance is used to support <a href="https://aws.amazon.com/eks/" target="_blank" rel="noopener">Amazon Elastic Kubernetes Service (Amazon EKS)</a> or <a href="https://aws.amazon.com/ecs/" target="_blank" rel="noopener">Amazon Elastic Container Service (Amazon ECS)</a> container deployments, details about the cluster, task, and pod are also included in the finding. Findings about identified malware can be viewed in the GuardDuty console along with other GuardDuty findings or can be retrieved using the <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_Operations.html" target="_blank" rel="noopener">GuardDuty APIs</a>. Additionally, each finding that GuardDuty generates is sent to <a href="https://aws.amazon.com/eventbridge/" target="_blank" rel="noopener">Amazon EventBridge</a> and <a href="https://aws.amazon.com/security-hub/" target="_blank" rel="noopener">AWS Security Hub</a>. With EventBridge, you can author rules that allow you to match certain GuardDuty findings and then send the findings to a defined target in an event-driven flow. Security Hub helps you include GuardDuty findings in your aggregation and prioritization of security findings for your overall AWS environment.</p> 
   <p>GuardDuty <a href="https://aws.amazon.com/guardduty/pricing/" target="_blank" rel="noopener">charges</a> for the total amount of Amazon EBS data that’s scanned. You can use the provisioned storage for an Amazon EBS volume to get an initial estimate on what the scan will cost. When the actual malware scan runs, the final cost is based on the amount of data that was actually scanned by GuardDuty to perform a malware scan. To get a more accurate estimate of what a malware scan on an Amazon EBS volume might cost, you must obtain the actual storage amount used from the EC2 instance that the volume is attached to. There are multiple methods available to determine the actual amount of storage currently being used on an EBS volume including using the <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file.html" target="_blank" rel="noopener">CloudWatch Logs agent</a> to collect disk-used metrics, and running individual commands to see the amount of free disk space on <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-describing-volumes.html#ebs-view-free-disk-space" target="_blank" rel="noopener">Linux</a> and <a href="https://docs.aws.amazon.com/AWSEC2/latest/WindowsGuide/ebs-describing-volumes.html#ebs-view-free-disk-space" target="_blank" rel="noopener">Windows</a> EC2 instances.</p> 
   <h2>Use cases using GuardDuty On-demand malware scan</h2> 
   <p>Now that you’ve reviewed the on-demand malware scan feature and how it works, let’s walk through four use cases where you can incorporate it to help you achieve your security goals. In use cases 1 and 2, we provide you with deployable assets to help demonstrate the solution in your own environment.</p> 
   <h3>Use case 1 – Initiating scans for EC2 instances with specific tags</h3> 
   <p>This first use case walks through how on-demand scanning can be performed based on <a href="https://docs.aws.amazon.com/whitepapers/latest/tagging-best-practices/tagging-best-practices.html" target="_blank" rel="noopener">tags</a> applied to an EC2 instance. Each tag is a label consisting of a key and an optional value to store information about the resource or data retained on that resource. Resource tagging can be used to help identify a specific target group of EC2 instances for malware scanning to meet your security requirements. Depending on your organization’s strategy, tags can indicate the data classification strategy, workload type, or the compliance scope of your EC2 instance, which can be used as criteria for malware scanning.</p> 
   <p>In this solution, you use a combination of GuardDuty, an <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/documents.html" target="_blank" rel="noopener">AWS Systems Manager document (SSM document)</a>, <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Subscriptions.html" target="_blank" rel="noopener">Amazon CloudWatch Logs subscription filters</a>, <a href="https://aws.amazon.com/lambda/" target="_blank" rel="noopener">AWS Lambda</a>, and <a href="https://aws.amazon.com/sns/" target="_blank" rel="noopener">Amazon Simple Notification Service (Amazon SNS)</a> to initiate a malware scan of EC2 instances containing a specific tag. This solution is designed to be deployed in a member account and identifies EC2 instances to scan within that member account.</p> 
   <h4>Solution architecture</h4> 
   <p>Figure 1 shows the high-level architecture of the solution which depicts an on-demand malware scan being initiated based on a tag key.</p> 
   <div id="attachment_32789" class="wp-caption aligncenter"> 
    <img aria-describedby="caption-attachment-32789" src="https://infracom.com.sg/wp-content/uploads/2023/12/img1_v3.jpg" alt="Figure 1: Tag based on-demand malware scan architecture" width="769" height="317" class="size-full wp-image-32789"> 
    <p id="caption-attachment-32789" class="wp-caption-text">Figure 1: Tag based on-demand malware scan architecture</p> 
   </div> 
   <p>The high-level workflow is:</p> 
   <ol> 
    <li>Enter the tag scan parameters in the SSM document that’s deployed as part of the solution.</li> 
    <li>When you initiate the SSM document, the <span>GuardDutyMalwareOnDemandScanLambdaFunction</span> Lambda function is invoked, which launches the collection of the associated Amazon EC2 ARNs that match your tag criteria.</li> 
    <li>The Lambda function obtains ARNs of the EC2 instances and initiates a malware scan for each instance. </li> 
    <li>GuardDuty scans each instance for malware.</li> 
    <li>A CloudWatch Logs subscription filter created under the log group <span>/aws/guardduty/malware-scan-events</span> monitors for log file entries of on-demand malware scans which have a status of COMPLETED or SKIPPED. If a scan matches this filter criteria, it’s sent to the <span>GuardDutyMalwareOnDemandNotificationLambda</span> Lambda function. </li> 
    <li>The <span>GuardDutyMalwareOnDemandNotificationLambda</span> function parses the information from the scan events and sends the details to an Amazon SNS topic if the result of the scan is clean, skipped, or infected. </li> 
    <li>Amazon SNS sends the message to the topic subscriptions. Information sent in the message will contain the account ID, resource ID, status, volume, and result of the scan.</li> 
   </ol> 
   <h4>Systems Manager document</h4> 
   <p><a href="https://aws.amazon.com/systems-manager/" target="_blank" rel="noopener">AWS Systems Manager</a> is a secure, end-to-end management solution for resources on AWS and in multi-cloud and hybrid environments. The SSM document feature is used in this solution to provide an interactive way to provide inputs to the Lambda function that’s responsible for identifying EC2 instances to scan for malware.</p> 
   <h4>Identify Amazon EC2 targets Lambda</h4> 
   <p>The <span>GuardDutyMalwareOnDemandScanLambdaFunction</span> obtains the ARN of the associated EC2 instances that match the tag criteria provided in the Systems Manager document parameters. For the EC2 instances that are identified to match the tag criteria, an On-demand malware scan request is submitted by the <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_StartMalwareScan.html" target="_blank" rel="noopener">StartMalwareScan</a> API.</p> 
   <h4>Monitoring and reporting scan status</h4> 
   <p>The solution deploys an <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/logs/Subscriptions.html" target="_blank" rel="noopener">Amazon CloudWatch Logs subscription filter</a> that monitors for log file entries of on-demand malware scans which have a status of COMPLETED or SKIPPED. See <a href="https://docs.aws.amazon.com/guardduty/latest/ug/malware-protection-scans.html" target="_blank" rel="noopener">Monitoring scan status</a> for more information. After an on-demand malware scan finishes, the filter criteria are matched and the scan result is sent to its Lambda function destination <span>GuardDutyMalwareOnDemandNotificationLambda</span>. This Lambda function generates an Amazon SNS notification email that’s sent by the <span>GuardDutyMalwareOnDemandScanTopic</span> Amazon SNS topic.</p> 
   <h4>Deploy the solution</h4> 
   <p>Now that you understand how the on-demand malware scan solution works, you can deploy it to your own AWS account. The solution should be deployed in a single member account. This section walks you through the steps to deploy the solution and shows you how to verify that each of the key steps is working.</p> 
   <p>Step 1: Activate GuardDuty</p> 
   <p>The sample solution provided by this blog post requires that you activate GuardDuty in your AWS account. If this service isn’t activated in your account, learn more about the <a href="https://aws.amazon.com/guardduty/pricing/" target="_blank" rel="noopener">free trial and pricing </a>or this service, and follow the steps in <a href="https://aws.amazon.com/guardduty/getting-started/" target="_blank" rel="noopener">Getting started with Amazon GuardDuty</a> to set up the service and start monitoring your account.</p> 
   <blockquote> 
    <p><strong>Note:</strong> On-demand malware scanning is not part of the GuardDuty free trial.</p> 
   </blockquote> 
   <p>Step 2: Deploy the AWS CloudFormation template</p> 
   <p>For this step, deploy the template within the AWS account and AWS Region where you want to test this solution.</p> 
   <ol> 
    <li>Choose the following <strong>Launch Stack</strong> button to launch an <a href="https://aws.amazon.com/cloudformation/" target="_blank" rel="noopener">AWS CloudFormation</a> stack in your account. Use the AWS Management Console navigation bar to choose the Region you want to deploy the stack in. <p><a href="https://console.aws.amazon.com/cloudformation/home?#/stacks/create/review?templateURL=https:%2F%2Fs3.amazonaws.com%2Fawsiammedia%2Fpublic%2Fsample%2F1933-four-cases-guardduty-malware-protection-on-demand-scanning%2FOnDemandMalwareScanTags.yaml&stackName=gd-on-demand-malware-scan-tags" rel="noopener noreferrer" target="_blank"><img loading="lazy" src="https://d2908q01vomqb2.cloudfront.net/22d200f8670dbdb3e253a90eee5098477c95c23d/2019/06/05/launch-stack-button.png" alt="Launch Stack" width="190" height="36" class="aligncenter size-full wp-image-10149"></a></p> </li> 
    <li>Set the values for the following parameters based on how you want to use the solution: 
     <ul> 
      <li><strong>Create On-demand malware scan sample tester condition</strong> — Set the value to <span>True</span> to generate two EC2 instances to test the solution. These instances will serve as targets for an on-demand malware scan. One instance will contain <a href="https://www.eicar.org/download-anti-malware-testfile/" rel="noopener" target="_blank">EICAR malware sample files</a>, which contain strings that will be detected as malware but aren’t malicious. The other instance won’t contain malware.</li> 
      <li><strong>Tag key</strong> — Set the key that you want to be added to the test EC2 instances that are launched by this template.</li> 
      <li><strong>Tag value</strong> — Set the value that will be added to the test EC2 instances that are launched by this template.</li> 
      <li><strong>Latest Amazon Linux instance used for tester</strong> — Leave as is.</li> 
     </ul> </li> 
    <li>Scroll to the bottom of the <strong>Quick create stack</strong> screen and select the checkbox next to <strong>I acknowledge that AWS CloudFormation might create IAM resources</strong>.</li> 
    <li>Choose <strong>Create stack</strong>. The deployment of this CloudFormation stack will take 5–10 minutes.</li> 
   </ol> 
   <p>After the CloudFormation stack has been deployed successfully, you can proceed to reviewing and interacting with the deployed solution.</p> 
   <p>Step 3: Create an Amazon SNS topic subscription</p> 
   <p>The CloudFormation stack deploys an Amazon SNS topic to support sending notifications about initiated malware scans. For this post, you create an email subscription for receiving messages sent through the topic.</p> 
   <ol> 
    <li>In the <a href="https://console.aws.amazon.com/sns/home" target="_blank" rel="noopener">Amazon SNS console</a>, navigate to the Region that the stack was deployed in. On the Amazon SNS topics page, choose the created topic that includes the text <strong>GuardDutyMalwareOnDemandScanTopic</strong>. 
     <div id="attachment_32744" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32744" src="https://infracom.com.sg/wp-content/uploads/2023/12/img2.jpg" alt="Figure 2: Amazon SNS topic listing" width="740" class="size-full wp-image-32744"> 
      <p id="caption-attachment-32744" class="wp-caption-text">Figure 2: Amazon SNS topic listing</p> 
     </div> </li> 
    <li>On the <strong>Create subscription</strong> page, select <strong>Email</strong> for the <strong>Protocol</strong>, and for the <strong>Endpoint</strong> add a valid email address. Choose <strong>Create subscription</strong>. 
     <div id="attachment_32745" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32745" src="https://infracom.com.sg/wp-content/uploads/2023/12/img3.jpg" alt="Figure 3: Amazon SNS topic subscription" width="740" class="size-full wp-image-32745"> 
      <p id="caption-attachment-32745" class="wp-caption-text">Figure 3: Amazon SNS topic subscription</p> 
     </div> </li> 
   </ol> 
   <p>After the subscription has been created, an email notification is sent that must be acknowledged to start receiving malware scan notifications.</p> 
   <p>Amazon SNS subscriptions support many other types of subscription protocols besides email. You can review the list of <a href="https://docs.aws.amazon.com/sns/latest/dg/sns-event-destinations.html" target="_blank" rel="noopener">Amazon SNS event destinations </a>to learn more about other ways that Amazon SNS notifications can be consumed.</p> 
   <p>Step 4: Provide scan parameters in an SSM document</p> 
   <p>After the AWS CloudFormation template has been deployed, the SSM document will be in the Systems Manager console. For this solution, the <strong>TagKey</strong> and <strong>TagValue</strong> parameters must be entered before you can run the SSM document.</p> 
   <ol> 
    <li>In the <a href="https://console.aws.amazon.com/systems-manager/home" target="_blank" rel="noopener">Systems Manager console</a> choose the <strong>Documents</strong> link in the navigation pane.</li> 
    <li>On the SSM document page, select the <strong>Owned by me</strong> tab and choose <strong>GuardDutyMalwareOnDemandScan</strong>. If you have multiple documents, use the search bar to search for the <strong>GuardDutyMalwareOnDemandScan</strong> document. 
     <div id="attachment_32746" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32746" src="https://infracom.com.sg/wp-content/uploads/2023/12/img4.jpg" alt="Figure 4: Systems Manager documents listing" width="740" class="size-full wp-image-32746"> 
      <p id="caption-attachment-32746" class="wp-caption-text">Figure 4: Systems Manager documents listing</p> 
     </div> </li> 
    <li>In the page for the <strong>GuardDutyMalwareOnDemandScan</strong>, choose <strong>Execute automation</strong>.</li> 
    <li>In the <strong>Execute automation runbook page</strong>, follow the document description and input the required parameters. For this blog example, use the same tags as in the parameter section of the initial CloudFormation template. When you use this solution for your own instances, you can adjust these parameters to fit your tagging strategy. 
     <div id="attachment_32747" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32747" src="https://infracom.com.sg/wp-content/uploads/2023/12/img5-1.png" alt="Figure 5: Automation document details and input parameters" width="740" class="size-full wp-image-32747"> 
      <p id="caption-attachment-32747" class="wp-caption-text">Figure 5: Automation document details and input parameters</p> 
     </div> </li> 
    <li>Choose <strong>Execute</strong> to run the document. This takes you to the <strong>Execution detail</strong> page for this run of the automation document. In a few minutes the <strong>Execution status</strong> should update its overall status to <strong>Success</strong>. 
     <div id="attachment_32748" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32748" src="https://infracom.com.sg/wp-content/uploads/2023/12/img6-1.png" alt="Figure 6: Automation document execution detail" width="740" class="size-full wp-image-32748"> 
      <p id="caption-attachment-32748" class="wp-caption-text">Figure 6: Automation document execution detail</p> 
     </div> </li> 
   </ol> 
   <p>Step 5: Receive status messages about malware scans</p> 
   <ol> 
    <li>Upon completion of the scan, you should get a status of <strong>Success</strong> and email containing the results of the on-demand scan along with the scan IDs. The scan result includes a message for an INFECTED instance and one message for a CLEAN instance. For EC2 instances without a tag key, you will receive an Amazon SNS notification that says “No instances found that could be scanned.” Figure 7 shows an example email for an INFECTED instance. 
     <div id="attachment_32749" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32749" src="https://infracom.com.sg/wp-content/uploads/2023/12/img7-1.png" alt="Figure 7: Example email for an infected instance" width="740" class="size-full wp-image-32749"> 
      <p id="caption-attachment-32749" class="wp-caption-text">Figure 7: Example email for an infected instance</p> 
     </div> </li> 
   </ol> 
   <p>Step 6: Review scan results in GuardDuty</p> 
   <p>In addition to the emails that are sent about the status of a malware scan, the details about each malware scan and the findings for identified malware can be viewed in GuardDuty.</p> 
   <ol> 
    <li>In the <a href="https://console.aws.amazon.com/guardduty/home" target="_blank" rel="noopener">GuardDuty console</a>, select <strong>Malware scans</strong> from the left navigation pane. The <strong>Malware scan</strong> page provides you with the results of the scans performed. The scan results, for the instances scanned in this post, should match the email notifications received in the previous step. 
     <div id="attachment_32750" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32750" src="https://infracom.com.sg/wp-content/uploads/2023/12/img8.jpg" alt="Figure 8: GuardDuty malware scan summary" width="740" class="size-full wp-image-32750"> 
      <p id="caption-attachment-32750" class="wp-caption-text">Figure 8: GuardDuty malware scan summary</p> 
     </div> </li> 
    <li>You can select a scan to view its details. The details include the scan ID, the EC2 instance, scan type, scan result (which indicates if the scan is infected or clean), and the scan start time. 
     <div id="attachment_32751" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32751" src="https://infracom.com.sg/wp-content/uploads/2023/12/img9.jpg" alt="Figure 9: GuardDuty malware scan details" width="740" class="size-full wp-image-32751"> 
      <p id="caption-attachment-32751" class="wp-caption-text">Figure 9: GuardDuty malware scan details</p> 
     </div> </li> 
    <li>In the details for the infected instance, choose <strong>Click to see malware findings</strong>. This takes you to the GuardDuty findings page with a filter for the specific malware scan. 
     <div id="attachment_32752" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32752" src="https://infracom.com.sg/wp-content/uploads/2023/12/img10.jpg" alt="Figure 10: GuardDuty malware findings" width="740" class="size-full wp-image-32752"> 
      <p id="caption-attachment-32752" class="wp-caption-text">Figure 10: GuardDuty malware findings</p> 
     </div> </li> 
    <li>Select the finding for the <strong>MalicousFile</strong> finding to bring up details about the finding. Details of the <strong>Execution:EC2/Malicious</strong> file finding include the severity label, the overview of the finding, and the threats detected. We recommend that you treat high severity findings as high priority and immediately investigate and, if necessary, take steps to prevent unauthorized use of your resources. 
     <div id="attachment_32753" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32753" src="https://infracom.com.sg/wp-content/uploads/2023/12/img11.png" alt="Figure 11: GuardDuty malware finding details" width="740" class="size-full wp-image-32753"> 
      <p id="caption-attachment-32753" class="wp-caption-text">Figure 11: GuardDuty malware finding details</p> 
     </div> </li> 
   </ol> 
   <h3>Use case 2 – Initiating scans on a schedule</h3> 
   <p>This use case walks through how to schedule malware scans. Scheduled malware scanning might be required for particularly sensitive workloads. After an environment is up and running, it’s important to establish a baseline to be able to quickly identify EC2 instances that have been infected with malware. A scheduled malware scan helps you proactively identify malware on key resources and that maintain the desired security baseline.</p> 
   <h4>Solution architecture</h4> 
   <div id="attachment_32790" class="wp-caption aligncenter"> 
    <img aria-describedby="caption-attachment-32790" loading="lazy" src="https://infracom.com.sg/wp-content/uploads/2023/12/img12_v3.jpg" alt="Figure 12: Scheduled malware scan architecture" width="769" height="319" class="size-full wp-image-32790"> 
    <p id="caption-attachment-32790" class="wp-caption-text">Figure 12: Scheduled malware scan architecture</p> 
   </div> 
   <p>The architecture of this use case is shown in figure 12. The main difference between this and the architecture of use case 1 is the presence of a scheduler that controls submitting the <span>GuardDutyMalwareOnDemandObtainScanLambdaFunction</span> function to identify the EC2 instances to be scanned. This architecture uses <a href="https://docs.aws.amazon.com/scheduler/latest/UserGuide/what-is-scheduler.html" target="_blank" rel="noopener">Amazon EventBridge Scheduler</a> to set up flexible time windows for when a scheduled scan should be performed.</p> 
   <p>EventBridge Scheduler is a serverless scheduler that you can use to create, run, and manage tasks from a central, managed service. With EventBridge Scheduler, you can create schedules using cron and rate expressions for recurring patterns or configure one-time invocations. You can set up flexible time windows for delivery, define retry limits, and set the maximum retention time for failed invocations.</p> 
   <h4>Deploying the solution</h4> 
   <p>Step 1: Deploy the AWS CloudFormation template</p> 
   <p>For this step, you deploy the template within the AWS account and Region where you want to test the solution.</p> 
   <ol> 
    <li>Choose the following <strong>Launch Stack</strong> button to launch an <a href="https://aws.amazon.com/cloudformation/" target="_blank" rel="noopener">AWS CloudFormation</a> stack in your account. Use the AWS Management Console navigation bar to choose the Region you want to deploy the stack in. <p><a href="https://console.aws.amazon.com/cloudformation/home?#/stacks/create/review?templateURL=https:%2F%2Fs3.amazonaws.com%2Fawsiammedia%2Fpublic%2Fsample%2F1933-four-cases-guardduty-malware-protection-on-demand-scanning%2FOnDemandMalwareScheduledScan.yaml&stackName=gd-on-demand-malware-scan-schedule" rel="noopener noreferrer" target="_blank"><img loading="lazy" src="https://d2908q01vomqb2.cloudfront.net/22d200f8670dbdb3e253a90eee5098477c95c23d/2019/06/05/launch-stack-button.png" alt="Launch Stack" width="190" height="36" class="aligncenter size-full wp-image-10149"></a></p> </li> 
    <li>Set the values for the following parameters based on how you want to use the solution: 
     <ul> 
      <li>On-demand malware scan sample tester — Amazon EC2 configuration 
       <ul> 
        <li><strong>Create On-demand malware scan sample tester condition</strong> — Set the value to <span>True</span> to generate two EC2 instances to test the solution. These instances will serve as targets for an on-demand malware scan. One instance will contain <a href="https://www.eicar.org/download-anti-malware-testfile/" rel="noopener" target="_blank">EICAR malware sample files</a>, which contain strings that will be detected as malware but aren’t malicious. The other instance won’t contain malware.</li> 
        <li><strong>Tag key</strong> — Set the key that you want to be added to the test EC2 instances that are launched by this template.</li> 
        <li><strong>Tag Value</strong> — Set the value that will be added to the test EC2 instances that are launched by this template.</li> 
        <li><strong>Latest Amazon Linux instance used for tester</strong> — Leave as is.</li> 
       </ul> </li> 
      <li>Scheduled malware scan parameters 
       <ul> 
        <li><strong>Tag keys and values parameter</strong> — Enter the tag key-value pairs that the scheduled scan will look for. If you populated the tag key and tag value parameters for the sample EC2 instance, then that should be one of the values in this parameter to ensure that the test instances are scanned.</li> 
        <li><strong>EC2 instances ARNs to scan</strong> — [Optional] EC2 instances ID list that should be scanned when the scheduled scan runs.</li> 
        <li><strong>EC2 instances state</strong> — Enter the state the EC2 instances can be in when selecting instances to scan.</li> 
       </ul> </li> 
      <li>AWS Scheduler parameters 
       <ul> 
        <li><strong>Rate for the schedule scan to be run</strong> — defines how frequently the schedule should run. Valid options are <strong>minutes</strong>, <strong>hours</strong>, or <strong>days</strong>.</li> 
        <li><strong>First time scheduled scan will run</strong> — Enter the day and time, in UTC format, when the first scheduled scan should run.</li> 
        <li><strong>Time zone</strong> — Enter the time zone that the schedule start time should be applied to. Here is a list of <a href="https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html#time-zones" target="_blank" rel="noopener">valid time zone values</a>.</li> 
       </ul> </li> 
     </ul> </li> 
    <li>Scroll to the bottom of the <strong>Quick create stack </strong>screen and select the checkbox for <strong>I acknowledge that AWS CloudFormation might create IAM resources</strong>.</li> 
    <li>Choose <strong>Create stack</strong>. The deployment of this CloudFormation stack will take 5–10 minutes.</li> 
   </ol> 
   <p>After the CloudFormation stack has been deployed successfully, you can review and interact with the deployed solution.</p> 
   <p>Step 2: Amazon SNS topic subscription</p> 
   <p>As in use case 1, this solution supports using Amazon SNS to send a notification with the results of a malware scan. See the Amazon SNS subscription set up steps in use case 1 for guidance on setting up a subscription for receiving the results. For this use case, the naming convention of the Amazon SNS topic will include <strong>GuardDutyMalwareOnDemandScheduledScanTopic</strong>.</p> 
   <p>Step 3: Review scheduled scan configuration</p> 
   <p>For this use case, the parameters that were filled in during submission of the CloudFormation template build out an initial schedule for scanning EC2 instances. The following details describe the various components of the schedule and where you can make changes to influence how the schedule runs in the future.</p> 
   <ol> 
    <li>In the console, go to the <a href="https://console.aws.amazon.com/events/home" target="_blank" rel="noopener">EventBridge</a> service. On the left side of the console under <strong>Scheduler</strong>, select<strong> Schedules</strong>. Select the scheduler that was created as part of the CloudFormation deployment. 
     <div id="attachment_32755" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32755" src="https://infracom.com.sg/wp-content/uploads/2023/12/img13.jpg" alt="Figure 13: List of EventBridge schedules" width="740" class="size-full wp-image-32755"> 
      <p id="caption-attachment-32755" class="wp-caption-text">Figure 13: List of EventBridge schedules</p> 
     </div> </li> 
    <li>The <strong>Specify schedule detail</strong> page is where you can set the appropriate <strong>Timezone</strong>, <strong>Start date and time</strong>. In this walkthrough, this information for the schedule was provided when launching the CloudFormation template. 
     <div id="attachment_32756" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32756" src="https://infracom.com.sg/wp-content/uploads/2023/12/img14.jpg" alt="Figure 14: EventBridge schedule detail" width="740" class="size-full wp-image-32756"> 
      <p id="caption-attachment-32756" class="wp-caption-text">Figure 14: EventBridge schedule detail</p> 
     </div> </li> 
    <li>On the <strong>Invoke</strong> page, the JSON will include the instance state, tags, and IDs, as well as the tags associated with the instance that were filled in during the deployment of the CloudFormation template. Make additional changes, as needed, and choose <strong>Next</strong>. 
     <div id="attachment_32757" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32757" src="https://infracom.com.sg/wp-content/uploads/2023/12/img15.png" alt="Figure 15: EventBridge schedule Lambda invoke parameters" width="740" class="size-full wp-image-32757"> 
      <p id="caption-attachment-32757" class="wp-caption-text">Figure 15: EventBridge schedule Lambda invoke parameters</p> 
     </div> </li> 
    <li>Review and save schedule. 
     <div id="attachment_32758" class="wp-caption aligncenter"> 
      <img aria-describedby="caption-attachment-32758" src="https://infracom.com.sg/wp-content/uploads/2023/12/img16.jpg" alt="Figure 16: EventBridge schedule summary" width="740" class="size-full wp-image-32758"> 
      <p id="caption-attachment-32758" class="wp-caption-text">Figure 16: EventBridge schedule summary</p> 
     </div> </li> 
   </ol> 
   <p>Step 4: Review malware scan results from GuardDuty</p> 
   <p>After a scheduled scan has been performed, the scan results will be available in the GuardDuty Malware console and generate a GuardDuty finding if malware is found. The output emails and access to the results in GuardDuty is the same as explained in use case 1.</p> 
   <h3>Use case 3 – Initiating scans to support a security investigation</h3> 
   <p>You might receive security signals or events about infrastructure and applications from multiple tools or sources in addition to Amazon GuardDuty. Investigations that arise from these security signals necessitate malware scans on specific EC2 instances that might be a source or target of a security event. With GuardDuty On-demand malware scan, you can incorporate a scan as part of your investigation workflow and use the output of the scan to drive the next steps in your investigation.</p> 
   <p>From the GuardDuty delegated administrator account, you can initiate a malware scan against EC2 instances in a member account which is associated with the administrator account. This enables you to initiate your malware scans from a centralized location and without the need for access to the account where the EC2 instance is deployed. Initiating a malware scan for an EC2 instance uses the same <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_StartMalwareScan.html" target="_blank" rel="noopener">StartMalwareScan</a> API described in the other use cases of this post. Depending on the tools that you’re using to support your investigations, you can also use the GuardDuty console to initiate a malware scan.</p> 
   <p>After a malware scan is run, malware findings will be available in the delegated administrator and member accounts, allowing you to get details and orchestrate the next steps in your investigation from a centralized location.</p> 
   <p>Figure 17 is an example of how a security investigation, using an on-demand malware scan, might function.</p> 
   <div id="attachment_32759" class="wp-caption aligncenter"> 
    <img aria-describedby="caption-attachment-32759" src="https://infracom.com.sg/wp-content/uploads/2023/12/img17.jpg" alt="Figure 17: Example security investigation using GuardDuty On-demand malware scans" width="740" class="size-full wp-image-32759"> 
    <p id="caption-attachment-32759" class="wp-caption-text">Figure 17: Example security investigation using GuardDuty On-demand malware scans</p> 
   </div> 
   <p>If you’re using GuardDuty as your main source of security findings for EC2 instances, the GuardDuty-initiated malware scan feature can also help facilitate an investigation workflow. With GuardDuty initiated malware scans, you can reduce the time between when an EC2 instance finding is created and when a malware scan of the instance is initiated, making the scan results available to your investigation workflows faster, helping you develop a remediation plan sooner.</p> 
   <h3>Use case 4 – Malware scanning in a deployment pipeline</h3> 
   <p>If you’re using deployment pipelines to build and deploy your infrastructure and applications, you want to make sure that what you’re deploying is secure. In cases where deployments involve third-party software, you want to be sure that the software is free of malware before deploying into environments where the malware could be harmful. This applies to software deployed directly onto an EC2 instance as well as containers that are deployed on an EC2 instance. In this case, you can use the on-demand malware scan in an EC2 instance in a secure test environment prior to deploying it in production. You can use the techniques described earlier in this post to design your deployment pipelines with steps that call the <a href="https://docs.aws.amazon.com/guardduty/latest/APIReference/API_StartMalwareScan.html" target="_blank" rel="noopener">StartMalwareScan</a> API and then check the results of the scan. Based on the scan results, you can decide if the deployment should continue or be stopped due to detected malware.</p> 
   <p>Running these scans before deployment into production can help to ensure the integrity of your applications and data and increase confidence that the production environment is free of significant security issues.</p> 
   <p>Figure 18 is an example of how malware scanning might look in a deployment pipeline for a containerized application.</p> 
   <div id="attachment_32760" class="wp-caption aligncenter"> 
    <img aria-describedby="caption-attachment-32760" src="https://infracom.com.sg/wp-content/uploads/2023/12/img18.png" alt="Figure 18: Example deployment pipeline incorporating GuardDuty On-demand malware scan" width="740" class="size-full wp-image-32760"> 
    <p id="caption-attachment-32760" class="wp-caption-text">Figure 18: Example deployment pipeline incorporating GuardDuty On-demand malware scan</p> 
   </div> 
   <p>In the preceding example the following steps are represented:</p> 
   <ol> 
    <li>A container image is built as part of a deployment pipeline.</li> 
    <li>The container image is deployed into a test environment.</li> 
    <li>From the test environment, a GuardDuty On-demand malware scan is initiated against the EC2 instance where the container image has been deployed.</li> 
    <li>After the malware scan is complete, the results of the scan are evaluated.</li> 
    <li>A decision is made on allowing the image to be deployed into production. If the image is approved, it’s deployed to production. If it’s rejected, a message is sent back to the owner of the container image for remediation of the identified malware.</li> 
   </ol> 
   <h2>Conclusion</h2> 
   <p>Scanning for malware on your EC2 instances is key to maintaining that your instances are free of malware before they’re deployed to production, and if malware does find its way onto a deployed instance, it’s quickly identified so that it can be investigated and remediated.</p> 
   <p>This post outlines four use cases you can use with the On-demand malware scan feature: Scan based on tag, scan on a schedule, scan as part of an investigation, and scan in a deployment pipeline. The examples provided in this post are intended to provide a foundation that you can build upon to meet your specific use cases. You can use the provided code examples and sample architectures to enhance your operational and deployment processes.</p> 
   <p>To learn more about GuardDuty and its malware protection features, see the <a href="https://docs.aws.amazon.com/guardduty/latest/ug/malware-protection.html" target="_blank" rel="noopener">feature documentation</a> and the service <a href="https://docs.aws.amazon.com/guardduty/latest/ug/malware-protection-limitations.html" target="_blank" rel="noopener">quotas for Malware protection</a>.</p> 
   <p>If you have feedback about this post, submit comments in the Comments section below. If you have questions about this post, start a new thread on the <a href="https://repost.aws/topics/TAEEfW2o7QS4SOLeZqACq9jA/security-identity-compliance%3Fsc_ichannel=ha&sc_ilang=en&sc_isite=repost&sc_iplace=hp&sc_icontent=TAEEfW2o7QS4SOLeZqACq9jA&sc_ipos=0" rel="noopener" target="_blank">AWS Security, Identity, &amp; Compliance re:Post</a> or <a href="https://console.aws.amazon.com/support/home" rel="noopener" target="_blank">contact AWS Support</a>.</p> 
   <p><strong>Want more AWS Security news? Follow us on <a title="Twitter" href="https://twitter.com/AWSsecurityinfo" target="_blank" rel="noopener noreferrer">Twitter</a></strong>.</p> 

   <!-- '"` -->