|
|
|
Forum Newbie
      
Group: General Forum Members
Last Login: Tuesday, August 19, 2008 5:17 AM
Points: 5,
Visits: 13
|
|
Hi we are not to keep our database or tables secured inspite of having password changed ,firewalls and spyware live. the hacker is injecting the java script code in the records of the tables . we found that code insertion is done at where the user is giving the input data. how to avoid this problem.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 11:06 AM
Points: 17,125,
Visits: 12,226
|
|
Parameterise all queries in your front end app. Do not concatenated together SQL statements and execute them.
Preferably, use stored procedures for data access only and do not allow the application user to have any rights to the base tables. The application user should have only execute rights on the stored procedures.
Gail Shaw
We walk in the dark places no others will enter We stand on the bridge and none may pass
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, March 18, 2010 9:36 AM
Points: 278,
Visits: 940
|
|
Hi,
Here are some recommendations for you:
1. Secure the Web Tier
You need to ensure that your application/website tier validates all user input before passing it on to the database layer. Rather than checking for invalid characters (quotations etc.), as there are potentially many, I recommend to my clients that they define a list of “valid” input values for their interfaces/forms etc.
2. Use Bound Parameters
In order to negate SQL Injection you need to ensure that any parameters that are passed to SQL calls are adequately bound.
3. Use Different Connections
Use different connections/logins for different tasks. I.e. the connection that is validating a user’s email address does not need to have update permissions to the database.I often recommend to clients that they use a connection/account with minimal privileges for all operations (i.e. logging a user into their system) unless otherwise necessary. Once a user has been authenticated they can be provided with access to/via another connection that has more privileges.
4. Use Stored Procedures
Use stored procedures to interact with your database rather than generating/building SQL dynamically.
Also take a look at the following Microsoft article: http://msdn.microsoft.com/en-us/library/ms161953.aspx
Hope this helps.
John Sansom | www.johnsansom.com | SQL Server DBA at Santech Solutions | www.santechsolutions.co.uk
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 9:01 PM
Points: 20,164,
Visits: 13,702
|
|
In other words, you will need to rewrite part of the app to use stored procedures instead of dynamic embedded SQL.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
"Data isn't the only thing that's supposed to have Integrity."
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Monday, November 30, 2009 10:12 PM
Points: 1,276,
Visits: 393
|
|
The best way to avoid SQL Injection is use of Stored Procedures.
Cheers, Hari
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Today @ 11:06 AM
Points: 17,125,
Visits: 12,226
|
|
Hari.Sharma (7/14/2008) The best way to avoid SQL Injection is use of Stored Procedures.
The only way to 100% for certain avoid SQL injection is to use properly parameterised queries or stored procedures.
And don't make the mistake of using stored procedures that dynamically build up SQL strings inside the proc and then exec it. Procs like that are just as vulnerable to SQL injection as dynamic string on the front end.
Gail Shaw
We walk in the dark places no others will enter We stand on the bridge and none may pass
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 7:10 AM
Points: 160,
Visits: 1,847
|
|
A decent overview with examples and links is in Earland Sommarskog's article here;
http://www.sommarskog.se/dynamic_sql.html#SQL_injection
There's a lot more out there covering in more detail, but IMO this is a good starting point for getting the basic idea hth Andrew
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Yesterday @ 4:15 AM
Points: 1,107,
Visits: 3,622
|
|
some brilliant links and advice there, way to go guys :D
-----------------------------------------------------------------------------------------------------------
"Ya can't make an omelette without breaking just a few eggs"
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Saturday, February 06, 2010 5:53 PM
Points: 138,
Visits: 265
|
|
I'd say GilaMonster has it right. Dynamic SQL in any form (in an application or in a stored procedure) is vulnerable to SQL injection. The safest and best place for SQL DML code is in the database as a stored procedure. You could think of the stored procedures as the methods to a database object. In the .NET world you don't grant access to the internal code and data structures except thru properties and methods, so don't treat your database differently. Never grant users the ability to select, insert, update or delete anything directly from a table or view. Only allow them to execute stored procedures.
This is a point of control for the data. Besides, you don't want to face a news crew (or your boss) to try and explain how the data was compromised. Especially since these practices have been best practices for over a decade.
--Paul Hunter
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Yesterday @ 9:01 PM
Points: 20,164,
Visits: 13,702
|
|
paulhunter (7/15/2008) In the .NET world you don't grant access to the internal code and data structures except thru properties and methods, so don't treat your database differently.
THAT is one of the best justifications for stored procedures that I've seen. Thanks, Paul.
--Jeff Moden "RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".
"Data isn't the only thing that's supposed to have Integrity."
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."
For better, quicker answers on T-SQL questions, click on the following... http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following... http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
|
|
|
|