sql-injection

Is this stored procedure safe from sql injection?

This stored proc executes sql with parameters using sp_executesql. Is it safe from sql injection? create procedure ExecutePeopleFilter (@lastNameFilter varchar(20), @companyNameFilter varchar(20), @ageFilter int, @dateFilter datetime) as begin declare @sql varchar(4000) declare @params varchar(1000) decla...

How to put double quotes in ADO.NET query?

I am trying to prevent any SQL injection in all my queries and would like to know how to put double quotes in this query. Thanks string.Format("SELECT TOP 10 article_guid, article_title FROM article WHERE article.article_isdeleted = 0 AND FREETEXT(article_title, @val)"); ...

SQL Injection Protection - Cast from string to int

We all know that parameterized SQL is the way to go when dealing with user input and dynamic SQL, but is casting from string to int (or double, or long, or whatever) as effective if the input you are seeking is numeric? I guess what I am asking is if this technique alone is infallible in regards to SQL injection? ...

Error when replacing words that contain quotes in mySQL

I have updated many records already, but when it came to a word that contains a quote I get this error: "ERROR: Unclosed quote @ 1357" I know why it's giving me this error, I just don't how to solve it. Here's a sample: UPDATE invnum SET cAccountName = replace(cAccountName,'JOHN'S','BEN') Thanks in advance. ...

Basic SQL Injections?

I was told in a previous question that my query is prone to SQL injections. get_stats = mysql_query("SELECT * FROM visitors WHERE site='$_GET[site]' AND date BETWEEN '$start_date' AND '$end_date' "); What would be the easiest way to approac...

Are SQL Server 2008 Table Valued Parameters vulnerable to SQL injection attacks?

I have been investigating Table-Valued Parameters in SQL Server 2008, and I've discovered that when passing such a parameter to a stored procedure, a query such as the following is sent to the database server: declare @p1 dbo.MyTypeName insert into @p1 values(N'row1col1',N'row1col2') insert into @p1 values(N'row2col1',N'row2col2') inser...

Extract SQL query from a Web Page independent of the Scripting language

Hello friends. At present i am doing a project regarding SQL injection. I am doing it in such a way that it will find the SQL injection independent of the server side scripting.. whether it may be jsp or asp or php. Now the major problem is I have to extract the SQL query from the web page. That is when i press submit button for instance...

SQL Server - Dynamic PIVOT Table - SQL Injection

Sorry for the long question but this contains all the SQL I've used to test the scenario to hopefully make it clear as to what I'm doing. I'm build up some dynamic SQL to produce a PIVOT table in SQL Server 2005. Below is code to do this. With various selects showing the raw data the values using GROUP BY and the values in a PIVOT as I...

Can SqlServer be configured to not execute stored procs submitted as strings?

Scenario A: SqlConnection con = new SqlConnection(myConnString); SqlDataAdapter adp = new SqlDataAdapter("EXEC spGetUserInfo 42", con); DataSet ds; adp.Fill(ds); Scenario B: SqlConnection con = new SqlConnection(myConnString); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandText = "spGetUserInfo"; cmd.CommandType ...

Protection against SQL injection

Does the following PHP MySQL statement protect against SQL Injection? $strSQL = "SELECT * FROM Benutzer WHERE Benutzername = '".$Benutzer."' AND Password = '".md5($PW)."'"; The Variables $Benutzer and $PW are inputs from the User. We're checking the username and password against common SQL Injection techniques: ' or 0=0 --, " or...

Classic ASP SQL Injection

I recently inherited a classic asp website with a ton of inline SQL insert statements that are vulnerable to SQL injection attacks. These insert statements are executed via the ADO command object. Will setting the ADO Command Object's Prepared property to true ensure that the query is parameterized before execution, thus mitigating the...

Preventing SQL injection: is mysql_real_escape_string() really all I need?

Possible Duplicate: Best way to stop SQL Injection in PHP It seems far too good to be true to me that this simple function does all I need. Yet most of my google searches lead to results that basically say "just use this function and all will be well!". I've seen a couple that briefly, or at too high a level for my own beginner...

Is it possbile to write files with MySQL via SQL injection?

Long story short, we found files promoting prescription drugs on our server that we didn't put there. The Windows server has very old applications and runs MySQL 5.1.11. Beyond other security flaws, could SQL injection be used to write files to the server file system? I am certain that some of these old applications are vulnerable to SQ...

How does a PreparedStatement avoid or prevent SQL injection?

I know that PreparedStatements avoid/prevent SQL Injection. How does it do that? Will the final form query that is constructed using PreparedStatements will be a string or otherwise? ...

rails active record nuances and protecting against injection attacks

When I make a query... is there any meaningful difference between using a find_by helper or not? Are there any reasons I'm overlooking for opting for shorter lines of code when doing things like this? Booking.find_all_by_user_id(1, :joins => :confirmation) Booking.find(:all, :joins => :confirmation, :conditions => [ 'bookings.user_id...

Escaping with this PHP function is unsafe?

Hi, If I escape data with addcslashes($input,chr(0x00) . chr(0x0d) . chr(0x0a) . chr(0x1a) . chr(0x5c) . chr(0x27) . chr(0x22)); would that be enough to stop SQLi? I have all required characters there, so, as long as the $input is UTF-8, there should be no problems with that itself. Of course invalid use of the method or something si...

common validation mistakes in flash

i know the drill to find XSS and injection at sites made with javascript, php, java, mysql... Basically, I know how to write the bugs, so i know to find them. Now i'm evaluating a product which the frontend is flash. what are the common mistakes I should be looking? ...

Dynamically created SQL vs Parameters in SQL Server

If I were to select a row from a table I basically have two options, either like this int key = some_number_derived_from_a_dropdown_or_whatever SqlCommand cmd = new SqlCommand("select * from table where primary_key = " + key.ToString()); or use a parameter SqlCommand cmd = new SqlCommand("select * from table where primary_key = @pk")...

Does Code Igniter automatically prevent SQL injection?

I just inherited a project because the last developer left. The project is built off of Code Igniter. I've never worked with Code Igniter before. I took a quick look at the code and I see database calls in the controller like this: $dbResult = $this->db->query("SELECT * FROM users WHERE username = '".$_POST['user_name']."'"); or c...

Multiple values in where with prepared SQL-Statements?

Is there a way to select multiple values with prepared statements in (My-)SQL? I'm trying to select a couple of rows from a table with the IN-keyword, something like: SELECT * FROM table where id IN (1, 2, 3) The "1, 2, 3" should be passed as a parameter of the statement. Is this possible with PHP/PDO or do I have to concaterate...