Code Monkey home page Code Monkey logo

alerting-securityhub-findings's Introduction

Alerting AWS Security Hub Findings

Terraform code that creates a solution for sending emails with Security Hub Findings. It implements the following resources:

  • EventBridge Event Rule --> Two Events Rule. One for monitoring Security Hub Findings and one for executing daily deletion of resolved findigns.
  • Step Function --> Serverless workflow for analyzing all the findings registered in Security Hub.
  • Lambda Function --> Four Lambda Function. Three of them are integrated into Step Functions and the other is for daily execution.
  • DynamoDB Table --> Table that keeps records of all active findings.
  • Cloudwatch Log Group --> Log Groups containing Lambda execution logs.
  • IAM Role --> Six IAM Roles for handling Lambda, DynamoDB and Step Functions Permissions.
  • SES Identity --> Verified identities for sending and receiving the findings emails.

High Level Architecture

HLA

How It Works

  1. An Event Rule monitors Security Hub Findings. These Findings are filtered by source service. Currently this solution supports findings originated in Security Hub (CIS and Foundational benchmarks), GuardDuty and Inspector.

  2. When the Event Rule detects an Event it triggers a Step Function State Machine Workflow.

  3. If the Finding is new or if it has been active for more than 15 days, it sends an Email to Operations, extracting the most important attributes of the json event and formatting the email in HTML, to make it more human readable.

  4. Additionally, a lambda is run on a daily basis checking, for each item in the dynamodb table, whether it is still active in the security hub or not. If it is no longer active, it removes the item from the table.

Why is this solution necessary?

Security Hub alerts for each finding of the services you have integrated but the same finding can be logged several times before being resolved so if you send an email to the support team for each finding, they will find duplicate findings so, to avoid spam, I have set up a workflow with step functions to alert only about findings that are not repeated and are still active.

Step Function State Machine Workflow

HLA

  1. The first Lambda Function checks if the finding item is in the DynamoDB table. If it is not there, it means it is a new finding so it adds the item to the table, sends the event to the next Lambda which will parse the event in HTML and send it to the operations teams via SES.
  2. If the item exists it means that the finding is duplicated and it is still active in Security Hub so another Lambda Function is executed to check if the finding has been active for more than 15 days. If yes, it execute de parse HTML Lambda to notify the support team and if the finding has been active for less than 15 days, it does noting.

Usage

  1. Clone the repository

    $ git clone https://github.com/lorenzocampo/alerting-securityhub-findings.git
    
  2. Initialize a working directory containing Terraform configuration files:

    $ terraform init
    
  3. Create an execution plan, which lets you preview the changes that Terraform plans to make to your infrastructure

    $ terraform plan
    
  4. Executes the actions proposed in a Terraform plan

    $ terraform apply
    

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.