Skip to content

Automate malware scanning of incoming files to your Amazon S3 bucket before processing

0

Hi Vijay/community,

Thanks for this article (https://repost.aws/articles/ARenp6XtBKQECpPcZAtnLK4A/automate-malware-scanning-of-incoming-files-to-your-amazon-s3-bucket-before-processing), it has been very helpful! I am having some trouble that I would like to see if you can help me with.

Here is where I am at:

  1. I have GuardDuty successfully tagging malware files.
  2. I have created the step function and have modified it slightly. I think this is working correctly. I removed the rule for clean files as I didn't want them to be moved.
  3. I am struggling to create the EventBridge rule so that it runs after a scan is complete and malware is found. I haven't created one of these before so need some steps please.

What I am trying to do is:

  1. If a malware file is found, tag it.
  2. Then move it to a new bucket that I have created and delete it from the original upload location.
  3. Send an email alert that malware was found.
  4. If no malware is found, ignore and do nothing.

Can you please let me know what I need to do and if I am missing any other steps?

2 Answers
0

Hello.

If a malware file is found, tag it.

This is a feature of GuardDuty Malware Protection.
https://docs.aws.amazon.com/guardduty/latest/ug/how-malware-protection-for-s3-gdu-works.html

Then move it to a new bucket that I have created and delete it from the original upload location.

When malware is found, an event with "scanResultStatus" of "THREATS_FOUND" is issued.
https://docs.aws.amazon.com/ja_jp/guardduty/latest/ug/monitor-with-eventbridge-s3-malware-protection.html#s3-object-scan-status-malware-protection-s3-ev

Therefore, by setting an event rule in EventBridge as shown below, it is possible to isolate files to another location by running Lambda via EventBridge when malware is detected.
EventBridge can execute not only Lambda but also StepFunctions.
In your case, you are using StepFunctions, so you can target EventBridge to StepFunctions.

{
  "detail-type": ["GuardDuty Malware Protection Object Scan Result"],
  "source": ["aws.guardduty"],
  "detail": {
    "scanResultDetails": {
      "scanResultStatus": ["THREATS_FOUND"]
    }
  }
}

Send an email alert that malware was found.

If you also set up Amazon SNS when setting up EventBridge above, you can send email notifications.

If no malware is found, ignore and do nothing.

The above EventBridge rule is a rule that matches when malware is found, so it will not react otherwise.

The following AWS blog explains in detail how to implement it.
https://aws.amazon.com/jp/blogs/security/using-amazon-guardduty-malware-protection-to-scan-uploads-to-amazon-s3/

EXPERT

answered 2 years ago

EXPERT

reviewed 2 years ago

0

Hi,

To your question, you have here a step-by-step guidance on how to create an EventBridge rule for GuardDuty: https://repost.aws/knowledge-center/guardduty-eventbridge-sns-rule

You should use to create the proper rule for malware detection as suggested by Riku in his answer

Best,

Didier

EXPERT

answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.