

# Creating a penetration test

A penetration test belongs to an environment. It uses the target domains and resources of that environment. Each time you start the test, AWS Continuum creates a run that records the activity and findings.

## Prerequisites
<a name="pt-creating-test-prerequisites"></a>

Before you create a penetration test, make sure that you have the following:
+ An environment with a service role
+ At least one verified target domain in the environment
+ (Optional) Sign-in credentials for a test account in your application

To check the environment, see [Checking that the environment is ready](pt-getting-started.md#pt-getting-started-readiness).

## Creating the test
<a name="pt-creating-test-create"></a>

The wizard has five pages. When you choose **Save & Next**, AWS Continuum saves your progress as a draft. To return to a draft, choose **Resume setup** on the **Create penetration test** page, or **Continue setup** on the test's page.

**To create a penetration test**

1. Open the AWS Continuum console at [https://console.aws.amazon.com/continuum/](https://console.aws.amazon.com/continuum/).

1. In the navigation pane, under **Penetration testing**, choose **Overview**.

1. Choose the environment name, and then choose **Create penetration test**.

1. On the **Penetration test details** page, enter the name, scope, and target URLs. Then choose **Save & Next**.

   For details, see [Penetration test details](#pt-creating-test-details).

1. On the **VPC Resources**, **Credentials**, and **Network configuration** pages, enter any settings that the test needs. Choose **Save & Next** after each page.

   For details, see [VPC resources](#pt-creating-test-vpc), [Credentials](#pt-creating-test-credentials), and [Network configuration](#pt-creating-test-network).

1. On the **Additional configuration** page, choose the **Service role** and any other settings.

   (Optional) To run threat models for the test, under **Automation**, for **Threat model**, choose **Once** or **On every run**. For more information, see [Choosing when threat models run](pt-threat-modeling.md#pt-threat-modeling-strategy).

   For details, see [Additional configuration](#pt-creating-test-additional).

1. Choose **Create penetration test** to create the test, or **Create and execute** to create it and start a run.

The test appears in the **Penetration tests** table on the environment's **Overview** tab.

## Penetration test details
<a name="pt-creating-test-details"></a>

The name can have 3–100 letters, numbers, underscores, or hyphens.

Under **Penetration testing scope**, you choose the following settings:
+ **What do you want to test?** – Choose **White box** to test a running application with its source repositories as context. Choose **Black box** to test it from the outside without source code.
+ **Application category** – Choose **Web application** for a full test of web and API risks. Choose **Generative AI application** for a focused test of large language model (LLM) risks.
+ **Target URLs** – Enter each URL to test. Each URL must be under a verified domain. If your application uses a non-standard port, include it, such as `https://example.com:8443`.

For a white-box test, you also choose the source repositories, source archives, and supporting documents in **Source code and documents**. To use repositories from a source provider, create a GitHub or GitLab integration first. For instructions, see [GitHub](integrations.md#integrations-github) and [GitLab](integrations.md#integrations-gitlab).

## VPC resources
<a name="pt-creating-test-vpc"></a>

Skip this page if your target URLs are reachable from the internet. For a private application, choose the **VPC**, **Subnet**, and **Security Group** that can reach it. The security group must allow outbound traffic to your targets.

**Note**  
When you connect to a subnet, AWS Continuum creates an elastic network interface in the subnet that you configure for the penetration test. This network interface doesn't have a public IP address, so it can't communicate with internet gateways in public subnets. If your penetration test requires open internet access, use a private subnet with an associated NAT gateway instead.

**Tip**  
When you test an endpoint that has an IP allowlist, add a private VPC configuration with an associated NAT gateway to your penetration test. You can then use the NAT gateway IP address to allowlist outbound traffic from the penetration test.

You choose the VPCs that tests in an environment can use on the **Additional configuration** page of the environment. For more information, see [Additional configuration settings](pt-getting-started.md#pt-getting-started-resources). For each test, you then choose the specific VPC, subnet, and security group on this page. The service role of the environment needs permissions to create and manage network interfaces. For the VPC policy, see [Permissions policies](pt-security-iam.md#pt-security-iam-service-role-permissions).

If you have a private VPC associated with your penetration test and a GitHub or GitLab repository configured, make sure that the provider is accessible through your private VPC so that AWS Continuum can pull the repository.

### Running a penetration test against VPC resources in another account
<a name="pt-creating-test-vpc-cross-account"></a>

You can run penetration tests against VPC resources that are shared with your account through [AWS Resource Access Manager](https://docs.aws.amazon.com/ram/latest/userguide/what-is.html). Both accounts must be part of the same AWS Organization. Secrets Manager secrets and Lambda functions that you use for test credentials must be in the same account as your environment.

**To test VPC resources that another account owns**

1. (Optional) Enable automatic resource sharing for your organization.

   ```bash
   aws ram enable-sharing-with-aws-organization
   ```

1. Using credentials from the account that owns the VPC resources, share the subnet and security group resources with the account that owns the penetration test.

   In the following command, replace the placeholder values with your own. The values are described after the command.

   ```bash
   aws ram create-resource-share \
       --name {{my-pentest-resource-share}} \
       --resource-arns {{subnet-ARN}} {{security-group-ARN}} \
       --principals {{penetration-test-owner-account-ID}}
   ```

   In the command, replace the following values:
   + {{my-pentest-resource-share}} – A name for the resource share.
   + {{subnet-ARN}} – The Amazon Resource Name (ARN) of the subnet to share.
   + {{security-group-ARN}} – The ARN of the security group to share.
   + {{penetration-test-owner-account-ID}} – The ID of the AWS account that owns the penetration test.

1. Verify that the service role of the environment grants access to the shared VPC resources.

1. Add the shared VPC, subnets, and security groups to the environment.

1. On the page of the environment, save the configuration.

1. Edit the penetration test, and choose the shared VPC resources on the **VPC Resources** page.

## Credentials
<a name="pt-creating-test-credentials"></a>

Add credentials to test the parts of your application behind a sign-in. Choose **Add login** for each user role that you want to test. Use an account with the access of a typical user, not an administrator.

For each login, you enter the following settings:
+ For **Login name**, enter a name for the login. For **Target URL**, enter the URL where the test uses the credentials.
+ For **Credential provider**, choose **Create new credential**, **Secrets Manager**, **Lambda**, or **IAM role**.
+ For **Authentication type**, choose **Basic authentication**, **OAuth**, **API key**, **JWT**, or **AWS Signature Version 4**.

With **Create new credential**, you enter the username and password. You can also add a time-based one-time password (TOTP) secret or set up email multi-factor authentication (MFA).

After you save the test, you can check that each login works. Choose **Test** in the login's row, or choose **Test all credentials**. The status changes to **Verified**, **Failed**, or **Timed out**. To see what happened, choose **View logs**.

For more information about each credential provider, multi-factor authentication, and using several logins, see [Providing test credentials for penetration testing](pt-test-credentials.md).

## Network configuration
<a name="pt-creating-test-network"></a>

By default, the test reaches only your target URLs. On this page, you can change that with the following settings:
+ **Additional allowed URLs** – URLs that the test can reach but doesn't attack, such as a hosted login page. These URLs don't need verification.
+ **Blocked URLs** – URLs that the test must not reach, such as destructive operations or administrative paths
+ **Custom headers** – Headers that AWS Continuum adds to every request
+ **Trusted CA certificates** – Certificate authority (CA) certificates for targets whose certificates aren't publicly trusted
+ **Client certificates** – Certificates for targets that require mutual Transport Layer Security (mTLS)

### Allowed and blocked URLs
<a name="pt-creating-test-network-scope"></a>

Every URL that the test can reach is one of three kinds:
+ **Target** – A URL that the test is allowed to attack. Target URLs come from the penetration test details page. To change one, go back to that page.
+ **Additional allowed** – A URL that the test can access but must not attack. Use this for a hosted login page, a content delivery network (CDN), or another supporting service that your application depends on.
+ **Blocked** – A URL that the test must not access at all.

By default, only your target URLs are reachable during the penetration test. This network scope doesn't apply to credential tests. Add an allowed URL for anything else that your application needs. An entry can be a whole domain, such as `auth.example.com`, or a specific path, such as `https://example.com/callback`. A blocked entry always takes precedence over an allowed one.

Additional allowed URLs don't require ownership verification, even if they belong to a different domain than your target. Only target domains require verified ownership. AWS Continuum doesn't penetration test allowed URLs. It uses them only for sign-in and navigation.

To make a non-standard port reachable, enter a full URL that includes the scheme and the port, such as `https://auth.example.com:8443`. If you enter a domain without a scheme, such as `auth.example.com:8443`, AWS Continuum allows the domain only on standard ports.

**Warning**  
Block any path that should not be accessed during testing, such as a destructive operation or a sensitive administrative function. AWS Continuum excludes the specified path and all paths nested beneath it. For example, if you block `https://example.com/admin`, then `https://example.com/admin/tools` is also blocked.

### Custom HTTP headers
<a name="pt-creating-test-network-headers"></a>

Specify custom HTTP headers that AWS Continuum adds to every request that it makes during penetration tests and credential tests. Credential tests can reach domains outside your target URLs. Don't put a value in a custom header that you wouldn't send to those domains.

**To add custom HTTP headers**

1. In the **Custom headers** section, enter a header name and value to associate with outbound requests.

1. To add another header, choose **Add header**, and then enter the header.

1. To remove a header, choose **Remove** next to it.

**Note**  
By default, AWS Continuum adds a `User-Agent` header that is set to `securityagent`, unless you specify a different `User-Agent` value. You can use this value to allowlist penetration test traffic in a web application firewall (WAF).

### Trusted CA certificates
<a name="pt-creating-test-network-ca"></a>

If a target endpoint uses a Transport Layer Security (TLS) certificate that isn't publicly trusted, provide the trust anchor. This applies when a private or internal CA, an intermediate CA, or a self-signed certificate issued the certificate. AWS Continuum uses the trust anchor to validate the connection during testing. Without the trust anchor, endpoint validation rejects the target before testing begins.

Trusted CA certificates apply to the entire penetration test.

**Note**  
Skip this task if your target endpoints use certificates that a publicly trusted CA issued.

**Important**  
Provide the certificate only, never a private key. AWS Continuum doesn't accept a certificate that has expired or isn't yet valid.

**To provide a trusted CA certificate**

1. On the **Network configuration** page, expand **Trusted CA certificates**.

1. Choose **Add certificate**.

1. For **Source**, choose one of the following:
   + **Paste PEM** – Paste a PEM-encoded X.509 certificate.
   + **Upload a file** – Upload a `.pem`, `.crt`, or `.cer` certificate file.
   + **S3 URI** – Enter the Amazon S3 URI of a certificate that you staged, in the form `s3://{{amzn-s3-demo-bucket}}/ca.pem`. AWS Continuum reads the certificate from Amazon S3 when the penetration test runs, by using the service role. The service role must have `s3:GetObject` permission for the object. Enter the `s3://` URI form. An Amazon S3 HTTPS URL isn't accepted.

1. On the **Network configuration** page, review the parsed certificate details (subject, issuer, type, and validity), and then choose **Save**.

To add more than one trust anchor, choose **Add certificate** again. To change or remove a certificate later, choose the actions menu on its row, and then choose **Edit** or **Remove**. Trusted CA certificates that you save are retained when you edit the penetration test.

### Client certificates for mutual TLS
<a name="pt-creating-test-network-client-certs"></a>

Attach a client certificate to a penetration test so that AWS Continuum can test endpoints that require mutual TLS (mTLS). An mTLS endpoint accepts a connection only when the client presents a certificate during the TLS handshake. Without a client certificate, the endpoint rejects the connection and AWS Continuum can't test it.

You store each client certificate and its private key in a AWS Secrets Manager secret in your account, and reference the secret from the penetration test. AWS Continuum stores only the secret ARN. It reads the certificate and private key from the secret when the penetration test runs.

**Note**  
Skip this task if your target endpoints don't require a client certificate.  
The server certificate of the endpoint is a separate setting. If it's self-signed, or issued by a private or internal CA, you also provide a trust anchor. For more information, see [Trusted CA certificates](#pt-creating-test-network-ca). An endpoint can need both.
+ **A certificate applies to a whole host** – You attach a certificate to one or more hosts, and it applies to every path and port on each host. A host can use only one client certificate.
+ **Hosts must be target endpoints** – Each host must belong to a target URL of the penetration test. Include every host that requires the certificate, not only the API host. For example, suppose the API at `https://api.example.com` needs a token from `https://auth.example.com`. If the token endpoint requires the client certificate, add both URLs as targets and attach the certificate to both hosts. Otherwise, the token request goes out without a certificate, and the authentication server rejects it.
+ **The agent never handles the certificate** – AWS Continuum presents the certificate during the TLS handshake. This happens on the network path between the test environment and the host. The certificate and private key aren't available inside the test environment. Don't instruct AWS Continuum to pass a certificate file to a command, for example with `curl --cert`. Write authentication steps as plain HTTPS requests, and AWS Continuum attaches the certificate for the hosts that you chose.
+ **Hosts must use HTTPS and a hostname** – An origin uses the form `https://{{hostname}}:{{port}}` with no path. An IP address isn't accepted. AWS Continuum selects the certificate from the TLS server name, and a connection to an IP address doesn't carry one.
+ **Certificates are presented only to their hosts** – AWS Continuum presents a certificate only when it connects to a host that you attached it to. It never presents the certificate to any other host.
+ **Certificate names** – A name can be 1–100 characters: letters, numbers, hyphens, and underscores, starting with a letter or number. Names must be unique within the penetration test.

**Important**  
The certificate must remain valid for the whole run. AWS Continuum rejects a certificate that has expired or isn't yet valid. It also requires the certificate to stay valid for at least 36 hours after the penetration test starts. If you set a maximum task-hours limit that is lower than 36, the certificate must stay valid for that number of hours instead.  
AWS Continuum reads the secret once, when the penetration test starts. Rotating the secret during a run doesn't affect that run.

#### Storing the certificate in AWS Secrets Manager
<a name="pt-creating-test-network-client-certs-secret"></a>

The secret must hold a JSON `SecretString` with the following fields:

```json
{
  "certificate": "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----",
  "privateKey": "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----",
  "privateKeyPassword": "optional"
}
```
+ `certificate` – The PEM-encoded client certificate, followed by any intermediate CA certificates.
+ `privateKey` – The PEM-encoded private key that matches the certificate.
+ `privateKeyPassword` – (Optional) Include it only if the private key is encrypted.

Each PEM value must contain real line breaks: the `BEGIN` and `END` markers each on their own line, and the base64 body on the lines between them. In JSON, write each line break as `\n`.

**Note**  
If you create the secret in the AWS Secrets Manager console, use the **Plaintext** tab and paste the JSON. The **Key/value** tab stores `\n` as two literal characters rather than a line break, and AWS Continuum then can't read the certificate.

The following AWS CLI command builds the secret from local `client.crt` and `client.key` files, so that the line breaks are encoded correctly. In the following command, replace `client.crt` and `client.key` with the paths to your certificate and private key files, and replace {{partner-api-cert}} with your secret name.

```bash
aws secretsmanager create-secret \
  --name "{{partner-api-cert}}" \
  --secret-string "$(jq -n --rawfile c client.crt --rawfile k client.key \
      '{certificate: $c, privateKey: $k}')"
```

#### Granting access to the secret
<a name="pt-creating-test-network-client-certs-access"></a>

The service role reads the secret when the penetration test runs. It must have the following permissions:
+ `secretsmanager:GetSecretValue` on the secret
+ `kms:Decrypt` on the AWS KMS key of the secret, if the secret is encrypted with a customer managed key

For the base service role policy, see [Permissions policies](pt-security-iam.md#pt-security-iam-service-role-permissions). If the base policy doesn't cover the secret, add a statement for it, as in the following example:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "secretsmanager:GetSecretValue",
      "Resource": "arn:aws:secretsmanager:{{us-east-1}}:{{111122223333}}:secret:{{partner-api-cert-AbCdEf}}"
    },
    {
      "Effect": "Allow",
      "Action": "kms:Decrypt",
      "Resource": "arn:aws:kms:{{us-east-1}}:{{111122223333}}:key/{{1234abcd-12ab-34cd-56ef-1234567890ab}}"
    }
  ]
}
```

#### Providing a client certificate in the console
<a name="pt-creating-test-network-client-certs-console"></a>

Add the target URLs first, because you choose the hosts of the certificate from them.

**To attach a client certificate**

1. On the **Network configuration** page, expand **Client certificates**.

1. Choose **Add certificate**.

1. For **Name**, enter a name for the certificate, such as `partner-api-cert`.

1. Enter the AWS Secrets Manager ARN of a secret that you created as described in [Storing the certificate in AWS Secrets Manager](#pt-creating-test-network-client-certs-secret).

1. For **Hosts**, choose one or more target hosts that require this certificate.

1. Choose **Save**.

To attach another certificate, choose **Add certificate** again. To change or remove a certificate later, choose the actions menu on its row, and then choose **Edit** or **Remove**. While a certificate applies to a host, you can't change the target URL of that host. Update or remove the certificate first.

#### Troubleshooting client certificate errors
<a name="pt-creating-test-network-client-certs-errors"></a>

Client certificate errors come from the secret, the certificate and key, or the TLS setup of the target. AWS Continuum checks each client certificate before testing begins, in two steps. First, it reads the secret and validates the certificate and private key. Then, it connects to each host with its certificate. If either step fails, AWS Continuum stops the penetration test with a message. Find the message in the following tables, and take the action for it.

A certificate loading message names the certificate.


| Message contains | What to do | 
| --- | --- | 
| Cannot assume the pentest service role | Confirm that the trust policy of the service role allows AWS Continuum to assume it for this penetration test. For the trust policy, see [Trust policy](pt-security-iam.md#pt-security-iam-service-role-trust). | 
| Cannot access the secret | Grant the service role secretsmanager:GetSecretValue on the secret. For instructions, see [Granting access to the secret](#pt-creating-test-network-client-certs-access). | 
| Cannot decrypt the secret | Grant the service role kms:Decrypt on the customer managed key of the secret, and confirm that the key is enabled. | 
| Secret not found, or could not be read due to an invalid parameter | Confirm that the secret ARN is correct. | 
| is in an invalid state | The secret is pending deletion. Restore the secret, or replace it with a new one. | 
| does not contain a text value | The secret is stored as binary. Store the certificate and key as a JSON SecretString in the format shown in [Storing the certificate in AWS Secrets Manager](#pt-creating-test-network-client-certs-secret). | 
| is not valid JSON, or must be a JSON object | Store the value as a JSON object in the format shown in [Storing the certificate in AWS Secrets Manager](#pt-creating-test-network-client-certs-secret). | 
| is missing the 'certificate' or 'privateKey' field | Add both fields to the secret. | 
| is not valid PEM-encoded X.509 material, or could not be loaded by the TLS stack | Check the PEM line breaks. A secret that you create on the Key/value tab of the AWS Secrets Manager console stores \\n as literal characters. | 
| The private key in client certificate | Confirm that the key is PEM-encoded and that privateKeyPassword is correct, or remove it if the key isn't encrypted. | 
| The private key does not match the certificate | Use the private key from the same key pair as the certificate. | 
| has expired, or is not yet valid | Replace the certificate with one that is currently valid. | 
| run window | Use a certificate that stays valid for at least 36 hours after the penetration test starts, or for your maximum task-hours limit if it's lower than 36. | 

If a host doesn't answer the connection check, the message begins with `Could not complete an mTLS connection to one or more targets.` It then lists each reason that was found, with the number of targets that failed for that reason. The message doesn't name the hosts. If you attached certificates to more than one host, check each of those hosts.


| Message contains | What to do | 
| --- | --- | 
| The server certificate does not match the configured hostname | The TLS server certificate of the host doesn't cover the hostname in the target URL. Update the server certificate so that its subject alternative names include that hostname, or change the target URL to a hostname that the certificate covers. This is common when a private API sits behind a load balancer or API gateway that serves a certificate for a different name. | 
| The server certificate failed verification | AWS Continuum couldn't validate the server certificate of the host. Check that the certificate is valid and that the host sends its complete certificate chain. If the host uses a self-signed certificate or a private or internal CA, add that CA as a trusted CA certificate. For more information, see [Trusted CA certificates](#pt-creating-test-network-ca). | 
| Check that the server certificate is trusted and matches the configured hostname | The connection failed, but the cause couldn't be determined. Check the following, in order: the server certificate of the host is trusted and matches the hostname; the host accepts the attached client certificate (for example, confirm that the issuer of the certificate is in the trust store of the host); and the host is reachable from the penetration test network. For a host in a VPC, see [VPC resources](#pt-creating-test-vpc). | 

## Additional configuration
<a name="pt-creating-test-additional"></a>

On this page, you choose the following settings:
+ **Service role** – The role that AWS Continuum uses to access your resources
+ **CloudWatch log group** – Where to store the test logs. If you don't choose one, AWS Continuum creates a log group.
+ **Report configuration** – An Amazon S3 location for reports
+ **Code remediation** – Whether AWS Continuum opens pull requests that fix findings. Code remediation uses the GitHub or GitLab integration of the test's source repositories. To create an integration, see [GitHub](integrations.md#integrations-github) or [GitLab](integrations.md#integrations-gitlab). For more information, see [Remediating a penetration test finding](pt-remediating-findings.md).
+ **Threat model** (under **Automation**) – Whether AWS Continuum generates threat models from the test's source code: **Off**, **Once**, or **On every run**. You can view each run on the test's **Threat models** tab. For more information, see [Choosing when threat models run](pt-threat-modeling.md#pt-threat-modeling-strategy).
+ **Test behavior** – The cleanup strategy, the maximum task hours, and the risk types to exclude

## Starting a run
<a name="pt-creating-test-start"></a>

Start a run to test your targets with the current configuration and record the findings. After a run starts, you can't change the test's configuration for that run.

**To start a run**

1. On the environment's **Overview** tab, in the **Penetration tests** table, choose the test name.

1. Choose **Start run**.

1. In the **Start penetration test run** dialog box, confirm that you're ready to start.

The run appears on the **Jobs** tab. To follow it, see [Viewing penetration test findings](pt-viewing-findings.md).