A simple Todo application built with ASP.NET Core 9.0 and Microsoft Aspire, featuring SQL Server database integration. This application intentionally demonstrates bad security practices for educational purposes.
This application contains intentionally bad security practices for educational demonstration only. DO NOT use this code in production applications!
- Create new todo items with title and description
- Mark todo items as complete/incomplete
- Delete todo items
- View all todo items with creation and completion timestamps
- Responsive Bootstrap UI with Bootstrap Icons
- SQL Server database integration via Microsoft Aspire
- SQL Injection vulnerabilities in all database operations
- Poor password hashing using MD5 (cryptographically broken)
- Exposed password hashes in user interface
- No input validation or sanitization
- Poor session management
- Internal error exposure to users
- No access control or authorization
- AppHost1: Microsoft Aspire Application Host that orchestrates the distributed application
- WebApplication1: ASP.NET Core MVC web application with Entity Framework Core
- Database: SQL Server database managed by Aspire
- .NET 9.0 SDK
- Docker (for running SQL Server container)
-
Clone the repository
git clone <repository-url> cd not-secure1
-
Run the Aspire Application Host
cd AppHost1/AppHost1 dotnet runThis will:
- Start a SQL Server database container
- Launch the web application
- Open the Aspire dashboard in your browser
-
Access the Application
- Web Application: http://localhost:8081
- Aspire Dashboard: http://localhost:8080
Id(int, Primary Key)Title(string, Required, Max 200 characters)Description(string, Optional, Max 1000 characters)IsCompleted(bool)CreatedAt(DateTime, UTC)CompletedAt(DateTime?, UTC, nullable)
Id(int, Primary Key)Username(string, Required, Max 50 characters)Password(string, Required, Max 100 characters) - MD5 hash (BAD!)Email(string, Required, Max 100 characters)CreatedAt(DateTime, UTC)IsActive(bool)
- Location:
BadSecurityService.cs - Vulnerable Methods:
GetUserByUsername,SearchUsers,CreateUser,DeleteUser - Example Attack:
' OR '1'='1in username field - Impact: Unauthorized access, data manipulation, potential data loss
- Algorithm: MD5 (cryptographically broken)
- Salt: None used
- Storage: Plain text hashes exposed in UI
- Vulnerability: Rainbow table attacks, hash cracking
- No sanitization of user inputs
- No validation of data types or formats
- Direct concatenation of user input into SQL queries
- Internal errors exposed to users
- Stack traces potentially revealed
- Database structure information leaked
- Poor session configuration
- No proper logout functionality
- Session fixation vulnerabilities
- Bypass Authentication: Use
' OR '1'='1as username - Drop Table: Use
'; DROP TABLE Users; --as username - Union Attack: Use
' UNION SELECT 1,2,3,4,5,6 --as username
- View Password Hashes: Check user details page
- Crack MD5: Use online MD5 crackers with exposed hashes
- Rainbow Table: Look up common password hashes
The application automatically creates the database and tables on first run using context.Database.Migrate().
- Backend: ASP.NET Core 9.0, Entity Framework Core
- Database: SQL Server with Microsoft.Data.SqlClient
- Frontend: Bootstrap 5, Bootstrap Icons
- Orchestration: Microsoft Aspire
- Container: Docker
├── AppHost1/ # Aspire Application Host
│ └── AppHost1/
│ ├── AppHost.cs # Application orchestration
│ └── AppHost1.csproj # Project configuration
├── WebApplication1/ # Web Application
│ ├── Controllers/
│ │ ├── HomeController.cs
│ │ ├── TodoController.cs
│ │ └── UserController.cs # VULNERABLE - Bad security practices
│ ├── Data/
│ │ └── ApplicationDbContext.cs
│ ├── Models/
│ │ ├── ErrorViewModel.cs
│ │ ├── TodoItem.cs
│ │ └── User.cs # User model with exposed password
│ ├── Services/
│ │ └── BadSecurityService.cs # VULNERABLE - SQL injection demo
│ ├── Views/
│ │ ├── Shared/
│ │ │ └── _Layout.cshtml
│ │ ├── Todo/
│ │ │ ├── Index.cshtml
│ │ │ └── Create.cshtml
│ │ └── User/ # VULNERABLE - Exposed password views
│ │ ├── Index.cshtml
│ │ ├── Create.cshtml
│ │ ├── Login.cshtml
│ │ └── Details.cshtml
│ └── Program.cs
└── AppHost1.sln # Solution file
This application is designed to demonstrate common security vulnerabilities in web applications. It serves as a learning tool for:
- Understanding SQL injection attacks
- Recognizing poor password security practices
- Learning about input validation importance
- Understanding proper error handling
- Learning secure session management
Remember: Never use these techniques in production applications!