How To

Mapping your AWS attack surface

To improve your application security program, chart the attack surface of your cloud’s network perimeter using Steampipe.

Chris Farris
7 min. read - Dec 19, 2022
To improve your application security program, chart the attack surface of your cloud’s network perimeter using Steampipe.

What is a cloud attack surface?

Traditional IT security protects the network perimeter with firewalls, vulnerability scanners and patching processes. Discovering the attack surface of your network perimeter was a simple matter of knowing your public IP range and scanning it from an external host. With the introduction of public cloud technologies, the attack surface expanded to include cloud provider’s APIs. "Identity is the new perimeter" became the new mantra.

The old network perimeter still exists, of course, and it has evolved. No longer are all the IP addresses that make up your perimeter assigned to your company. In the cloud, your network perimeter is part of the cloud provider’s IP space. And, cloud-provider-managed resources provide a direct path to your application code. This combination of cloud-provider IP addresses assigned to you, and the URLs of cloud-provider resources that lead to your application and data, comprise your cloud’s network perimeter and define part of the cloud attack surface.

An Organization must monitor and understand the network perimeter of their cloud estate. Resources comprising the externally facing network components of your cloud attack surface can be broadly grouped into IP addresses, hostnames, and URLs. In this blog post, we will provide step-by-step instructions for mapping the network aspects of the cloud attack surface using Steampipe.

Enumerate IP Addresses using Steampipe

For IP Addresses, we'll look mainly at the Elastic Network Interfaces. While other resources like CloudFront, S3, and API Gateway also leverage IP addresses, the network security protections of those services are the cloud provider's responsibility.

This query will download a list of all public IP addresses tied to the customer’s VPC.

eni.association_public_ip AS public_ip
aws_ec2_network_interface AS eni
eni.association_public_ip is not Null;

Enumerate Hostnames using Steampipe

To determine the DNS Hostnames used as part of your cloud perimeter, Steampipe can query all of the A records and CNAMEs in your Route 53 Hosted Zones. A records point directly to IP addresses under your control. CNAMEs are references that can point to hosts or other cloud-provider-managed resources. In either case, you need to understand what exists in your environment.

To query all of the hostnames that point to CNAME and A Records in your Route 53 Hosted Zones, use this SQL query:

select as hostname,
jsonb_array_elements_text(records) as resource_record
aws_route53_zone as z,
aws_route53_record as r
where r.zone_id =
and (type LIKE 'A' OR type LIKE 'CNAME')
and z.private_zone=false
and jsonb_pretty(records) not like '%dkim%'
and jsonb_pretty(records) not like '';

Review the list of IP addresses returned, and if permitted by the terms of service, scan these hostnames for exposed ports and services using nmap or Nessus.

Note: The above query excludes private DNS for VPCs z.private_zone=false and excludes common CNAMEs needed for ACM and email validation.

Enumerate the URLs using Steampipe

A number of AWS services, including CloudFront, S3, API Gateway, and AWS Lambda, produce URLs that can be vulnerable. For example, S3 Buckets exist as URLs on the public internet and can be accessed if the bucket is not properly secured. To get a list of all of the URLs for the public buckets in your cloud environment, you can use this query:

'https://' || name || '.s3.' || region || '' as url
bucket_policy_is_public is True;

To request all of the URLs from CloudFront, this SQL query will return both the distribution name and any aliases that are part of that distribution:

'https://' || domain_name as url
'https://' || jsonb_array_elements_text(aliases -> 'Items') as url

API Gateways themselves do not have URLs, but when the customer creates a "stage" a URL is created. To get a list of all the API Gateway v2 URLs, this SQL query can be used:

select 'https://' || api_id || '.execute-api.' || region || '' || stage_name as url
from aws_api_gatewayv2_stage;

API Gateway URLs typically have the following format:


where [api-id] is the ID of the API Gateway API, [region] is the AWS region where the API is deployed, [stage] is the stage of the API (such as "prod" or "dev"), and [path] is the path to the specific Lambda function being accessed. For example, the URL "" could be used to invoke a Lambda function named "hello" that is associated with the API Gateway API with ID "abc123", and is deployed in the "us-east-1" region.

Lambda URLs are a new feature of AWS Lambda, released in April of 2022. AWS allows the creation of Lambda URLs that do not require authentication. Therefore, these Lambda URLs are part of your cloud attack surface. To find the Lambda URLs in your environment, you can use this Steampipe query:

select url_config ->> 'FunctionUrl' as url
from aws_lambda_function
where url_config is not Null;

You can pull all these together using SQL UNION queries as demonstrated by this query. You can run it like:

Steampipe CLI
steampipe query all_urls.sql

| url                                                                   | type                          |
|   | application_load_balancer     |
| | application_load_balancer     |
|     | api_gateway                   |
|    | api_gateway                   |
|                                 | cloudfront_distribution       |
|                                 | cloudfront_distribution       |
|                                 | cloudfront_distribution       |
|                                 | cloudfront_distribution       |
|                                        | cloudfront_distribution_alias |
|                                       | cloudfront_distribution_alias |
| | lambda_url                    |
|                      | s3_bucket_url                 |
|                       | s3_bucket_url                 |
|                       | s3_bucket_url                 |
|        | s3_bucket_url                 |
|                      | s3_bucket_url                 |
|                 | s3_bucket_url                 |
Time: 115.3s. Rows fetched: 215. Hydrate calls: 317.

Empowered with a list of all the exposed URLs in your organization, you can then set up a process to scan these using a number of web-focused Dynamic Application Security Testing (DAST) tools and scanners such as Zed Attack Proxy, dirsearch (Web path scanner), Aquatone, and Nikto2. The OWASP® Foundation maintains a full list of scanning tools that could be used.

If you are a larger organization that runs a bug bounty program, scanning your URLs for these low-hanging fruit is a quick and easy way to avoid payouts to researchers who use the same tools.


Steampipe is a powerful way to find and enumerate your AWS IP addresses, hostnames, and URLs. Follow the steps outlined here to gather the information needed to define and manage the network component of your cloud attack surface, ensure the security and integrity of your data and applications, and prevent unauthorized access to your network resources. Of course everyone's situation is unique, and you may find a solution that works better for you. If so, please let us know: we love to learn from our community!