Questions tagged [sql-injection]

SQL injection is a code injection technique, used to attack data-driven applications, in which malicious SQL statements are inserted into an entry field for execution (e.g. to dump the database contents to the attacker).

SQL injection exploits a type of computer security vulnerability found in applications with SQL databases. It enables attackers to apply malicious SQL commands to the database via user input. It can for example extract, alter or delete sensitive data.

The vulnerability is present when user input is used directly in the SQL commands, instead of as parameters or properly filtered (also known as "sanitized", e.g. by quoting escape characters). It happens primarily because of poorly written SQL handling functions in client applications.

See famous example - Bobby Tables incident and the community wiki question's answer How can I prevent SQL injection in PHP?

Useful Links

3768 questions
1
vote
1 answer

How to escape sql injection from HANA placeholder

I have some HANA queries which use PLACEHOLDER input and of course I want to prevent an sql injection. I try to use ? in odbc_prepare() $query = <<
d0niek
  • 218
  • 1
  • 12
1
vote
2 answers

Making MySQL queries safe for database insertion (strings)

Possible Duplicate: Practises for getting information from $_GET/$_POST and saving it to a database? Just wondering what exactly I should look out for with regards to safety in MySQL database insertions for users entering strings. Currently all…
JDS
  • 16,388
  • 47
  • 161
  • 224
1
vote
1 answer

Create a trigger on compile

To prevent SQL injection, I want to validate all Varchar parameters of procedures, user functions and packages. Is it possible to create a trigger when compiling or creating a new stored procedure or a user function to force all developpers to add…
Bilel Chaouadi
  • 903
  • 1
  • 10
  • 28
1
vote
3 answers

How do I build a parameterized PDO statement in PHP for a dynamic query?

Apologies if this has been asked already. I've seen answers regarding static SQLs, but in this case I'd like to use PDO->prepare() for a query string that is built dynamically at runtime. Breaking down into a simple example: $TempSQL = "SELECT…
Barry
  • 492
  • 1
  • 4
  • 12
1
vote
1 answer

MongoDB NoSQL Injection - Node.js

I'm using MongoDB 4.2 with Express > 4. I'm trying to execute a NoSQL Injection using node.js. This is the .ejs code of a form with username and password:
1
vote
1 answer

Vulnerability to SQL injection even when SQLite3::escapeString() is used and no user input is asked?

I am referring to this answer of mine to another question, which another user criticized because vulnerable to SQL injection, even if no user input is requested and escape procedure is called. The following code is used to create a .sql dump of an…
ephestione
  • 43
  • 9
1
vote
1 answer

Bypassing SQL Character Blacklist Filtering

I am working on a cyber security course containing a challenge on a SQL Server 2000 host. I have leaked an asp file containing the source for the login page that contains a hardcoded query that takes the username and password from the user and…
3therk1ll
  • 2,056
  • 4
  • 35
  • 64
1
vote
1 answer

How to create a database programmatically and injection-safe?

Non-DDL-statements can and under all circumstances should be protected against SQL injection. In JDBC this is done with PreparedStatement and CallableStatement which allow parameter insertion, but can't be used for DDL statements. The third is…
Kalle Richter
  • 8,008
  • 26
  • 77
  • 177
1
vote
1 answer

When (and why the when) and how should I sanitize data from POST JSON in php (such that output usable in Swift AND HTML)

The past couple of days, I’ve read through a lot of resources on the sanitization of input and output data with PHP to prevent (most prominently) XSS and SQL injection, i.a. a bunch of question on SO. At this point, however, I feel like I am more…
Moritz
  • 745
  • 1
  • 10
  • 32
1
vote
5 answers

How to Prevent SQL Injection in Oracle SQLPlus?

Obviously if I am using JDBC/ODBC, I can use bind variables and prepared statements to prevent SQL injection. However, when data is passed to batch processes that end up invoking Oracle SQLPlus, is there a way to prevent SQL injection? For…
1
vote
0 answers

why it does't work when i use group_concat in floor() sql error injection

When I try to use the sql error injection of some no-echo situation,i find it works, when i use group_concat in my query,but it should be a error so that i can get the error information. The correct usage is: select count(*), concat( …
thinksoso
  • 13
  • 4
1
vote
1 answer

Apache: log storage into MySQL

Method 1: Pipe Log Recently I've read an article about how to save Apache log in MySQL database. Briefly, the idea is to pipe each log to MySQL: # Format log as a MySQL query LogFormat "INSERT INTO apache_logs \ set ip='%h',\ datetime='%{%Y-%m-%d…
Mark Messa
  • 440
  • 4
  • 22
1
vote
4 answers

Practices for getting information from $_GET/$_POST and saving it to a database?

What are today's best practises when it comes to getting information from a get/post and saving information to a database? Is data still escaped like it used to or are there additional practises? Also, where can HTMLPurifier fit in this? I'm…
James P.
  • 19,313
  • 27
  • 97
  • 155
1
vote
1 answer

Parameterized Dynamic Queries / SQL Sanitation NodeJS

I am fairly new to node and have a problem with dynamic parameterized queries using sqlstring. The issue with the below code is that filters are optional depending on what a user passes into the function so the order of them can change (making it…
Jeff
  • 13
  • 3
1
vote
1 answer

How to prevent sql injection in JPA

I am using below jpa code. How can we prevent below code from sql injections? List docs= em.createQuery("SELECT c FROM Document c WHERE c.docId = :docId ", Document.class) .setParameter("docId",…