Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 10 of 10

Thread: MySQL security

  1. #1
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    I hear that you should protect your databases, but I'm not sure how. Say you just set up a new database online. What precautions should one take to keep unwanted people from accessing it? How can people get into it to begin with? If someone does get in, what should you do?

    Oh, and what's this I hear about escape sequences or commands sent through online forms?

  2.  

  3. #2
    Senior Member visualAd's Avatar
    Join Date
    Jan 2003
    Location
    Slough, UK
    Posts
    201
    Member #
    434
    A you referring to MySql or databases in general?

  4. #3
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    (If MySQL) You should at least:
    • Add a new superuser with a strong password
    • Remove/delete the default "root" user
    • Add a new user that has limited privileges. This username is the one you use in your scripts to let clients interact with your database (through your webpages). No reason to log on with a username that has access priveleges far exceeding the scripts need
    • Make sure all user input data are properly escaped. If you fail to escape characters like single quotemarks and wildcards, you leave your DB system open for SQL injects.
      That means the query held in your script could be altered by user input, and execute something completely different, return values (like usernames and passwords or generally wreak havoc on your system).
      If your default user additionally has full privileges, you leave yourself that much more vulnerable.
    S. Rosland

  5. #4
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    Thanks for the info! Yes, I did mean MySQL; shoulda said that to begin with.

  6. #5
    Member
    Join Date
    Jan 2005
    Posts
    97
    Member #
    8727
    Delete root? I always leave root, but use a user with only privileges like select, insert, & update.

    The main thing is to escape SQL queries where there can be user-modified queries, i.e. login, submitting, etc, with mysql_real_escape_string and stuff like that.

  7. #6
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    Why would you need default 'root', when (as far as I know) all privileges can be given to a more 'protected' superuser?

    I can't remember where (book or internet article) where an example were given on how to penetrate a system with an unprotected 'root' user, even though the script were using a limited user. A bit complicated, but the conclusion were to remove or at least password protect root.

    Default root also have connect privileges from any external client.
    S. Rosland

  8. #7
    Member
    Join Date
    Jan 2005
    Posts
    97
    Member #
    8727
    Hmm...? I thought you had to password protect root when you configure mysql
    for the first time... and things which install them for you make you do one...

    Also I set it so you can only connect from localhost... ALWAYS. I guess we are just talking different styles of configuration.

  9. #8
    Senior Member Eddy Bones's Avatar
    Join Date
    Jan 2004
    Location
    Washington, USA
    Posts
    1,054
    Member #
    4651
    The root user on my test server isn't password protected. Maybe it depends on what kind of installer you're using? I didn't have any nice auto configuration stuff that some packages give you.

  10. #9
    Junior Member
    Join Date
    Aug 2003
    Posts
    8
    Member #
    2791
    Quote Originally Posted by n3on
    Hmm...? I thought you had to password protect root when you configure mysql
    for the first time... and things which install them for you make you do one...

    Also I set it so you can only connect from localhost... ALWAYS. I guess we are just talking different styles of configuration.
    I too on my dev server never had the root user password protected by default, I had to go update the password manually.

  11. #10
    Senior Member rosland's Avatar
    Join Date
    Jul 2003
    Location
    Norway
    Posts
    1,944
    Member #
    2096
    The later versions of MySQL comes with a configuration wizzard that starts after the server itself has installed.

    However, it only gives you the option of entering a password for 'root'. You can skip it if you don't want (leaving 'root' unprotected). As far as I can recall, the wizzard does not alter the external access privileges of root. Meaning a wildcard will replace IP authorization in the users table.

    Even if you password protect it, 'root' is still a default known username. (meaning anyone with malicious intents at least has the username when trying to penetrate your system.)

    A simple Grant statement will add a new superuser where both username and password are unique, and that will have all the privileges of default 'root'.

    This:
    Code:
    grant all privileges on *.* to unique@localhost identified by 'unique_password' with grant option
    will give 'unique' at local host same privileges as root (the *.* means all tables in all databases). "All privileges" does not include GRANT options, so this has to be added separately (as shown in the example).
    S. Rosland


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -6. The time now is 03:36 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com