top of page
Search

Input Validation and SQL Injection

  • Writer: Abhilasha
    Abhilasha
  • Jul 12, 2024
  • 1 min read

Input Validation:

  • Input validation checks potentially dangerous inputs to ensure they are safe for processing within the code or when communicating with other components.

  • Without proper input validation, an attacker can craft inputs in unexpected forms, leading to altered control flow, resource control, or code execution.

SQL Injection:

  • Occurs when input is not sanitized properly, allowing an attacker to manipulate SQL queries.

Example Scenario:

  1. Vulnerability Identification:

  • In the SQLInjectionActivity.class, the raw query used is: java Copy code rawQuery("SELECT * FROM sqluser WHERE user = '" + localEditText.getText().toString() + "'", null());

  • This query concatenates user input directly into the SQL query without sanitization.

  1. Exploit Example:

  • Inputting diva' OR '1'='1 into the application causes the query to become: sql Copy code SELECT * FROM sqluser WHERE user = 'diva' OR '1'='1';

  • This always returns true, potentially exposing all user data in the sqluser table.

Key Points:

  • Input validation issues occur when applications do not sanitize user input, leading to client-side and server-side attacks.

  • Properly sanitize inputs to prevent such vulnerabilities.

Practical Steps:

  1. Identify and sanitize user inputs.

  2. Use parameterized queries or prepared statements.

  3. Avoid direct concatenation of user inputs into SQL queries.

In summary, always validate and sanitize inputs to prevent SQL injection and other related attacks.

4o

 
 
 

Recent Posts

See All
PE internals

Linked Libraries and Functions Imported Functions: Definition: These are functions used by a program that are actually stored in...

 
 
 
OS internals

Privilege Separation Concept: Modern operating systems separate user applications (untrusted) from critical operating system components...

 
 
 
Memory Management in short

Address Space CPU Access: To run instructions and access data in main memory, the CPU needs unique addresses for that data. Definition:...

 
 
 

Comments


Subscribe Form

Thanks for submitting!

©2021 by just dump 1. Proudly created with Wix.com

bottom of page