Saturday, July 2, 2011

SQL injection

SQL injection is a technique that exploits a security vulnerability occurring in the database layer of an application. The vulnerability is present when user input is either incorrectly filtered for string literal escape characters embedded in SQL statements or user input is not strongly typed and thereby unexpectedly executed. It is in fact an instance of a more general class of vulnerabilities that can occur whenever one programming or scripting language is embedded inside another. SQL injection is a subset of Code injection.


Example:

SELECT * From tblStock WHERE Ticker = 'Enter Stock Ticker here'

However, assume that the user enters the following:

GOOG'; drop table tblStock-- ....in this case tblStock can be dropped

Best coding practise to prevent SQL Injection is as follow:

1. Validate all User Input

* Never build Transacent statement directlt from User Input

* When working with XML document, validate all data with its schema as sson as it is entered

2. Use parameterized Query

No comments:

Post a Comment

Open default email app in .NET MAUI

Sample Code:  if (Email.Default.IsComposeSupported) {     string subject = "Hello!";     string body = "Excellent!";    ...