This project involves analyzing security vulnerabilities in a web application, identifying and fixing these vulnerabilities, and thoroughly testing the application to ensure it is secure. The primary focus was on SQL injection vulnerabilities and improving password storage security. This project highlights my SQL capabilities, risk assessment secure coding audits.
-
Database Examination:
- Utilized the
sqlite3
tool to examine the application's database. - Employed the
.schema
command for a comprehensive overview of the database structure. - Executed SQL queries directly at the command prompt and through DB Browser to examine the database contents.
- Utilized the
-
Application Execution:
- Launched the web application using the command
./gradlew run
(orgradlew run
for Windows). - Interacted with the application via a web browser at
http://localhost:8080
.
- Launched the web application using the command
-
SQL Injection Testing:
- Tested the application with various SQL injection payloads such as
' OR '1'='1
,' OR 1=1 --
, and others. - Recorded successful SQL injection attempts that resulted in unauthorized access and exposure of confidential patient data.
- Tested the application with various SQL injection payloads such as
-
Vulnerability Analysis:
- Identified the use of string concatenation to incorporate user-supplied input into SQL queries, making the application susceptible to SQL injection attacks.
- Found that passwords were stored as raw strings, posing a significant security risk.
-
Implementing Prepared Statements:
- Updated the
AppServlet
source file to use prepared statements. - Modified
AUTH_QUERY
andSEARCH_QUERY
variables to use placeholders (?
) and filled values using thesetString
method. - Ensured user-supplied values were treated as data rather than executable SQL code.
- Updated the
-
Code Modifications:
- Updated the
authenticated
method to execute the SQL query using a prepared statement. - Updated the
searchResults
method to execute the SQL query using a prepared statement.
- Updated the
-
Testing and Validation:
- Repeated the initial experiment to ensure the application was no longer susceptible to SQL injection attacks.
- Confirmed that the changes effectively prevented SQL injection vulnerabilities by treating input values as data parameters.
-
Modified Application:
- The application code was updated to use prepared statements, enhancing security against SQL injection attacks.
-
Report:
- A detailed PDF report (
report.pdf
) describing the analysis, the vulnerabilities identified, the fixes implemented, and the validation results.
- A detailed PDF report (
This project demonstrates the importance of secure coding practices, especially in handling user input and storing sensitive data. By implementing prepared statements and properly securing passwords, the application is now robust against SQL injection attacks, ensuring the protection of confidential patient data.