ecommerce-api/

directory
v0.0.0-...-9a10ecf Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2019 License: BSD-3-Clause

README ΒΆ

Vulnerable eCommerce API

Vulnerable eCommerce API is a simple Golang web application that contains an example of a Broken Access Control vulnerability and its main goal is to describe how a malicious user could exploit it.

Index

What is Broken Access Control?

Restrictions on what authenticated users are allowed to do are often not properly enforced. Attackers can exploit these flaws to access unauthorized functionality and/or data, such as access to other users' accounts, view sensitive files, modify other users’ data, change access rights, etc.

The main goal of this app is to discuss how Broken Access Control vulnerabilities can be exploited and to encourage developers to send secDevLabs Pull Requests on how they would mitigate these flaws.

Setup

To start this intentionally insecure application, you will need Docker and Docker Compose. After forking secDevLabs, you must type the following commands to start:

cd secDevLabs/owasp-top10-2017-apps/a5/ecommerce-api
make install

Then simply visit localhost:10005 ! πŸ˜†

Get to know the app πŸ’΅

To properly understand how this application works, you can follow this step:

  • Try registering a user and log in!

Attack narrative

Now that you know the purpose of this app, what could go wrong? The following section describes how an attacker could identify and eventually find sensitive information about the app or its users. We encourage you to follow these steps and try to reproduce them on your own to better understand the attack vector! 😜

πŸ‘€
Lack of userID validation allows for an attacker to get other users' tickets

In order to better understand how this API works, two users, user1 and user2, were created as shown below:

curl -s -H "Content-Type: application/json" -d '{"username":"user1","password":"pass"}' http://localhost:10005/register  
curl -s -H "Content-Type: application/json" -d '{"username":"user2","password":"pass"}' http://localhost:10005/register

Or using web interface:

The users created above are registered on MongoDB and we can get their userID through the following curl commands:

curl -s -H "Content-Type: application/json" -d '{"username":"user1","password":"pass"}' http://localhost:10005/login
curl -s -H "Content-Type: application/json" -d '{"username":"user2","password":"pass"}' http://localhost:10005/login

This can also be observed via the web interface. In the web interface it is possible to verify that after completing the login form, two requests are made to the API.

πŸ”₯

Having both userID, we can verify that the route "GET /ticket/:userID" does not validate if the request was made by the same user or someone else without the proper permission, as shown by the image:

curl -vvv http://localhost:10005/ticket/GUID

Secure this app

How would you mitigate this vulnerability? After your changes, an attacker should not be able to:

  • Access other users' tickets.

PR solutions

[Spoiler alert 🚨 ] To understand how this vulnerability can be mitigated, check out these pull requests!

Contributing

We encourage you to contribute to SecDevLabs! Please check out the Contributing to SecDevLabs section for guidelines on how to proceed! πŸŽ‰

Directories ΒΆ

Path Synopsis
app
db

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL