LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 11-24-2015, 11:21 PM   #1
MyFriendTal
LQ Newbie
 
Registered: Mar 2015
Location: Montreal, Canada
Distribution: Debian
Posts: 1

Rep: Reputation: Disabled
MySQL Injection vs Programming practice


Is prepared queries are a good way (or best) to counter SQL Injection?

Does prepares queries can make applications 100% safe by it seft?

Ref: php.net/manual/fr/mysqli.quickstart.prepared-statements.php
 
Old 11-25-2015, 03:41 AM   #2
ilesterg
Member
 
Registered: Jul 2012
Location: München
Distribution: Debian, CentOS/RHEL
Posts: 587

Rep: Reputation: 72
English version of the link for other readers.

I might not totally understand the PHP code in the guide but there's totally no way of making your application 100% secure.
 
Old 11-26-2015, 10:27 PM   #3
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,150

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
not a programming expert, but to counter attack SQL injection you should filter the input.

For example if your asking for telephone number, then filter special characters like *, /, \, $, #, , alphabets etc...

Then same thing goes for any input field, allow the characters that is needed and deny or filter other characters that is not expected as part of the data that will be collected to process the input data.

or check out this one:
http://stackoverflow.com/questions/6...jection-in-php
 
1 members found this post helpful.
Old 11-27-2015, 08:13 PM   #4
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940Reputation: 3940
You definitely should use prepared statements and bound-parameters in all cases, even though the PHP language does not make this particularly easy to do.

You should never, ever "build" an SQL statement in which anything supplied by the user is "textually inserted." Instead, you should prepare a statement that consists of a literal string hard-coded in the source code of the program, which statement includes "placeholders ('?')" corresponding to each variable parameter which the statement expects to receive. You bind the appropriate values for each placeholder, each time you execute the prepared statement ... which only need be prepared once. The SQL statement, itself, is fixed and unchanging within your program.

I frankly never quite understood why the PHP language makes the construction and execution of parameterized SQL queries so difficult. In other languages, you simply provide the parameters as an array-valued parameter to "execute." The designers of PHP did things acceptably well in most cases, but they rather-curiously fumbled the ball on this one.

Last edited by sundialsvcs; 11-27-2015 at 08:15 PM.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
MySQL Injection With Apostrophe Question dman777 Linux - Security 4 06-25-2012 10:16 PM
MySql.com SQL injection vulnerability exploited (oh, the irony) win32sux Linux - Security 1 03-29-2011 07:34 AM
LXer: MySQL allegedly hacked - via SQL injection LXer Syndicated Linux News 0 03-28-2011 09:40 PM
LXer: MySQL addresses SQL injection vulnerability LXer Syndicated Linux News 0 06-02-2006 07:54 AM
Practice for programming? coolguy_iiit Programming 2 12-29-2004 01:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 08:32 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration