Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New Coder
    Join Date
    May 2009
    Location
    USA
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Allowing Remote DB Access to All Servers - Is it a bad idea?

    On my server, I have CPanel installed with MySQL and phpMyAdmin and the like. On my CPanel, there is an option titled "Remote MySQL", and this page allows me to specify IP addresses of servers that are permitted to access my databases on this server. Now, I can enable any server to access my databases (given they have the database name, user, and password) if I enable the wildcard '%' as a viable server that is allowed to access my databases with the correct information.

    So, why am I telling you this? I am building a Windows application (.exe) that needs to access my MySQL database on my live server in order to make changes and function properly. I have the application working properly and it is able to access and change information in my MySQL database with the code I have written. However, the application can only access my database if the IP of the person using the application has been added to the list of servers allowed to access my MySQL DB, which as I said before is an option in my CPanel. Now, obviously I cannot add the IP address of every user who downloads my application to this list, and therefore I came up with the solution of enabling any server from any IP address to gain access to my database, if the proper information and password is known and provided.

    So, my question to you is this: Is it a bad idea for me to allow "remote access" to my MySQL databases from any server IP? Since they would first need the DB username and password to even access my DB, I would assume that allowing any server IP access to my DB in CPanel would not be an issue. But, am I correct in assuming that this would not be a potential security issue for me? Please help me to clarify whether or not allowing remote access to my MySQL databases to any server IP is a good or bad idea, based on the circumstance that my Windows application needs to access this database from any IP address in order to function properly.

    I thank you in advance for any advice or rationale I receive.

  • #2
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,695
    Thanks
    80
    Thanked 4,511 Times in 4,475 Posts
    Username and password protection is probably enough. *IF* you limit that particular username as much as possible.

    For example, if your remote users only need READ access to one specific table, then only grant exactly those permission to that outside username. Even better, provide stored procedures for *ALL* your queries and then only allow that outside user to execute SPs. No ability to run any kind of ad hoc queries. Now only those operations you have explicitly coded as SPs in that particular table are externally visible.

    But whatever you do, use a *VERY VERY* strong password for your root account! After all, if you allow remote access for "guest" then if some guest tried to use the root account, they'd be able to! So you really want to take care with that password.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #3
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Is this exposed out onto the Internet or is this specifically for an internal Intranet setup? If it is the former, in addition to what Old Pedant said, make sure you keep up to date on security fixes and such.

    If the people using the program are always going to be coming from the same range of IP addresses, you could always just add in a specific range instead of all.
    OracleGuy

  • #4
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    26,695
    Thanks
    80
    Thanked 4,511 Times in 4,475 Posts
    It does occur to me that if this is an application that you are distributing, you could require people to register. And, as part of the registration process, you would capture their ip address and add it to the list of allowed addresses. If they change ip addresses, they'd have to re-register or equivalent.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #5
    New Coder
    Join Date
    May 2009
    Location
    USA
    Posts
    23
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thank you very much for your responses, everyone. As Old Pedant has said, this is an application that will be distributed freely, available for download to anyone who wishes to download it. The website with which it interfaces is a website I have developed, and if a user does not have an account on this website then there is really no reason for them to download my application in the first place, as it requires a user account to function properly. So, I could require log-in to download this application from my website.

    I would rather not log the IP address of each person who downloads the application and add it to the "allowed IPs" list in CPanel because, as Old Pedant said, IP addresses can change and then the user may wonder why they are all of a sudden unable to use the application. I suppose I could have the application produce an error message telling the user to re-download the application (thus adding their new IP address to the allowed list), but I'm not exactly sure if this is the way that I would like to go here.

    @oracleguy: This program will be exposed to the open Internet, as long as the user is registered on my website and authed. I'm thinking of taking Old Pedant's suggestion and creating a separate database and username and only allow this application to access that specific database. Also, I will change my database passwords to more complex combinations of characters. I've already limited the specific username to which the application connects to only SELECT, UPDATE, and INSERT permissions (although I may remove the INSERT abilities later).

  • #6
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Alright, in that case I second Old Pedant's suggestion to have your program only use stored procedures. And this gives you a second added benefit you might not have considered. If you change your database schema slightly or want to do something slightly different with the data, you can just change your stored procedures and not have to modify your program. So existing versions won't break due to database changes.
    OracleGuy


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •