This article shows how to leverage the Lumu Defender API and the Ubiquiti Unifi Cloud Gateway features to mitigate security risks.
The integration uses Unifi Traffic rules to block outbound traffic related to Lumu-detected adversarial contacts. It manages a rule per IOC type, IP addresses, and Domains, updating them based on Lumu-reported detections and updates.
1. Open your Web browser and access the Unifi Site Manager. Log in if the Site Manager requests it.2. In the Site Manager window, look for the site where your Unifi devices are attached to, then, click on the site.3. Now, you are on the Network application.
1. Head to the left navigation bar and look for the Settings button (the Gear icon). Click on it.
2. Head to the Settings navigation bar on the left. Click on the Admin & Users menu.
3. In the Admins window, click the Manage Roles(1) button next to the search bar. The Manage Roles section will appear on the right side of the Window. Click on the Create New Role(2) menu to create your integration role.
4. Create your integration role by following these guidelines:a. Enter a distinctive Role Name(1).b. Select the Permissions(2) for each application. Ensure that the Network application has Full Management selected. The rest of the applications must be set to None.c. When finished, save your integration role by clicking on the Create button.
1. Click on the Create New Admin button located next to the search bar.
2. Fill in the information in the Create New Admin section on the right side of the window. Follow these guidelines:a. Type your integration Username(1)b. Give your integration user a secure Password(2)c. Ensure the Restrict to Local Access Only(3) toggle is enabled.d. Enable the Use a Predefined Role(4) toggle ande. Select the Role(5) you created in the Create a dedicated integration role section.e. When you are ready, save your integration user by clicking the Create(6) button.
The integration operates with local users instead of Unifi Accounts.
Ensure you store your integration user credentials in a safe place. This information will be needed to configure your integration.
Ensure the device you will use to deploy the integration can reach the Ubiquiti Unifi devices you want to integrate. In case you need changes in your network to allow communications between the integration components, contact your network administrator.
The integration set-up process needs you to collect this information from Lumu portal:
Log in to your Lumu portal and run the following procedures to collect these data.
To collect the Lumu Defender API key, please refer to the Defender API document.
To collect your Lumu company UUID, log in to your Lumu portal. Once you are in the main window, copy the string below your company name.
The companies file is in charge of defining how the integration connects to Lumu and extracts the information of the incidents and related indicators of compromise.
-
lumu:
uuid: "COMPANY_UUID"
defender_key: "DEFENDER_API_KEY"
hash_type: "sha1" # Supported hash types: sha256, sha1, md5
ioc_types: # Supported IOC types: ip, domain, url, hash. Select one, multiple, or all of them
- ip
- domain
- url
- hash
adversary: # Supported adversary types: C2C, Malware, Mining, Spam, Phishing, Anonymizer. Select one, multiple, or all of them
- C2C
- Malware
- Mining
- Spam
- Phishing
- Anonymizer
days: 3 # Min 1, max 3
-
COMPANY 2
-
COMPANY 3
-
...
Within this file, COMPANY_UUID and DEFENDER_API_KEY fields are mandatory. Please use the values captured in the previous steps. The ioc_types values must match the IOC types required by the integration, in this case, ip and domain.
The integrations file contains the information required for the integration to connect and interact with your Ubiquiti Unifi Cloud Gateway devices:
- lumu:
uuid: "COMPANY_UUID"
adversary: # Supported adversary types: C2C, Malware, Mining, Spam, Phishing, Anonymizer. Select one, multiple, or all
- C2C
- Malware
- Mining
- Spam
- Phishing
- Anonymizer
days: 3 # Number of days to collect adversary data from the IOC Manager
app:
name: "INTEGRATION_NAME"
clean: false # Flag used if you want to revert all changes made by the integration component. Supported values are true or false
ioc_types: # Supported IOC types: ip, domain. Select one, multiple, or all of them
- ip
- domain
api:
username: UNIFI_USERNAME
password: UNIFI_PASSWORD
host: UNIFI_IP_OR_HOSTNAME
site: UNIFI_SITE_NAME # Site name. If not defined, the integration will use "default"
To use the script, you must locate yourself on the path selected for deployment (<app_lumu_root>). Use the following command to show all options available for the package:
Usage: run [-h] [--config CONFIG] [--ioc-manager-db-path IOC_MANAGER_DB_PATH] [-v] [-l {screen,file}] [--hours HOURS]
| Options | Description |
| -h, --help | show this help message and exit |
| --config CONFIG | Configuration file for the integration (default: integrations.yml) |
| --ioc-manager-db-path IOC_MANAGER_DB_PATH | IOC Manager dabatase path (default: ioc.db). This is the database where the IOC information comes from. |
| --logging {screen,file} | Select where you want to output logs (default: screen) |
| --verbose, -v | Use this flag to increase log verbosity |
| --hours HOURS | Number of hours to expire records in the database |
To query all ip addresses and domains related to Lumu incidents triggered in the days defined in your configuration files, run the following command.
python3 run.py
To clean the existing records from your Ubiquiti Unifi Cloud Gateway device, just set up the clean flag in the integrations.yml file to true.
Then, run the integration script as follows:
python3 run.py [--config CONFIG] [--ioc-manager-db-path IOC_MANAGER_DB_PATH]
According to your needs, you can combine the examples shown. If you need more details on the steps executed by the integration script, you can add the –logging {file, screen} and –verbose arguments. These arguments can be used for troubleshooting.
If you have a Docker environment, you can select this option to run the integration as a Docker process. To deploy and run your integration as a docker container, locate yourself at the <app_lumu_root> folder, and follow these instructions:
1. Build the container by running the following command.
2. Run the container by using the following command.
With this mode, your integration will run every 5 minutes.
For troubleshooting purposes, you can run the following commands:
To log in to your container using an interactive shell:
docker exec -it lumu-unifi-response bash
To collect integration logs:
docker logs -f lumu-unifi-response
1. Head to the left navigation bar. Click on the Settings menu (the Gear icon).2. Head to the Settings navigation bar. Click on the Security menu.3. The Lumu rules are listed under the Traffic & Firewall Rules window. Ensure the Simple option and the All toggle are enabled.
To identify failures in the script execution, use the -v flag. The script execution log will show more detailed information.
The application logs will be redirected to the lumu.log file. The file errors.log stores only the errors to make them easier to find and aid the troubleshooting process.
If you receive errors like this:
It means you are using the wrong key parameters or values. Review your configuration files and run the integration again.
If you receive the following error.
There could be another instance running. To check this, open the pid.pid file in the integration folder. This file stores the process ID if it’s running.