Linux - SecurityThis forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I have a database server in my office and it's also exposed to the outside world via web servers that run PHP. I was wondering how can I make sure my server is protected from SQL injections or other commonly SQL level attacks? I want to make sure my data on the server remains secure. I'm not exactly sure what happens when someone does a SQL injection but it sounds like a bad thing.
Click here to see the post LQ members have rated as the most helpful post in this thread.
Every SQL statement that takes a parameter should be a prepared statement with bound parameters. You never build SQL queries with string concatenation.
Quote:
Originally Posted by carlosinfl
I'm not exactly sure what happens when someone does a SQL injection but it sounds like a bad thing.
In addition to the prepared statements, I like to sanitize all input received from the user before before using it any fashion. For example, if you are expecting numerical input, make sure that you only receive a number AND that it is within the expected range. If you are expecting a date or date-time make sure that it is in the proper format AND that it is a valid date. Do not pass anything received from a user directly to your database.
The "Bobby Tables problem," referred to (and originally inspired by) that comic strip, has another aspect, too: "don't give your web applications any more database privileges than they actually require to do a particular thing." If you are querying records, you shouldn't be using a database-handle that is connected using privileges that allow writing to anything ... nor read-access to anything that does not need to be queried at this time.
Basically, it comes down to being dis-trustful, and programming your applications to do the same thing.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.