Your devices connects to Internet through a metered connection and you want to keep costs down. A couple of weeks ago, another company faced a situation on some of their devices where they would get tampered and join a malicious botnet, participating in DDoS attacks.
You thought that monitoring a few metrics such as the amount of packets on the device and reporting them to the IoT solution could help detecting this kind of threat earlier. That is exactly what AWS Device Defender Detect does using device side metrics.
You need to run an agent on each device that report key metrics to AWS IoT Reserved Device regularly.
In a real-world scenario, you would need to develop the device-side code to send the device-side metrics to AWS IoT. For this Lab, the Virtual Devices are already equipped with the required code that measures and sends data every 5 minutes to reserved AWS IoT Topics such as:
$aws/things/$THING_NAME/defender/metrics/json
More information on AWS IoT Device Defender Detect - Device Side Metrics .
Notice the following best-practice and limitations:
You will walk through a solution which has the following tasks:
For this chapter, we’ll make use of the ecs-cli to get the Virtual Device public IP. The Amazon Elastic Container Service (Amazon ECS) command line interface (CLI) provides high-level commands to simplify creating, updating, and monitoring clusters and tasks from a local development environment, see: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI.html.
To install the ecs-cli, follow along the install guide ( https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_CLI_installation.html ) or copy and paste the following command in the Cloud9 terminal
sudo curl -Lo /usr/local/bin/ecs-cli https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest
gpg --keyserver hkp://keys.gnupg.net --recv BCE9D9A42D51784F
curl -Lo ecs-cli.asc https://amazon-ecs-cli.s3.amazonaws.com/ecs-cli-linux-amd64-latest.asc
gpg --verify ecs-cli.asc /usr/local/bin/ecs-cli
sudo chmod +x /usr/local/bin/ecs-cli
Test that everything is installed correctly by typing:
ecs-cli --version
The ecs-cli version should be visualized.
To create a Security Profile, follow the steps below, which are similiar to what you’ve done in the previous section:
In this section, you will specify the behavior that you want to monitor. For this lab, we’ll want to keep track of the amount of Outbound Bytes our devices network cards send.
In a real-world scenario, to avoid generating lots of false-positive, more metrics than just the Outgoing Bytes should be analyzed, for example:
For more information, you can check out this awesome blog post by Eknath: Use AWS IoT Device Defender to detect statistical anomalies and to visualize your device security metrics
OutboundBytesSecProfile
OutboundBytesBehavior
When you create a Security Profile, Behaviours are not mandatory, that’s because it is good practice to monitor your devices behaviour before setting one up.
Now, you will need to configure an SNS topic to receive the Alerts and a Role allowing AWS IoT Device Defender Detect to post message to it.
On the next screen, you need to select which devices AWS IoT Device Defender Detect should monitor. For this workshop, you will attach the Security Profile to all devices, but in a production environment, you can select the appropriate target depending on the Profile.
Now, AWS IoT Device Defender is continuosly monitoring the amount of messages sent by each device. Let’s check what happens when a thing starts to present an anomalous behavior.
Go back to the Cloud9 console.
Run the script that forces the device to send large packets:
cd ~/environment/aws-iot-playground
./scripts/send_large_payload.sh
You can also see the near-realtime graph in the Device section, remember that Device-side data have a 5-minute granularity.
The Alert will trigger the lambda function that will move the virtual device to the Quarantine
Thing Group. You can check if it worked following the steps.
Mitigation actions really depends on the kind of device, environment and processes your company may have in place, they could range from:
Good job, IoT Fleet Manager! You learned how to setup AWS IoT Device Defender Detect for device-side metrics and discovered the possible mitigation actions that can be performed on the devices.