|
| 1 | +--- |
| 2 | +title: How-to test the attack path and cloud security explorer using a vulnerable container image in Microsoft Defender for Cloud |
| 3 | +description: Learn how to test the attack path and security explorer using a vulnerable container image |
| 4 | +ms.service: defender-for-cloud |
| 5 | +ms.topic: how-to |
| 6 | +ms.date: 07/17/2023 |
| 7 | +--- |
| 8 | + |
| 9 | +# Testing the Attack Path and Security Explorer using a vulnerable container image |
| 10 | + |
| 11 | +## Observing potential threats in the attack path experience |
| 12 | + |
| 13 | +Attack path analysis is a graph-based algorithm that scans the cloud security graph. The scans expose exploitable paths that attackers may use to breach your environment to reach your high-impact assets. Attack path analysis exposes attack paths and suggests recommendations as to how best remediate issues that will break the attack path and prevent successful breach. |
| 14 | + |
| 15 | +Explore and investigate [attack paths](how-to-manage-attack-path.md) by sorting them based on name, environment, path count, and risk categories. Explore cloud security graph Insights on the resource. Examples of Insight types are: |
| 16 | + |
| 17 | +- Pod exposed to the internet |
| 18 | +- Privileged container |
| 19 | +- Pod uses host network |
| 20 | +- Container image is vulnerable to remote code execution |
| 21 | + |
| 22 | +## Testing the attack path and security explorer using a mock vulnerable container image |
| 23 | + |
| 24 | +If there are no entries in the list of attack paths, you can still test this feature by using a mock container image. Use the following steps to set up the test: |
| 25 | + |
| 26 | +**Requirement:** An instance of Azure Container Registry (ACR) in the tested scope. |
| 27 | + |
| 28 | +1. Import a mock vulnerable image to your Azure Container Registry: |
| 29 | + |
| 30 | + 1. Run the following command in Cloud Shell: |
| 31 | + |
| 32 | + ``` |
| 33 | + az acr import --name $MYACR --source DCSPMtesting.azurecr.io/mdc-mock-0001 --image mdc-mock-0001 |
| 34 | + ``` |
| 35 | + |
| 36 | + 1. If your AKS isn't attached to your ACR, use the following Cloud Shell command line to point your AKS instance to pull images from the selected ACR: |
| 37 | + |
| 38 | + ``` |
| 39 | + az aks update -n myAKSCluster -g myResourceGroup --attach-acr <acr-name> |
| 40 | + |
| 41 | +1. Authenticate your Cloud Shell session to work with the cluster: |
| 42 | + |
| 43 | + ``` |
| 44 | + az aks get-credentials --subscription <cluster-suid> --resource-group <your-rg> --name <your-cluster-name> |
| 45 | + |
| 46 | +1. Verify success by doing the following steps: |
| 47 | +
|
| 48 | + - Look for an entry with **mdc-dcspm-demo** as namespace |
| 49 | + - In the **Workloads-> Deployments** tab, verify “pod” created 3/3 and **dcspmcharts-ingress-nginx-controller** 1/1. |
| 50 | + - In services and ingresses look for-> services **service**, **dcspmcharts-ingress-nginx-controller and dcspmcharts-ingress-nginx-controller-admission**. In the ingress tab, verify one **ingress** is created with an IP address and nginx class. |
| 51 | +
|
| 52 | +1. Deploy the mock vulnerable image to expose the vulnerable container to the internet by running the following command: |
| 53 | +
|
| 54 | + ``` |
| 55 | + helm install dcspmcharts oci://dcspmtesting.azurecr.io/dcspmcharts --version 1.0.0 --namespace mdc-dcspm-demo --create-namespace --set registry=<your-registry> |
| 56 | +``` |
| 57 | +
|
| 58 | +> [!NOTE] |
| 59 | +> After completing the above flow, it can take up to 24 hours to see results in the cloud security explorer and attack path. |
| 60 | +
|
| 61 | +## Investigate internet exposed Kubernetes pods |
| 62 | +
|
| 63 | +You can build queries in one of the following ways: |
| 64 | +
|
| 65 | +- [Find the security issue under attack paths](#find-the-security-issue-under-attack-paths) |
| 66 | +- [Explore risks with built-in cloud security explorer templates](#explore-risks-with-cloud-security-explorer-templates) |
| 67 | +- [Create custom queries with cloud security explorer](#create-custom-queries-with-cloud-security-explorer) |
| 68 | +
|
| 69 | +### Find the security issue under attack paths |
| 70 | +
|
| 71 | +1.Go to **Recommendations** in the Defender for Cloud menu. |
| 72 | +1. Select the **Attack Path** link to open the attack paths view. |
| 73 | +
|
| 74 | + :::image type="content" source="media/how-to-test-attack-path/attack-path.png" alt-text="Screenshot of showing where to select Attack Path." lightbox="media/how-to-test-attack-path/attack-path.png"::: |
| 75 | +
|
| 76 | +1. Locate the entry that details this security issue under “Internet exposed Kubernetes pod is running a container with high severity vulnerabilities.” |
| 77 | +
|
| 78 | + :::image type="content" source="media/how-to-test-attack-path/attack-path-kubernetes-pods-vulnerabilities.png" alt-text="Screenshot showing the security issue details." lightbox="media/how-to-test-attack-path/attack-path-kubernetes-pods-vulnerabilities.png"::: |
| 79 | +
|
| 80 | +### Explore risks with cloud security explorer templates |
| 81 | +
|
| 82 | +1. From the Defender for Cloud overview page, open the cloud security explorer. |
| 83 | +
|
| 84 | +1. Some out of the box templates for Kubernetes appear. Select one of the templates: |
| 85 | +
|
| 86 | + - **Azure Kubernetes pods running images with high severity vulnerabilities** |
| 87 | + - **Kubernetes namespaces contain vulnerable pods** |
| 88 | + |
| 89 | + :::image type="content" source="media/how-to-test-attack-path/select-template.png" alt-text="Screenshot showing where to select templates." lightbox="media/how-to-test-attack-path/select-template.png"::: |
| 90 | +
|
| 91 | +1. Select **Open query**; the template builds the query in the upper portion of the screen. Select **Search** to view the results. |
| 92 | + |
| 93 | + :::image type="content" source="media/how-to-test-attack-path/query-builder-search.png" alt-text="Screenshot that shows the query built and where to select search." lightbox="media/how-to-test-attack-path/query-builder-search.png"::: |
| 94 | +
|
| 95 | +### Create custom queries with cloud security explorer |
| 96 | +
|
| 97 | +You can also create your own custom queries. The following example shows a search for pods running container images that are vulnerable to remote code execution. |
| 98 | +
|
| 99 | +:::image type="content" source="media/how-to-test-attack-path/custom-query-search.png" alt-text="Screenshot that shows a custom query." lightbox="media/how-to-test-attack-path/custom-query-search.png"::: |
| 100 | +
|
| 101 | +The results are listed below the query. |
| 102 | +
|
| 103 | +:::image type="content" source="media/how-to-test-attack-path/custom-query-results.png" alt-text="Screenshot that shows the results from a custom query." lightbox="media/how-to-test-attack-path/custom-query-results.png"::: |
| 104 | +
|
| 105 | +## Next steps |
| 106 | +
|
| 107 | + - Learn more about the Defender for Cloud [Defender plans](defender-for-cloud-introduction.md#protect-cloud-workloads). |
0 commit comments