exploit-workshop

exploit-workshop

156 Stars

A step by step workshop to exploit various vulnerabilities in Node.js and Java applications

snyk-labs
May 27, 2025
156 stars
Category
Vulnerable-labs
GitHub Stars
156
Project Added On
May 27, 2025
Contributors
4

exploit-workshop

In this step by step workshop you’ll learn how to exploit various real world vulnerabilities existing in vulnerable versions of packages in a Node.js and Java application.

Required software you need to install for this workshop

You can do this workshop in 2 different flavours
* Using the prepared Docker images

OR

An introduction to this workshop

This workshop will lead you through installing and exploiting a number of intentionally vulnerable applications. The applications will use real world packages with know vulnerabilities, including:

  • Directory traversal
  • Regular expression denial of service (ReDoS)
  • Cross site scripting (XSS)
  • Remote code execution (RCE)
  • Arbitrary file overwrite (Zip Slip)

These exploits exist in a number of applications, most of which you will need to install either locally or on a cloud instance. The instructions below will walk you through the local installations, but you are more than welcome to try them out on remote cloud instances also.

For each vulnerability section in this workshop, you’ll be given information about the vulnerability as well as the package it exists in. You are encouraged to attempt to hack the application by trial and error without reading any hints at first. Try to think how you can trick the application sanitization and get into the mind of a hacker. The hints are there for when you get stuck so read them in order as and when you need a helping hand. If you can complete the hack without hints, that’s great! However it can be good to read the hints afterwards to make sure you broke in the same way we did! Plus there could be little tips in there to learn from also.

Goof installation

Depending on your choice before pick the appropriate install manual
using Docker Images
install on Local machine

From your browser of choice, navigate to http://localhost:3001 and you should see the following page.

Goof homepage

Take a few minutes playing with the site, and in particular, create a few todo items, using regular text “Buy Milk” as well as using markdown “Buy **lots** of milk”. Also navigate to the very modest about page linked to from the bottom of the homepage. Delight in the CSS-foo used to create this about page. Note: PRs sent that make this page look nicer will not be merged ;o)

Goof about page

Scan your application

First of all, let’s look at it from the blue (defensive) side.
Fork the goof application to your own github account. The application can be found on GitHub here: https://github.com/snyk/goof.
We need to scan our application to understand the direct and indirect dependencies that exist in the application, as well as the vulnerabilities in each library. To do this, navigate to https://snyk.io and click “Sign up” or “Log in” (if you’re already a user), on the top right of the site:

Login button

Click the “Log in with your GitHub” button:

Google Log in button

Next, import the goof project that you just cloned previously. Select goof from your GitHub repo list and click the “Import Projects” button on the top right of the window.

GitHub projects

When the project has been scanned you’ll see it in your dashboard:

Project Dashboard Goof

Click the package.json link to see the project page, which includes the full list of security vulnerabilities:

Project vuln page

You can click on the issues and dependencies tabs to see more information about the vulnerabilities and their remediation as well as where they are being introduced by your application. You’ll notice towards the bottom of the vulnerability listing there is a directory traversal vulnerability in the st package. Let’s look at this in more detail.

st directory traversal vuln

Directory Traversal

A Directory Traversal attack (also known as path traversal) aims to access files and directories that are stored outside the intended folder. By manipulating files with “dot-dot-slash” (../) sequences and its variations, or by using absolute file paths, it may be possible to access arbitrary files and directories stored on file system, including application source code, configuration, and other critical system files.

Directory Traversal vulnerabilities can be generally divided into two types:

  • Information Disclosure allows the attacker to gain information about the folder structure or read the contents of sensitive files on the system.
  • Writing arbitrary files: Allows the attacker to create or replace existing files. This type of vulnerability is also known as Zip-Slip.

The package in the goof application which contains a directory traversal vulnerability which we will exploit is the st package. Take a look at the st docs and familiarise yourself with the library.

You should now be aware of what directory traversal is, what the st package does and can go ahead and hack the application – you’re back on the red team now! Look around the application for where the st package might be used and try to traverse to a directory you should not be allowed to access.

Here are some hints to give you clues if you get stuck - try your best to only look at them once you’ve had a try yourself already and need help.

Click to see Hint 1.

Click to see Hint 2.

Click to see Hint 3.

Click to see Hint 4.

Click to see Hint 5.

Click to see Hint 6.

Click to see Hint 7.

Click to see Hint 8.

Click to see Hint 9.

Navigate your filesystem as if you were an attacker to find 3 pieces of sensitive information on your machine that you perhaps wouldn’t want an attacker to see.

Click to see Hint 10.

Take a look at the vulnerability description, including the CVSS score: https://snyk.io/vuln/npm:st:20140206. Why do you think the vulnerability is a medium severity, rather than high?

Remediate the vulnerability

Back on the snyk project page, find the directory traversal vulnerability in the st package and look at the remediation advice. You’ll see there’s only a single path to this vulnerability in the application, and the st package is a direct dependency, so remediation shouldn’t be too tricky. We can see that we need to update the version of the st package to 0.2.5. We can do this automatically, by clicking the “Fix this vulnerability” button.

Fix this vulnerability

You’ll see a list of your vulnerabilities, and only the st vulnerability should be selected. Scroll down to the bottom of the page and click “Open a fix PR”:

Open a fix PR

Take a look at the code changes in the pull request under the “Files Changed” tab:

PR tests

Make sure your new PR tests do not introduce any new security or licence issue have passed. These can be found in the conversation tab of the PR:

PR tests

When you’re happy with the PR, merge the changes.

Local machine install only (This will not work when you are using the Docker images)

If you’re running the application locally stop it by hitting Ctrl+C in the window you ran npm start. Get the latest code from GitHub by running git fetch. Download the new version of st by running npm install and then start your application again, using npm start.

Try your hacks again. Congratulations!, you’ve remediated the vulnerability and should now be redirected to the homepage each time you try to break free of the public folder.

Regular expression denial of service (ReDoS)

Take a look at the description of a ReDoS vulnerability in your Snyk scan:

ReDoS vuln information

This vulnerability in the ms package will be the one we will break in the goof application. Use the following command to add a todo item that contains a string representation of time:

$ echo 'content=Call mom in 20 minutes' | http --form http://localhost:3001/create -v

The ms library has matched a time pattern in your content input string. This is represented slightly differently on the goof webpage.

Call mom image

Using your knowledge of how ReDoS works, try to pass a content string that causes a noticeable delay, or a denial of service for other users. Note that while the request is being processed, the webpage will buffer any of your further requests until your first request is handled.

Click to see Hint 1.

Click to see Hint 2.

Click to see Hint 3.

Click to see Hint 4.

Click to see Hint 5.

Think about how might programmatically avoid this attack in your application code?

Remediate the vulnerability

Back on the snyk project page, find the regular expression denial of service vulnerability in the ms package and look at the remediation advice. You’ll see there’s only a single path to this vulnerability in the application, and the ms package is an indirect dependency, being pulled in by the humanize-ms package. We can see that we need to update the humanize-ms version to 1.0.2. This will pull in the ms package at a fixed version. Click “Fix this Vulnerability” again and create a PR.

Fix this vulnerability

After updating your application, try your hacks again. Congratulations!, you’ve remediated the vulnerability!

Cross Site Scripting (XSS)

... Content truncated. Click "See More" to view the full README.

Tool Information

Author

snyk-labs

Project Added On

May 27, 2025

License

Open Source

Tags

security tool