Export a Software Bill of Materials using Amazon Inspector
Amazon Inspector is an automated vulnerability management service that continually scans Amazon Web Services (AWS) workloads for software vulnerabilities and unintended network exposure. Amazon Inspector has expanded capability that allows customers to export a consolidated Software Bill of Materials (SBOM) for supported Amazon Inspector monitored resources, excluding Windows EC2 instances.
<p>Customers have asked us to provide additional software application inventory collected from Amazon Inspector monitored resources. This makes it possible to precisely track the software supply chain and security threats that might be connected to the results of the current Amazon Inspector. Generating an SBOM gives you critical security information that offers you visibility into specifics about your software supply chain, including the packages you use the most frequently and the related vulnerabilities that might affect your whole company.</p>
<p>This blog post includes steps that you can follow to export a consolidated SBOM for the resources monitored by Amazon Inspector across your organization in industry standard formats, including <a href="https://docs.aws.amazon.com/inspector/latest/user/sbom-export.html#sbom-formats" target="_blank" rel="noopener">CycloneDx</a> and <a href="https://docs.aws.amazon.com/inspector/latest/user/sbom-export.html#sbom-formats" target="_blank" rel="noopener">SPDX</a>. It also shares insights and approaches for analyzing SBOM artifacts using <a href="https://aws.amazon.com/athena" target="_blank" rel="noopener">Amazon Athena</a>.</p>
<h2>Overview</h2>
<p>An SBOM is defined as a nested inventory with a list of ingredients that make up software components. Security teams can export a consolidated SBOM to <a href="https://aws.amazon.com/s3/" target="_blank" rel="noopener">Amazon Simple Storage Service (Amazon S3)</a> for an entire organization from the resource coverage page in the AWS Management Console for Amazon Inspector. </p>
<p>Using <a href="https://cyclonedx.org/" target="_blank" rel="noopener">CycloneDx </a>and <a href="https://spdx.dev/" target="_blank" rel="noopener">SPDX</a> industry standard formats, you can use insights gained from an SBOM to make decisions such as which software packages need to be updated across your organization or deprecated, if there’s no other option. Individual application or security engineers can also export an SBOM for a single resource or group of resources by applying filters for a specific account, resource type, resource ID, tags, or a combination of these as a part of the SBOM export workflow in the console or application programming interfaces.</p>
<h2>Exporting SBOMs</h2>
<p>To export Amazon Inspector SBOM reports to an S3 bucket, you must create and configure a bucket in the AWS Region where the SBOM reports are to be exported. You must <a href="https://docs.aws.amazon.com/inspector/latest/user/findings-managing-exporting-reports.html#findings-managing-exporting-bucket-perms" target="_blank" rel="noopener">configure your bucket permissions</a> to allow only Amazon Inspector to put new objects into the bucket. This prevents other AWS services and users from adding objects to the bucket.</p>
<p>Each SBOM report is stored in an S3 bucket and has the name <span>Cyclonedx_1_4 (Json)</span> or <span>Spdx_2_3-compatible (Json)</span>, depending on the export format that you specify. You can also use <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/enable-event-notifications.html" target="_blank" rel="noopener">S3 event notifications</a> to alert different operational teams that new SBOM reports have been exported.</p>
<p>Amazon Inspector requires that you use an <a href="https://aws.amazon.com/kms/" target="_blank" rel="noopener">AWS Key Management Service (AWS KMS)</a> key to encrypt the SBOM report. The key must be a customer managed, symmetric KMS encryption key and must be in the same Region as the S3 bucket that you configured to store the SBOM report. The new KMS key for the SBOM report requires a <a href="https://docs.aws.amazon.com/inspector/latest/user/findings-managing-exporting-reports.html#findings-managing-exporting-KMS" target="_blank" rel="noopener">key policy</a> to be configured to grant permissions for Amazon Inspector to use the key. (Shown in Figure 1.)</p>
<div id="attachment_33129" class="wp-caption aligncenter">
<a href="https://infracom.com.sg/wp-content/uploads/2024/01/img1-1.png" rel="noopener" target="_blank"><img aria-describedby="caption-attachment-33129" src="https://infracom.com.sg/wp-content/uploads/2024/01/img1-1.png" alt="Figure 1: Amazon Inspector SBOM export" width="780" class="size-full wp-image-33129"></a>
<p id="caption-attachment-33129" class="wp-caption-text">Figure 1: Amazon Inspector SBOM export</p>
</div>
<h2>Deploy prerequisites</h2>
<p>The <a href="https://aws.amazon.com/cloudformation" target="_blank" rel="noopener">AWS CloudFormation</a> template provided creates an S3 bucket with an associated bucket policy to enable Amazon Inspector to export SBOM report objects into the bucket. The template also creates a new KMS key to be used for SBOM report exports and grants the Amazon Inspector service permissions to use the key.</p>
<p>The export can be initiated from the <a href="https://docs.aws.amazon.com/inspector/latest/user/designating-admin.html" target="_blank" rel="noopener">AWS Inspector delegated administrator account</a> or the AWS Inspector administrator account itself. This way, the S3 bucket contains reports for the AWS Inspector member accounts. To export the SBOM reports from Amazon Inspector deployed in the same Region, make sure the CloudFormation template is deployed within the AWS account and Region. If you enabled AWS Inspector in multiple accounts, the CloudFormation stack must be deployed in each Region where AWS Inspector is enabled.</p>
<h3>To deploy the CloudFormation template</h3>
<ol>
<li>Choose the following <strong>Launch Stack</strong> button to launch a CloudFormation stack in your account. <p><a href="https://console.aws.amazon.com/cloudformation/home?region=us-east-1#/stacks/new?stackName=SBOM&templateURL=https://s3.amazonaws.com/awsiammedia/public/sample/V1052247744-export-a-software-bill-of-materials/SBOM.yml" 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>Review the stack name and the parameters (<span>MyKMSKeyName</span> and <span>MyS3BucketName</span>) for the template. Note that the S3 bucket name must be unique.</li>
<li>Choose <strong>Next</strong> and confirm the stack options.</li>
<li>Go to the next page and choose <strong>Submit</strong>. The deployment of the CloudFormation stack will take 1–2 minutes. </li>
</ol>
<p>After the CloudFormation stack has deployed successfully, you can use the S3 bucket and KMS key created by the stack to export SBOM reports.</p>
<h2>Export SBOM reports</h2>
<p>After setup is complete, you can export SBOM reports to an S3 bucket.</p>
<h3>To export SBOM reports from the console</h3>
<ol>
<li>Navigate to the AWS Inspector console in the same Region where the S3 bucket and KMS key were created.</li>
<li>Select <strong>Export SBOMs</strong> from the navigation pane.</li>
<li><a href="https://docs.aws.amazon.com/inspector/latest/user/sbom-export.html#sbom-filters" target="_blank" rel="noopener">Add filters</a> to create reports for specific subsets of resources. The SBOMs for all active, supported resources are exported if you don’t supply a filter.</li>
<li>Select the export file type you want. Options are <strong>Cyclonedx_1_4 (Json)</strong> or <strong>Spdx_2_3-compatible (Json)</strong>.</li>
<li>Enter the S3 bucket URI from the output section of the CloudFormation template and enter the KMS key that was created. </li>
<li>Choose <strong>Export</strong>. It can take 3–5 minutes to complete depending on the number of artifacts to be exported.</li>
</ol>
<div id="attachment_33130" class="wp-caption aligncenter">
<img aria-describedby="caption-attachment-33130" src="https://infracom.com.sg/wp-content/uploads/2024/01/img2-1.png" alt="Figure 2: SBOM export configuration" width="780" class="size-full wp-image-33130">
<p id="caption-attachment-33130" class="wp-caption-text">Figure 2: SBOM export configuration</p>
</div>
<p>When complete, all SBOM artifacts will be in the S3 bucket. This gives you the flexibility to download the SBOM artifacts from the S3 bucket, or you can use <a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/selecting-content-from-objects.html" target="_blank" rel="noopener">Amazon S3 Select</a> to retrieve a subset of data from an object using standard SQL queries.</p>
<div id="attachment_33131" class="wp-caption aligncenter">
<img aria-describedby="caption-attachment-33131" src="https://infracom.com.sg/wp-content/uploads/2024/01/img3-1.png" alt="Figure 3: Amazon S3 Select" width="600" class="size-full wp-image-33131">
<p id="caption-attachment-33131" class="wp-caption-text">Figure 3: Amazon S3 Select</p>
</div>
<p>You can also run advanced queries using <a href="https://aws.amazon.com/athena" target="_blank" rel="noopener">Amazon Athena</a> or create dashboards using <a href="https://quicksight" target="_blank" rel="noopener">Amazon QuickSight</a> to gain insights and map trends.</p>
<h2>Querying and visualization</h2>
<p>With <a href="https://aws.amazon.com/athena/" target="_blank" rel="noopener">Athena</a>, you can run SQL queries on raw data that’s stored in S3 buckets. The Amazon Inspector reports are exported to an S3 bucket, and you can query the data and create tables by following the <a href="https://docs.aws.amazon.com/glue/latest/dg/tutorial-add-crawler.html" target="_blank" rel="noopener">Adding an AWS Glue crawler</a> tutorial.</p>
<p>To enable AWS Glue to crawl the S3 data, you must add the role as described in the AWS Glue crawler tutorial to the AWS KMS key permissions so that AWS Glue can decrypt the S3 data.</p>
<p>The following is an example policy JSON that you can update for your use case. Make sure to replace the AWS account ID <span></span> and S3 bucket name <span></span> with your own information. </p>
<div class="hide-language">
<pre class="unlimited-height-code"><code class="lang-text">{
"Sid": "Allow the AWS Glue crawler usage of the KMS key",
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::<span></span>:role/service-role/AWSGlueServiceRole-S3InspectorSBOMReports"
},
"Action": [
"kms:Decrypt",
"kms:GenerateDataKey*"
],
"Resource": "arn:aws:s3:::<span></span>"
},
<blockquote>
<strong>Note:</strong> The role created for AWS Glue also needs permission to read the S3 bucket where the reports are exported for creating the crawlers. The AWS Glue <a href="https://aws.amazon.com/iam" target="_blank" rel="noopener">AWS Identity and Access Management (IAM)</a> role allows the crawler to run and access your Amazon S3 data stores.</p>
</blockquote>
<p>After an AWS Glue Data Catalog has been built, you can run the crawler on a scheduled basis to help ensure that it’s kept up to date with the latest Amazon Inspector SBOM manifests as they’re exported into the S3 bucket.</p>
<p>You can further navigate to the added table using the crawler and view the data in Athena. Using Athena, you can run queries against the Amazon Inspector reports to generate output data relevant to your environment. The schema for the generated SBOM report is different depending on the specific resources (<a href="https://aws.amazon.com/ec2" target="_blank" rel="noopener">Amazon Elastic Compute Cloud (Amazon EC2</a>), <a href="https://aws.amazon.com/lambda" target="_blank" rel="noopener">AWS Lambda</a>, <a href="https://aws.amazon.com/ecr" target="_blank" rel="noopener">Amazon Elastic Container Registry (Amazon ECR)</a>) in the reports. So, depending on the schema, you can create a SQL Athena query to fetch information from the reports.</p>
<p>The following is an Athena example query that identifies the top 10 vulnerabilities for resources in an SBOM report. You can use the common vulnerability and exposures (CVE) IDs from the report to list the individual components affected by the CVEs.</p>
<div class="hide-language">
<pre class="unlimited-height-code"><code class="lang-text">SELECT
account,
vuln.id as vuln_id,
count() as vuln_count
FROM
,
UNNEST(Inset_table_name.vulnerabilities)as t(vuln)
GROUP BY
account,
vuln.id
ORDER BY
vuln_count DESC
LIMIT 10;
The following Athena example query can be used to identify the top 10 operating systems (OS) along with the resource types and their count.
If you have a package that has a critical vulnerability and you need to know if the package is used as a primary package or adds a dependency, you can use the following Athena sample query to check for the package in your application. In this example, I’m searching for a Log4j package. The result returns account ID, resource type, package_name, and package_count.
Note: The sample Athena queries must be customized depending on the schema of the SBOM export report.
To further extend this solution, you can use Amazon QuickSight to produce dashboards to visualize the data by connecting to the AWS Glue table.
Conclusion
The new SBOM generation capabilities in Amazon Inspector improve visibility into the software supply chain by providing a comprehensive list of software packages across multiple levels of dependencies. You can also use SBOMs to monitor the licensing information for each of the software packages and identify potential licensing violations in your organization, helping you avoid potential legal risks.
The most important benefit of SBOM export is to help you comply with industry regulations and standards. By providing an industry-standard format (SPDX and CycloneDX) and enabling easy integration with other tools, systems, or services (such as Nexus IQ and WhiteSource), you can streamline the incident response processes, improve the accuracy and speed of security assessments, and adhere to compliance with regulatory requirements.
In addition to these benefits, the SBOM export feature provides a comprehensive and accurate understanding of the OS packages and software libraries found in their resources, further enhancing your ability to adhere to industry regulations and standards.
If you have feedback about this post, submit comments in the Comments section below. If you have any question/query in regard to information shared in this post, start a new thread on the AWS IAM Identity Center re:Post or contact AWS Support.
Want more AWS Security news? Follow us on Twitter.
<!-- '"` -->