Task #12555

Task #12556: Pentest - 2nd Assessment [2021]

Pentest_IBAM - SQL Injection [HIGH]

Added by Nurul Athira Abdul Rahim almost 3 years ago. Updated about 2 years ago.

Status:Work Completed-End life cycleStart date:November 08, 2021
Priority:HighDue date:
Assignee:Nurul Athira Abdul Rahim% Done:

100%

Category:Penetration Test IssueSpent time:-
Target version:-

Description

SQL injection vulnerabilities arise when user-controllable data is incorporated into database SQL queries in an unsafe manner. An attacker can supply crafted input to break out of the data context in which their input appears and interfere with the structure of the surrounding query. A wide range of damaging attacks can often be delivered via SQL injection, including reading or modifying critical application data, interfering with application logic, escalating privileges within the database and taking control of the database server.

Solution provided by LGMS :
The most effective way to prevent SQL injection attacks is to use parameterized queries (also known as prepared statements) for all database access. This method uses two steps to incorporate potentially tainted data into SQL queries:

- The application specifies the structure of the query, leaving placeholders for each item of user input;
- The application specifies the contents of each placeholder.

Because the structure of the query has already been defined in the first step, it is not possible for malformed data in the second step to interfere with the query structure.

Review the documentation for the database and application platform to determine the appropriate APIs which can be used to perform parameterized queries. It is strongly recommended to parameterize every variable data item that is incorporated into database queries, even if it is not obviously tainted, to prevent oversights occurring and avoid vulnerabilities being introduced by changes elsewhere within the code base of the application.

Be aware that some commonly employed and recommended mitigations for SQL injection vulnerabilities are not always effective:

- One common defense is to double up any single quotation marks appearing within user input before incorporating that input into a SQL query. This defense is designed to prevent malformed data from terminating the string into which it is inserted. However, if the data being incorporated into queries is numeric, then the defense may fail, because numeric data may not be encapsulated within quotes, in which case only a space is required to break out of the data context and interfere with the query. Further, in second-order SQL injection attacks, data that has been safely escaped when initially inserted into the database is subsequently read from the database and then passed back to it again. Quotation marks that have been doubled up initially will return to their original form when the data is reused, allowing the defense to be bypassed.

- Another often cited defense is to use stored procedures for database access. While stored procedures can provide security benefits, they are not guaranteed to prevent SQL injection attacks. The same kinds of vulnerabilities that arise within standard dynamic SQL queries can arise if any SQL is dynamically constructed within stored procedures. Further, even if the procedure is sound, SQL injection can arise if the procedure is invoked in an unsafe manner using user-controllable data.

2021 BSN CDB Admin Portal Web Application Penetration Test Quick Results-v1.0.xlsx (2.19 MB) Nurul Athira Abdul Rahim, November 08, 2021 16:06

sc3.png (63.2 KB) Najmi Pasarudin, December 10, 2021 11:07

History

#1 Updated by Nurul Athira Abdul Rahim almost 3 years ago

  • Parent task set to #12556

#2 Updated by Najmi Pasarudin almost 3 years ago

  • Status changed from New - Begin Life Cycle to Development / Work In Progress

#3 Updated by Najmi Pasarudin almost 3 years ago

  • File sc3.png added
  • % Done changed from 0 to 90

Check the parameter SearchApprovable for boolean instead of injecting the parameter as String.
Refer sc3.png

#4 Updated by Najmi Pasarudin almost 3 years ago

  • Status changed from Development / Work In Progress to Internal Testing
  • Assignee changed from Najmi Pasarudin to Nurul Athira Abdul Rahim

#5 Updated by Nurul Athira Abdul Rahim almost 3 years ago

  • Status changed from Internal Testing to System Integration Test

#6 Updated by Najmi Pasarudin over 2 years ago

  • Status changed from System Integration Test to Pending Prod Deployment
  • Assignee changed from Nurul Athira Abdul Rahim to Najmi Pasarudin

#7 Updated by Najmi Pasarudin over 2 years ago

  • Status changed from Pending Prod Deployment to Pending Review
  • Assignee changed from Najmi Pasarudin to Nurul Athira Abdul Rahim

Production deployed on 4/3/2022

#8 Updated by Nurul Athira Abdul Rahim about 2 years ago

  • Status changed from Pending Review to Work Completed-End life cycle
  • % Done changed from 90 to 100

Also available in: Atom PDF