Git Product home page Git Product logo

jovan-vukic / secure-gift-shop-app Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 19.04 MB

The Secure Software Development project fortifies the Christmas Gift Shop app by employing static analysis tools, mitigating SQL injection, XSS, and CSRF vulnerabilities, implementing robust authorization, and integrating DevOps practices like exception handling, logging, and auditing to enhance security.

License: MIT License

HTML 27.89% Java 72.11%
auditing csrf csrf-protection exception-handling logging sqlinjection xss xss-detection

secure-gift-shop-app's Introduction


Secure Gift Shop App

The project aims to enhance the security of the Christmas Gift Shop application. Tasks include utilizing static analysis tools for vulnerability assessment, addressing SQL injection and Cross-site Scripting vulnerabilities, implementing protection against Cross-site Request Forgery attacks, establishing some role-based authorization mechanisms, and integrating DevOps practices such as exception handling, logging, and auditing. Through these measures, the project seeks to fortify the application against potential security threats while promoting best practices in software security and development.
Explore the project »

Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Installation
  3. Contributing
  4. License
  5. Contact
  6. Acknowledgments

About The Project

The project focuses on enhancing the security aspects of the Christmas Gift Shop application, which facilitates gift browsing, rating, and purchasing functionalities. The application allows users to view, search, add, and review gifts, as well as manage user profiles.

Application user interface

Login page

Login page

View and search gifts

View and search gifts

Page to add a new gift

Add new gift

Details about a gift as well as comments and rating

Details about a gift as well as comments and rating

Users overview

Users overview

Details about a user

Details about a user

Static Code Analysis

The first part of the projects requires us to utilize SonarQube, a static analysis tool, to generate a comprehensive report identifying vulnerabilities and security hotspots within the project codebase. The report is attached to the project.

SQL Injection and Cross-site Scripting (XSS)

The second part of the project requires us to investigate potential XSS and SQL injection vulnerabilities in the comment form of the Gift Details page. We need to mitigate these vulnerabilities and document attack and defense strategies.

SQLi and XSS attacks demonstration

Entering malicious query in the gift comment section

Entering malicious query

As a result, a new user has been added into the database, with one of the attributes being an XSS script.

Entering malicious query

The XSS script is triggered during user search.

Entering malicious query
SQLi and XSS attacks mitigation

Mitigating attacks involves employing a parameterized query (PreparedStatement) within the CommentRepository class, alongside sanitizing input fields for comments through the introduction of the th:text attribute. Additionally, utilizing textContent instead of innerHTML in relevant sections of the persons.html page is crucial to prevent XSS attacks.

Cross-site Request Forgery (CSRF)

It is required next to demonstrate a CSRF attack by altering personal data of a user through a crafted script. Then we have to implement CSRF protection using tokens and document both the attack and defense mechanisms.

CSRF attack demonstration

Launching the attacker server on port 3000 ('npm start' command in the 'csrf-exploit' folder)

Starting the attacker server

Clicking on the trophy image triggers a CSRF attack, resulting in a successful HTTP request

Clicking on the trophy image

User with id equal to 1 has modified values for the 'First Name' and 'Last Name' attributes as a result of the successful attack

Attack success
CSRF attack mitigation

It is necessary to implement a mechanism for generating a CSRF token at the session level and embedding it into User Details HTML page, thereby rejecting unauthorized HTTP requests from the attacker server as they lack the required token.

Implementation of Authorization

The project requires us to implement permission matrix as defined in the permissions/roles table (in the project specification). Then we have to assign roles to users accordingly and ensure proper database configurations.

Creating new roles and associating them with specific users, as well as introducing new permissions, is done in the 'data.sql' file, where the corresponding relationships are inserted into the appropriate tables.

Subsequently, individual permissions are resolved on the frontend by hiding corresponding UI elements for users without permission, or on the backend through appropriate annotations and logical checks during the execution of relevant endpoints.

DevOps

It is required to implement exception handling and logging mechanisms throughout the application, focusing on the relevance and categorization of log messages. Then it is necessary to Introduce auditing functionalities to track user actions and ensure the non-repudiation of user actions.

Exception handling is resolved by creating catch branches at appropriate locations, where logging and auditing are performed depending on the operation that triggers the respective exception. Logging and auditing are also carried out in other relevant parts of the code.

(back to top)

Installation

To get a local copy up and running follow these simple steps. Setup:

  1. Clone the repository:
    git clone https://github.com/jovan-vukic/secure-gift-shop-app.git
  2. Build and run the program using your preferred IDE.

(back to top)

Contributing

Contributions are what makes the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

Contact

Jovan - @jovan-vukic

Project Link: https://github.com/jovan-vukic/secure-gift-shop-app

(back to top)

Acknowledgments

This project was done as part of the course 'Secure Software Development' (13M111RBS) at the University of Belgrade, Faculty of Electrical Engineering.

Used resources:

(back to top)

secure-gift-shop-app's People

Contributors

jovan-vukic avatar danko-miladinovic avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.