sql-injection

How to parameterize complex OleDB queries?

对着背影说爱祢 提交于 2019-12-01 01:57:11
I'm trying to refactor some code that is using strings concatenation for creating SQL commands (which makes it vulnerable for a SQL injection). Basically all I'm trying to do is to replace all the string sqlToExecute = String.Format(..) statements with a SQL command and a List of OleDB parameters. I understand how this can be done for simple cases like String.Format("Select * from myTable where id = {0}", id) . However, I could not find a set of good examples for more complex SQL queries. Here are some of the queries that I'm not sure how exactly I can parameterize: 1. Parameters are used for

Does eliminating dangerous characters avoid SQL-injection?

心不动则不痛 提交于 2019-12-01 01:37:27
问题 Avoiding SQL-injections there are many ways How to prevent SQL injection in PHP?. The question is, how is it possible to sql-inject through removeBadCharacters ? function removeBadCharacters($s) { return str_replace(array('&','<','>','/','\\','"',"'",'?','+'), '', $s); } It tries to throw out dangerous characters (the application doesn't need those characters) : $x = removeBadCharacters($_POST['data']); mysql_query("insert into table (x) values ('".$x."');"); // or mysql_query("select * from

classic ASP protection against SQL injection

浪子不回头ぞ 提交于 2019-11-30 23:55:53
I've inherited a large amount of Classic ASP code that is currently missing SQL injection protection, and I'm working on it. I've examined in detail the solutions offered here: Classic ASP SQL Injection Protection On the database side, I have a Microsoft SQL server 2000 SP4 Unfortunately stored procedures are not an option. After studying php's mysql_real_escape_string ( http://www.w3schools.com/php/func_mysql_real_escape_string.asp ) , I've replicated its functionality in ASP. My question(s) are: 1) Does Microsoft SQL server 2000 have any other special characters that need to be escaped that

Is MySQL more resistant to SQL injection attack than PostgreSQL (under Perl/DBI)?

怎甘沉沦 提交于 2019-11-30 23:23:51
I am reviewing a Linux based perl web application that contains a login handler with the ubiquitous my $sth = $DB->prepare("SELECT password from passwords where userid='$userid'") or die; $sth->execute or die; ... where $userid is initialized from (unsafe, unfiltered) web user input. It is well known that the DBI documentation recommends that this code should be changed to use the placeholder "?" in place of '$userid' for security. This code was isolated on an off network box, as-is, for the purpose of a security review. Code like this on an internet server will eventually be cracked as there

How can I prevent SQL injection in PYTHON-DJANGO?

江枫思渺然 提交于 2019-11-30 23:03:48
问题 If a lamer input is inserted into an SQL query directly, the application becomes vulnerable to SQL injection, like in the following example: dinossauro = request.GET['username'] sql = "SELECT * FROM user_contacts WHERE username = '%s';" % username To drop the tables or anything -- making the query: INSERT INTO table (column) VALUES('`**`value'); DROP TABLE table;--`**`') What may one do to prevent this? 回答1: First, you probably should just use Django ORM, it will prevent any possibility of

how much safe from SQL-Injection if using hibernate

别来无恙 提交于 2019-11-30 22:30:51
问题 Does Hibernate guard against SQL injection attack ? If i am using hibernate then am i completely safe from SQL injection attack? I heard that Using Hibernate to execute a dynamic SQL statement built with user input can allow an attacker to modify the statement's meaning or to execute arbitrary SQL commands . 回答1: Does Hibernate guard against SQL injection attack? No, it doesn't guard the wrongly written ones , So you need to be careful when you write the queries. Always use the prepared

Rails methods vulnerable to SQL injection?

百般思念 提交于 2019-11-30 22:11:11
What are the Rails methods that are vulnerable to SQL injection, and in what form? For example, I know that where with a string argument is vulnerable: Model.where("name = #{params[:name}") # unsafe But a parameterized string or hash is not: Model.where("name = ?", params[:name]) # safe Model.where(name: params[:name]) # safe I'm mostly wondering about where , order , limit and joins , but would like to know about any other methods that might be attack vectors. In Rails, where , order , limit and joins all have vulnerable forms. However, Rails limits the number of SQL operations performed to 1

Detect SQL Injection

怎甘沉沦 提交于 2019-11-30 20:52:51
I came to a company that already has a fully grown project... but coders that worked here before me didn't follow conventions and didn't use parametrized SQL queries... as a result there is over 1000 places in a very huge project that can possibly be vulnerable to SQL injection... I need to find a solution that will automatically detect if there is an SQL injection in the code. So, for example there is a form which allows user to enter comments regarding a product, which will be sent to database on submit... how can we make sure that a user didn't enter a harmfull query instead of a normal

How to parameterize complex OleDB queries?

好久不见. 提交于 2019-11-30 20:18:58
问题 I'm trying to refactor some code that is using strings concatenation for creating SQL commands (which makes it vulnerable for a SQL injection). Basically all I'm trying to do is to replace all the string sqlToExecute = String.Format(..) statements with a SQL command and a List of OleDB parameters. I understand how this can be done for simple cases like String.Format("Select * from myTable where id = {0}", id) . However, I could not find a set of good examples for more complex SQL queries.

How do Django forms sanitize text input to prevent SQL injection, XSS, etc?

孤者浪人 提交于 2019-11-30 20:10:47
I don't see any form input sanitization in Django's form code w/r/t handling raw text. How does Django ensure that user input is sanitized when going into the database? Does it do this at all to prevent SQL injection, etc? User input is sanitized by the database driver automatically. Explicit user input sanitization is only ever required when you are trying to assemble a single string that contains both the SQL commands and also the data that you are trying to include; proper use of the Python DBAPI fully separates the commands and the data and you as a programmer should never have to worry