Giter VIP home page Giter VIP logo

automated-incident-response-with-ssm's Introduction

Introduction to performing automated incident response in a large, multi-account environment with exception handling

How quickly you respond to security incidents is key to minimizing their impacts. Automating incident response can help you scale your capabilities, rapidly reduce the scope of compromised resources, and reduce repetitive work by security teams. But when you use automation, you’ll also need to manage exceptions to standard response procedures.

This project provides a pattern and ready-made templates for a scalable multi-account setup of an automated incident response process with minimal code base, using native AWS tools. This project demonstrates how to set up exception handling for approved deviations based on resource tags.

Important: Use caution when introducing automation. Carefully test each of the automated responses because automating a sub-optimal incident response process could be counterproductive.

Solution

In this solution, you’ll use AWS Systems Manager Automation to execute most of the incident response steps. AWS maintains ready-made operational runbooks (automation documents), so you won’t need to maintain your own code base for them. The runbooks cover many predefined use cases, such as enabling Amazon Simple Storage Service (S3) bucket encryption, opening a Jira ticket, or terminating an Amazon Elastic Compute Cloud (EC2) instance. Every execution is well documented and repeatable in AWS Systems Manager. For a few common cases where there were no ready-made automation documents, It is provided three additional AWS Lambda functions with the required response actions in the templates in this post. The Lambda functions require minimal code, with no external dependencies outside AWS native tools.

The code and automation runbooks are implemented in a central security account. You will use the central security account to execute the incident response actions. You won’t need to take any actions in the service accounts where you’re monitoring and responding to incidents.

For more information please see our AWS Security Blog on How to perform automated incident response in a multi-account environment

How to deploy from Github

  1. Clone the repo with git clone [url]

Master Security Account

  1. Create a S3 bucket where the artifacts will be uploaded. Yor aws-cli-profile of master account must have read/write permission to the bucket. You can reuse existing bucket. It can be in the different region that the region you deploy.

  2. Adjust the Cloud Formation stack parameters in ./conf/master-acc.params.json. You must NOT modify the parameters S3BucketSources and S3SourcesPrefix as they are adjusted by deployment script.

  3. Deploy by executing ./scripts/deploy.sh with type parameter master, S3 bucket, aws-cli-profile and region. It will upload the artifacts to the S3 bucket and will deploy the Cloud Formation stack.

Usage: ./deploy.sh account_type[master|service] s3://bucket aws-cli-profile aws-region

Example of execution

./deploy.sh master s3://sources.sec.ir.sample SecMaster-2 eu-west-3

updating: isolate_ec2_lambda_function.py (deflated 61%)
updating: start_ssm_automation_lambda_function.py (deflated 57%)
updating: confine_secgr_lambda_function.py (deflated 64%)
updating: security_hub.py (deflated 55%)
updating: notify.py (deflated 42%)
updating: security_hub_custom_actions.py (deflated 68%)
updating: cfnresponse.py (deflated 58%)
updating: account_session.py (deflated 50%)
updating: session.py (deflated 51%)
updating: guard_duty.py (deflated 63%)
updating: deactivate_principal_lambda_function.py (deflated 67%)
upload: src/cfn/master-acc/master-account-custom-actions-sec-hub.yaml to s3://sources.sec.ir.sample/master/master-account-custom-actions-sec-hub.yaml
upload: src/cfn/master-acc/copy-s3obj-to-regional-s3bucket.yaml to s3://sources.sec.ir.sample/master/copy-s3obj-to-regional-s3bucket.yaml
upload: src/cfn/master-acc/master-account-main.yaml to s3://sources.sec.ir.sample/master/master-account-main.yaml
upload: dist/master_lambda_functions.zip to s3://sources.sec.ir.sample/master/master_lambda_functions.zip
resource uploaded successfully to s3://sources.sec.ir.sample

going to create-stack
arn:aws:cloudformation:eu-west-3:160815017796:stack/IR-master-account-stack/f29a6970-7299-11ea-bf0e-0e3a535926a2
Waiting for CF  stack to finish ..........................................
Stack IR-master-account-stack created (status CREATE_COMPLETE) 

Service Account

  1. Create or reuse a S3 bucket where the artifacts will be uploaded. Yor aws-cli-profile of service account must have read/write permissions to the bucket. You can reuse existing bucket for sure. It can be in the different region that the region you deploy.

  2. Adjust the Cloud Formation stack parameters in ./conf/service-acc.params.json. You must NOT modify the parameters S3BucketSources and S3SourcesPrefix as they are adjusted on deployment.

  3. Execute ./deploy.sh script with type parameter service, S3 bucket, aws-cli-profile and region. It will upload the artifacts to the S3 bucket and will deploy the Cloud Formation stack

Example:

./deploy.sh service s3://sources.sec.ir.sample SecEnv-2 eu-west-3
...
...

automated-incident-response-with-ssm's People

Contributors

amazon-auto avatar jsharpe avatar tzvetkov75 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

automated-incident-response-with-ssm's Issues

Make solution compatible with other partitions

Hello, I am a ProServe consultant working on a significant re-work of this solution. I am making this work in other partitions (testing in GovCloud).

Additionally, I am removing the option to enable Config and GuardDuty and will instead point to automated solutions to do this via docs for those services.

Since 2020 when this solution was published, the organization delegated admin features for these services coupled with multi-region aggregation of Security Hub will allow us to simplify this solution. I suggest that the deployment of Security Hub, Config, and GuardDuty be a prerequisite to this solution, and that this solution can be simplified in the member account to a single region (as the primary account is assuming a role and performing operations).

I will be submitting a pull request in the next few days but am opening this issue as directed by the CONTRIBUTING file.

Thanks!
Josh Moss

Unable to deploy service-acc main yaml CF template

Hi,

I am unable to deploy the service-acct main yaml file in a SH member account, getting this CF console response,

t-response-ssm-service-acct ROLLBACK_IN_PROGRESS The following resource(s) failed to create: [CondigEventForwarding, SecurityIRRole, RegionalS3Objects, AWSSystemsManagerAutomationExecutionRole, GDEventForwarding]. . Rollback requested by user.
2020-11-05 12:28:48 UTC-0500 SecurityIRRole CREATE_FAILED
2020-11-05 12:28:48 UTC-0500 AWSSystemsManagerAutomationExecutionRole CREATE_FAILED
2020-11-05 12:28:48 UTC-0500 GDEventForwarding CREATE_FAILED
2020-11-05 12:28:48 UTC-0500 CondigEventForwarding CREATE_FAILED
2020-11-05 12:28:47 UTC-0500 RegionalS3Objects CREATE_FAILED

Embedded stack arn:aws:cloudformation:us-east-1:xxyxxyxy:stack/automated-incident-response-ssm-service-acct-RegionalS3Objects-QV7TP1ZYMNUU/4f7767c0-1f8c-11eb-ae7e-0exxxxxx was not successfully created: The following resource(s) failed to create: [S3BucketRegionSources].

2020-11-05 12:28:43 UTC-0500 | GDEventForwarding | CREATE_IN_PROGRESS | Resource creation Initiated

Additionally, I have also attempted to execute the deploy script but my local pc env unable to handle the zip -jr switch,

$ ./deploy.sh service s3://xyz-bucket myprofile us-east-1

Command Line Error:
Unknown switch:
-jr

Thank you,

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.