Notifications

Module goals

  • Understanding how notification and alerting work in RHACS

  • Setup a notification alert to a Microsoft teams channel

  • Setup a notification alert to a Slack channel

How do notifications and alerts work in RHACS

Red Hat Advanced Cluster Security for Kubernetes (RHACS) offers robust notification and alerting mechanisms to enhance the security and observability of Kubernetes environments.

Notification and Alerting Mechanisms

Policy Violations

RHACS uses a set of pre-defined and custom policies to monitor the cluster for security violations. These policies can cover a wide range of security aspects including image vulnerabilities, misconfigurations, runtime behaviors, and compliance checks. When a policy is violated, RHACS generates a violation event. These events are the primary triggers for notifications and alerts.

Alert Configurations

RHACS supports integrations with various notification and alerting systems such as Slack, Microsoft Teams, email, PagerDuty, Splunk, and more. For systems not directly supported, custom webhooks can be configured to send alerts to any endpoint that can process HTTP POST requests.

Setting Up Notifications

Administrators can configure notification channels through the RHACS console. This involves providing the necessary credentials and endpoints for the chosen notification service. These notifications can be scoped to specific policies, allowing for granular control over which violations generate alerts and where those alerts are sent.

Alert Management

Policies can be assigned different severity levels (Low, Medium, High, Critical). Alerts can be configured to trigger based on the severity level of the violation. Depending on the integration, alerts can be routed to different teams or systems. For example, critical violations can be sent to on-call engineers via PagerDuty, while lower-severity alerts might be sent to a Slack channel for informational purposes.

Runtime Alerts

RHACS continuously monitors Kubernetes clusters for runtime anomalies. Alerts can be configured to trigger on suspicious activities such as unexpected network connections, process executions, or file system changes.By analyzing the runtime behavior of applications, RHACS can alert on deviations from known good states or behaviors. Configuring Alerting in RHACS

Setup a Microsoft Teams Integration

Let’s setup a basic Microsoft teams integration.

For this lab I have setup a free personal account. If you do not have access to an account simply follow along and complete the steps that you are able to. Please head to the Microsoft site
The following instructions have not been verified.
Procedure
  1. In the New Teams client, select Teams and navigate to the channel where you want to add an Incoming Webhook.

  2. Select More options ••• on the right side of the channel name.

  3. Select Manage channel.

  4. Screenshot shows the Manage channel option under More options for Teams 2.1

  5. Select Edit.

  6. Search for Incoming Webhook and select Add.

  7. Select Add.

If you’ve already added an Incoming Webhook, the Configure option appears. Select Configure to create an Incoming Webhook.
  1. Provide a name for the webhook and upload an image if necessary.

  2. Select Create.

  3. Screenshot shows the name and image fields to be filled to create the webhook.

  4. Copy and save the unique webhook URL present in the dialog. The URL maps to the channel and you can use it to send information to Teams.

  5. Select Done. The webhook is now available in the Teams channel.

Intergrate the Teams webhook into RHACS

Procedure
  1. Access the RHACS Console

  2. Go to Platform Configurations → Integrations

  3. Click on Microsoft Teams

  4. Click New integraton

  5. Give your webhook a name

  6. Paste the Teams Webhook

  7. Hit Test and hopefully recieve a "The test was successful" message.

Setup a Slack Integration

Create a Slack Webhook

Procedure
  1. Create a Slack App

  2. Log in to Slack: Go to the link: Slack API site and log in with your Slack credentials.

  3. Create a New App: Click on "Add Apps"

  4. Click on "From scratch" .

You will need to choose a name for the app and select the workspace where it will be used.

You can add features such as webhooks or bot users later, but for now, focus on setting up the Incoming Webhooks.
  1. Once your app is created, go to the app’s settings and find the "Incoming Webhooks" feature.

  2. Toggle Webhooks On: You will see an option to enable webhooks. Toggle it to “On” to allow incoming webhooks for your app.

  3. After enabling Incoming Webhooks, scroll down to the "Webhook URLs for Your Workspace" section.

  4. Add New Webhook to Workspace: Click the "Add New Webhook to Workspace" button.

A new window will open, allowing you to choose a Slack channel where messages sent by the webhook will appear. Authorize this action by clicking the "Allow" button after selecting the desired channel.

  1. Copy the Webhook URL: Once the webhook is authorized, a unique Webhook URL will be generated. You will use this URL in the next step.

Intergrate the Slack webhook into RHACS

Procedure
  1. Access the RHACS Console

  2. Go to Platform Configurations → Integrations

  3. Select Notifier Integrations → Slack

  4. Click the New integration button to set up a new notification system.

A new window will appear where you can choose the type of integration. Select Slack from the list.

You will need to configure the Slack integration by providing the following information:

Integration Name: Give your integration a name, like "Slack Webhook for Security Alerts." Webhook URL: Paste the Slack Webhook URL you generated earlier. Default Channel: This is typically auto-populated based on the webhook URL, but you can verify or specify the correct Slack channel. *Message Format: *Choose the format for your messages. This could be simple text, or you could customize it further using Block Kit if supported.

  1. Hit Test and hopefully recieve a "The test was successful" message.

08 not 1

Next we have to configure our policies to alert based on specific triggers.

Configure Notifications

Balancing security alerting in a team is crucial to ensure that the team is responsive to genuine threats while minimizing alert fatigue. RHACS enables this by letting you configure your alert channels and attach them to the policies you car about.

Let’s test this out. You will use the runtime enforcement policy that was used in the previous module.

Procedure
  1. On the left-hand side of the application, click the Platform Configuration tab and select Policy Management.

acs policy 00
  1. Filter through the policies to find Ubuntu Package Manager Execution or use the search bar to select Policy.

acs policy 01
  1. Once you have found the policy Ubuntu Package Manager Execution, click on the runtime enforcement policy you created earlier

08 not 2

There should now be a notifier option on the right hand side of the screen.

  1. Click your new webhook

  2. Save the policy

Next we are going to run the same runtime apt command as we did earlier.

  1. Run the following command in the terminal

POD=$(oc get pod -l app=ctf-web-to-system -o jsonpath="{.items[0].metadata.name}")
oc exec $POD -i --tty -- /bin/bash
[demo-user@bastion ~]$ POD=$(oc get pod -l app=ctf-web-to-system -o jsonpath="{.items[0].metadata.name}")
oc exec $POD -i --tty -- /bin/bash
node@ctf-web-to-system-6db858448f-hz6j2:/app$
If you see node@ctf…​ you’ve confirmed you have a shell and access to the Java application.
  1. Run the Ubuntu package manager in this shell:

apt update
  1. Examine the output and expect to see that the package manager attempts to perform an update operation:

Sample output

node@ctf-web-to-system-6db858448f-stwhq:/$ apt update
Reading package lists... Done
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)
node@ctf-web-to-system-6db858448f-stwhq:/$ command terminated with exit code 137
  1. Lastly, review your Slack or Teams channel for the alert.

08 not 3

Congrats!

A task to complete on your own.

You know the drill

giphy

Add the notifier to the Runtime Policy 'Netcat Execution Detected'. Enable enforcement of the policy and watch the "visa-processor" container for a violation. This container runs an nc command every minute or so.

Your mission is completed with a Notification to Slack or Teams.

Summary

giphy

Nice!

You integrations a webhook into RHACS and configured notifications based on previous policies.

Let’s go check out the RHACS API!