Enterprise-CMCS / macpro-quickstart-serverless

Other
18 stars 14 forks source link

Fix command injection vulnerability in `avScan` function #556

Closed ben-harvey closed 2 years ago

ben-harvey commented 2 years ago

Purpose

In this list of the top ten security vulnerabilities for serverless applications, number one is event data injection. This is a risk because lambdas run in response to input from all kinds of sources: not just user input, but also event data from other AWS services.

The attachments S3 bucket has permission to invoke the avScan lambda when new attachments are uploaded. The S3 event contains the file name of the uploaded attachment, and the lambda runs the virus scanner CLI with execSync, interpolating the file name.

That leaves the lambda vulnerable to an injection attack. By uploading a file with the name foo; echo You can run arbitrary commands since the file name for the virus scan function is unsanitized >&2; echo .pdf, you can run this command, or any arbitrary Bash command. image (1)

It's unlikely that a user of a MACPro application would be malicious, but best practices dictate that this vulnerability should be mitigated.

Linked Issues to Close

Approach

This change includes several mitigations:

Learning

Testing

I deployed the changes to the ui-src and uploads services and

Pull Request Creator Checklist

Pull Request Reviewer/Assignee Checklist

mdial89f commented 2 years ago

Like another PR, I'm not sure why the Deploy check didn't get picked up when i brought your fork into a same named branch. In any event, Deploy passed.