How ptdat4823/sql-injection-demo works
Project Type and Purpose
• This is a full-stack demonstration app intended to showcase SQL injection vulnerabilities.
• The project is divided cleanly between a front-end (client-side UI built in TypeScript/React using Vite) and a back-end (Node.js server handling API requests and database connectivity) along with an external SQL script that likely sets up the vulnerable database.
• The focus is on login/authentication (note files like “services/auth.js”, “front-end/src/Login.tsx”, and “database/sql_injection_dtb_account.sql”) and JWT handling, making security concerning SQL injection central to the demo.
File Structure
• Top-level directories:
• “front-end”: Contains the client-side code (React components, contexts, styling, and build configuration) which handles the user interface and client interactions.
• “back-end”: Contains server code including configuration files (in “config”), database utilities (in “database”), and service logic (in “services” for authentication and JWT management). The “index.js” is the entry point.
• “database”: Includes at least one SQL script for setting up a database table with an obvious SQL injection vulnerability.
• The naming and organization suggest the back-end is broken into concerns around configuration, database access/utility functions, and service logic for authentication and JWT token generation.
• The front-end clearly separates application assets, configuration, and source code.
a. Front-End Component:
• Details like “React / TypeScript” and “Vite” configuration, and note key UI components such as “Login”, “Home”, and shared context (“AuthContext”).
b. Back-End Component:
• Inside it, break down:
• “Configuration”: Highlight the existence of database configuration (config/database.js).
• “Database Layer”: Represent the modules (auth.js, util.js) responsible for interfacing with SQL.
• “Services”: Identify the authentication service and JWT management (services/auth.js and services/jwt.js).
• Entry point (“index.js”) as the central starting point.
c. Database Component:
• That there is an external SQL script (sql_injection_dtb_account.sql) used for setting up the vulnerable table, and mention that this is the interaction point for SQL queries from the back-end.
Relationships and Data Flow
• From “Front-End Client” to “Back-End Server” indicating API calls (likely REST or similar) for login and data submission.
• From “Back-End Server” to “SQL Database” indicating SQL query interactions (especially in the authentication process, which could be vulnerable to SQL Injection).
• That the “Back-End Server” both authenticates users and issues JWT tokens (connecting the “Auth Service” and “JWT Service”).
Architectural Patterns / Design Principles
• Separation of concerns:
• Client-side and server-side responsibilities are clearly divided.
• Within the back-end, configuration, database utilities, and services are separated into distinct modules.
• That the system is built for demonstration purposes – showcasing how a typical login flow might be exploited by SQL injection if proper sanitization is not performed.
Relevant Technologies and Libraries
• Front-End: React, TypeScript, Vite, ESLint for style enforcement.
• Back-End: Node.js (with Express may be assumed though not explicitly seen), JWT for token management.
• Database: An SQL database configured via the provided SQL script.