Slashdot Mirror


Ask Slashdot: Verifying Security of a Hosted Site?

edi_guy writes "I'm getting ready to launch a small commercial website that will contain customer information in a MySQL database that will be run by a web-hosting service. While I have good experience with SQL databases from a programming point of view, I'm not an expert on securing them. Given all of the publicity around break-ins and data theft on a seemingly daily basis, it seems prudent to review this now rather than later. What are suggestions on resources that would help verify that both myself and my hosting service are following best practices on securing a database backed website?"

182 comments

  1. First step, don't use a hosted site by Anonymous Coward · · Score: 0

    Second step, don't use a hosted site

    1. Re:First step, don't use a hosted site by mysidia · · Score: 2, Informative

      Second step, don't use a hosted site

      Make sure not to use a server application or OS someone else wrote or maintains either. Definitely don't use anything that requires a third party to provide the updates or patches.

      On second thought: "Third step, don't connect the web site to the internet."

      Seriously... you have to host things, or it will be very expensive to put your site up by building all the infrastructure yourself, or you cut corners and not have the protections (like design, cooling redundancy, power redundancy), a real datacenter operation provided by a hosting provider would.

      Trying to host a web site on home/business DSL is bound to be a failure. Good luck dealing with unexpected load spikes, also.

      "Not hosting the site" is not a realistic solution for most people.

      You need to pick a hosting provider that will work with you to ensure security, and who had third party validations to show you, is willing to cooperate with third parties to validate security, and will attest to / provide you some documentation of their own security practices (esp. physical security with regards to servers you colocate), OR their practices for dedicated servers (second best security option) -- e.g. who has access, what controls exist, etc; shared servers (where multiple customers have sites on the same OS install) are potentially dangerous in some regards.

    2. Re:First step, don't use a hosted site by Anonymous Coward · · Score: 1

      No, there's a little thing called a dedicated (or colocated) server. If you are sharing a server, which most people would call "hosted," then you are vulnerable to whatever problems they introduce.

    3. Re:First step, don't use a hosted site by Anonymous Coward · · Score: 0

      Pretty much. If you share the server, then by definition you don't control the server. If you don't control the server, you have no way of verifying it's security to any reasonable degree. To extrapolate:
      1. Buy server
      2. Secure server
      3. Pay someone reliable to power it, cool it, and connect it to the internet
      4. ???
      5. Probably lose a lot of money, the economy's in the shitter and I guarantee someone else already made a website does whatever the fuck your website does, and they do it better.

    4. Re:First step, don't use a hosted site by Anonymous Coward · · Score: 0

      "Seriously... you have to host things"

      No, you don't. You can house them.

      "or it will be very expensive to put your site up"

      From the site I come from, what it takes for a business, it takes for a business. Telling that doing what needs to be done for your users' data is "very expensive" is declaring yourself a cheap bastard.

      "you cut corners and not have the protections"

      You can cut *your* protections all you want, the problem is when you are talking about cutting your *customers'* protections. Using a hosted database you don't know how to properly manage is just risking data that it is not yours to start with.

      ""Not hosting the site" is not a realistic solution for most people."

      Well, I don't have the financial muscle to be in the big infrastructures business, so I am not in that business. What I don't do is telling that all that security measures for highways are "very expensive" and try to cut corners... on the security of people.

      "You need to pick a hosting provider that will work with you to ensure security"

      There's no damn hosting provider that will take care for you programs' security. You know why? Because they are *hosting* providers, not service providers. The service is up to you, and if you are not up to the service I really better prefer you just not trying.

    5. Re:First step, don't use a hosted site by mysidia · · Score: 1

      There's no damn hosting provider that will take care for you programs' security. You know why? Because they are *hosting* providers, not service providers. The service is up to you, and if you are not up to the service I really better prefer you just not trying./em>

      Not really true... many good hosting providers are also service providers and can help with anything (for the right price), and that's a good thing -- because most web developers are not good system administrators, you the author of this website should probably not be the system admin, DBA, etc, all at once; hosting providers employ experts, and you should utilize available expertise, or host a dedicated option and get consultants to set everything up.

      The security of your software implementation is your own business. The hosting provider's system administrators should work with you to ensure security of the platform the hosting provider is offering you that your software runs on, or offer you options that will ensure security.

      They might recommend things like VPS on shared server, dedicated server, or colocated hosting, to mitigate multitenancy risks; most hosting providers have many options, for the security concerned. Or they may explain what measures they have taken to ensure the software is secure and kept up to date. In any case, they should be able to provide more than some silly seal.

      It's always ultimately going to be up to the person hosting a site to decide how much security is needed, how sensitive the data stored by the application is, and what their own compliance requirements may be.

    6. Re:First step, don't use a hosted site by realityimpaired · · Score: 1

      You can actually get a decent colo fairly cheaply. I am paying $50/mo for my colo, which is a share of a 100mbit pipe with no bandwidth metering. For a low traffic site like the original summary is discussing, that's actually plenty.... it is certainly enough for my colo system, which is primarily a mail server, but also hosts a small low-traffic website and forum. Throw in $1000 for the hardware if you don't have an old server-capable computer kicking around, and you're golden.

      And if your e-commerce site isn't turning enough margin to pay for a $50 colo, then you really shouldn't be running an e-commerce site in the first place. As your traffic rises, you can worry about expanding your infrastructure either with load-balancing multiple servers, or with moving your colo to a faster pipe.

    7. Re:First step, don't use a hosted site by dolmen.fr · · Score: 1

      [...] get consultants to set everything up.

      You can't rely on consultants for security that way. At least not just for "set up".

      Security is a continuous processs. Not a thing you do just once.

  2. contract some guys by JonySuede · · Score: 1

    contract some penetration tester like the one from offensivesecurity

    --
    Jehovah be praised, Oracle was not selected
    1. Re:contract some guys by hellkyng · · Score: 4, Interesting

      Not a bad component to have a pen tester come in. You might want to start however by working through a hardening guide like the ones available over at the Center for Internet Security. They are very detailed, easy to follow, and do an excellent job of security your target. Test in development first though as it is too secure in a lot of cases and will kill needed functionality.

      Once you've accomplished that have a pen tester look things over and see if its secure. Then put in logging and monitoring, ensure your security controls don't change and that you aren't seeing suspicious activity in the logs.

      In terms of evaluating the hosting company, it depends on how open they will be with you. See if they have audit results from PCI or SAS70 and request them. See if they have pen test results available for you as well. Check and make their encryption looks reasonable, are they using SSL etc. Ask their security staff basic questions and see how knowledgeable they are. Request references with highly audited customers to see what they think.

      That should keep you busy for a little bit.

    2. Re:contract some guys by Anonymous Coward · · Score: 0

      yeah, you can never have too much snake oil

    3. Re:contract some guys by Z00L00K · · Score: 1

      I think that the first step is to watch the design of the website itself and use a layered approach to limit access to services and functionality of the server.

      For example - if you use a Tomcat/Java web server it shall be executed in a security manager using a security policy that limits what the application in Tomcat is able to do - like only specific classes may access specific ports/services on the server. And anything in Tomcat shall never access the database itself but instead only a secondary business layer that contains the logic of the application. That layer may access the database. It will make any access to the database a lot harder for anyone looking into penetrating the system since they have to learn the design of it and try to work around the security policy of Tomcat.

      And what's executing in Tomcat shall only be the presentation layer, not much business logic.

      Anyone that directly accesses the database from their presentation layer is making things easy for intruders since it may only take a single flaw like a bug in PHP to get direct access to the database.

      And of course - the web server shall be executing as one non-privileged user and the business logic server as another and the database engine as a third. None of them shall have admin rights. That's what compartmentalization is about. I'm not saying that it's a design that's impossible to penetrate, but it takes time to penetrate it if you want direct access to the database. And if it takes time it will increase the risk of discovery, especially if you in the code build in traps that notifies you or anyone monitoring security on the way. A trap sprung may mean that there is an intrusion and it's time to start monitoring and take counter-measures.

      --
      If builders built buildings the way programmers wrote programs, then the first woodpecker would destroy civilization.
    4. Re:contract some guys by TooMuchToDo · · Score: 1

      PCI and SAS70 audits are a joke. PCI "tests" are self-administered (and the "scans" are usually run by some firm charging top dollar to run open source vulnerability scanners against an IP or two), and merchant account providers simply ask if you completed and fulfill the requirements. SAS70? A get-rich-quick scheme from financial/accounting firms who perform the audit. Note they aren't technical consulting firms, but accounting firms. *insert troll face/problem? here*

      Use SSL. Ensure your site doesn't have any SQL injection vulnerabilities. Encrypt credit card numbers (if you need to store them; preferably you don't). Only allow ports 80/443 from the world, and only admin ports from known IP addresses. Use semi-complicated passwords. Ecommerce doesn't require rocket science or expensive audits.

    5. Re:contract some guys by JonySuede · · Score: 1

      I assumed that he was ready to go live and that he already had the basic covered. But sure first implement what parent post said first. But still I think that before going live the best thing that you can do is to have a penetration test done by a pro. Not some stupid audit shit like PCI (credits cards) and SAS70 (software assurance service).

      --
      Jehovah be praised, Oracle was not selected
    6. Re:contract some guys by hellkyng · · Score: 1

      PCI definitely is a joke but not for the reasons you listed. Self assessments are only done when a company is pretty small and processes a limited number of card transactions. In a large firmer like hosting companies they probably have to have a QSA conduct a formal and more rigorous audit. Companies like heartland were pci compliant when breached so it's definitely not perfect.

      But on the other hand a pci and sas70 are most likely the only insight your likely to get into the companies security unless your going to be a huge client. It not perfect but it can certainly be used as part of a layerd security assessment.

      Otherwise your advice is good but only a small part of what needs to be done to ensure an entire site is secure. Reading through the pci requirements might not be a bad idea either. Sure they are a checklist, but if you take the guidance and ensure you implement in ways that make sense and don't just check boxes you will do alright.

    7. Re:contract some guys by John+Hasler · · Score: 2

      Or get it done free: antagonize Anonymous.

      --
      Warning: this article may contain humor, sarcasm, parody, and perhaps even irony. Read at your own risk.
    8. Re:contract some guys by Anonymous Coward · · Score: 0

      Not a bad component to have a pen tester come in. You might want to start however by working through a hardening guide like the ones available over at the Center for Internet Security. They are very detailed, easy to follow, and do an excellent job of security your target. Test in development first though as it is too secure in a lot of cases and will kill needed functionality.

      Better yet put everything in that guide that is relevant to your system/s in a script that you can run automatically (and that spits out notices when things do change). Ideally you'd probably want to use a configuration management system (Puppet, Chef, Cfengine) for the task.

    9. Re:contract some guys by JonySuede · · Score: 1

      a good penetration tester usually get in and tell you in detail how he did it. And if he don't he list you what he tried. If you are not getting that, you are not buying a penetration test conduct by a pro, you are, at best, getting a report from an open source tool that you could run yourself.

      --
      Jehovah be praised, Oracle was not selected
    10. Re:contract some guys by wvmarle · · Score: 1

      Do PCI and SAS70 issue certificates that they find your site to be secure? If so that could prove invaluable CYA material in case something does go wrong after all, as you have at least something to prove you tried, and that that you were up to "industry standard".

    11. Re:contract some guys by TooMuchToDo · · Score: 1

      Was Sony's PSN infrastructure PCI or SAS70 compliant? Is it going to cost them any less if they are?

    12. Re:contract some guys by Glendale2x · · Score: 1

      SAS70 has nothing to do with being secure, it's really just a "report on controls placed in operation and tests of operating effectiveness". It's not a checklist audit. What that exactly means varies from company to company (every company's procedures vary) and the firm performing it.

      --
      this is my sig
    13. Re:contract some guys by aztracker1 · · Score: 1

      so registering, and running it under therealsonycorp.com should do it.

      --
      Michael J. Ryan - tracker1.info
    14. Re:contract some guys by grcumb · · Score: 1

      contract some penetration tester like the one from offensivesecurity

      Why pay?

      Just buy a domain called iheartsony.com (or similar), load it up with insults against Vladimir Putin and every member of the Chinese politburo and top it off with gay porn images with the head of the king of Thailand 'shopped onto the bodies.

      If your server is still standing after a week, it's secure....

      (NOTE: This does not guarantee that you will still be standing at the end of the week.)

      --
      Crumb's Corollary: Never bring a knife to a bun fight.
    15. Re:contract some guys by dolmen.fr · · Score: 1

      And if he doesn't get in, what does that mean? You have good security or is he a bad tester ?

    16. Re:contract some guys by Anonymous Coward · · Score: 0

      I looked at the Center for Internet Security. If they have hardening guidelines they are well hidden behind their metrics papers. Can you be more specific about the location of an actual hardening guide?

    17. Re:contract some guys by Anonymous Coward · · Score: 0

      Seriously, this is the best way to go. Hire a good penetration testing company to test your site. Make sure your contract is good and includes an NDA. They should provide a nice report on where you're vulnerable (and the steps to reproduce) and recommendations of how to fix it. Make sure to give them enough time to test properly and don't rush them. If their idea of a report, is the report from a Nessus scan fire them, for they are not a good pen-testing company.

    18. Re:contract some guys by JonySuede · · Score: 1

      It means that you are protected from the list of things that he tried to get in. If he is a pro he is suppose to give you that list.

      --
      Jehovah be praised, Oracle was not selected
    19. Re:contract some guys by tepples · · Score: 1

      Ensure your site doesn't have any SQL injection vulnerabilities.

      I use parameterized statements where I can, and even in those two cases where parameterized statements are more trouble than they're worth, I do my best to minimize those parts where I have to do manual escaping, and I test those places with "Bobby Tables" style patterns to make sure single quote characters are handled properly. What tools help for finding places that I may have missed?

      Encrypt credit card numbers (if you need to store them; preferably you don't).

      Ordinarily, I don't. But if I encrypt something in a database, what are best practices to store the decryption keys?

      Only allow ports 80/443 from the world

      Anything wrong with allowing port 587 in (authenticated SMTP message submission)?

      and only admin ports from known IP addresses.

      As I understand it, this works only one pays extra from a static IP at the office and doesn't work from home. What am I missing?

  3. owasp by badran · · Score: 4, Informative

    This is a good starting point:
    http://code.google.com/p/owasp-development-guide/

    Make sure that you setup your mysql server to only accept connections from your server(s).

    And get something like Fail2ban if you are using linux to stop brute-forcing.

    Store salted hashes of passwords.

    1. Re:owasp by Anonymous Coward · · Score: 0

      Store salted hashes of passwords.

      More importantly don't roll your own (e.g. plain-SHA512(salt, hash)), but rather use crypt(3) (or a module in your language of choice that mimics it).

      Using the straight hash algorithms is not very secure, as GPUs can steam roll through the combinations (even with salting) very quickly; a lot of smart people have gone to the trouble of designing the various crypt(3) algorithms, so it'd be a pity to waste the effort.

    2. Re:owasp by Anonymous Coward · · Score: 0

      OWASP is very good, and I would add another site here that also has good up to date information about site security.

    3. Re:owasp by mysidia · · Score: 1

      Store salted hashes of passwords.

      Not sufficient.. not just any hash will be resistant to brute force attempts.... Use something like a 4096 iteration PBKDF2 key that is, and effecting a brute force attempt will be difficult for the forseeable future. :)

    4. Re:owasp by laxergreg · · Score: 1

      Yup. Make owasp (https://www.owasp.org/index.php/Main_Page) your bible. It's by far the best community for web security. They explain everything from the threats themselves to how to secure them (and provide the tools to do so). First and foremost remember to never trust the user (validate all input) and that user doesn't necessarily mean hands on keyboard (web service calls, etc - anything not 100% under your control). Also, don't blacklist (e.g. no ''s), always whitelist when possible (e.g. less than 50 alphanumeric characters or apostrophe's), i.e. try not to say what isn't ok, say exactly what is ok.

      Also, check out hackthissite.org. I wouldn't pay a pen tester... just mess around yourself and learn some of the tools (nessus). You're not the NSA, you don't need to worry about APT. You just gotta close the front door and watch the occasional script kiddie bounce off.

  4. '); DROP TABLE Comments; -- by Anonymous Coward · · Score: 0

    Given that most of these high-publicity break-ins were facilitated by simple exploits, get your web interface sorted out (and I mean really sorted out), and you're at least halfway there.

    1. Re:'); DROP TABLE Comments; -- by dzr0001 · · Score: 1

      Uhh, right, because a poorly written web application won't be able to execute SQL if another DBMS is used.

  5. Do not use mySQL by Anonymous Coward · · Score: 0, Funny

    You will be open to SQL injection attacks. Also, do not say anything negative about the Chinese or Hillary Rodham Clinton, and do not Tweet pictures of your crotch to Hillary Rodham Clinton.

    1. Re:Do not use mySQL by JordanL · · Score: 2

      MySQL is not uniquely prone to injection attacks. All that requires is unescaped user input.

    2. Re:Do not use mySQL by Anonymous Coward · · Score: 5, Informative

      MySQL doesn't inherently open you up to SQL injection... Poor programming practices opens you up to SQL injection. Any SQL based database is vulnerable if someone stupid writes the program.

      The standard lines about SQL injection:

      DO use prepared statements with place holders e.g. "SELECT * FROM table WHERE id = ?"
      DO NOT use string concatonation "SELECT * FROM table WHERE id = '" + some_string + "'";
      DO sanity check anything passed into your database
      DO NOT use user input as an identifier (column, table, or view name) E.G. "SELECT * FROM "+user_input+" WHERE 1=1";
      DO make users for your database that have the least amount of permissions required to run your app (Only UPDATE, INSERT, DELETE, SELECT)

    3. Re:Do not use mySQL by Anonymous Coward · · Score: 0

      DO make users for your database that have the least amount of permissions required to run your app (Only UPDATE, INSERT, DELETE, SELECT)

      even better
      DO make your database operations into stored procedures and only give your database user the execute rights on those procedures and NOTHING else

    4. Re:Do not use mySQL by LordLucless · · Score: 1

      Also, don't listen to clueless Anonymous Cowards on Slashdot who don't know anything but the subject at hand - but comment anyway

      --
      Just because you're paranoid doesn't mean there isn't an invisible demon about to eat your face
    5. Re:Do not use mySQL by billcopc · · Score: 4, Informative

      Alternately,

      DO create stored procs / functions and grant your scripts execute privs (and not much else). This can be a pain to implement, but it is the most "elegant" solution since you're forced to properly decouple DB functionality from front-end logic. Plus it makes it easier to add different front-ends later if you go multiplatform or something...

      -or-

      DO run all user-sourced input through "mysql_escape_string" or your DBMS' equivalent. Most DAO implementations already do this.

      Prepared statements are a decent half-step, but they aren't easily applicable to variable-length queries such as "advanced search" or anything else with optional parameters. It's far too easy to hit one of these walls and fall back into sloppy coding to get around it, negating what little advantage the prepared statements offered.

      --
      -Billco, Fnarg.com
    6. Re:Do not use mySQL by HiggsBison · · Score: 1
      --
      My other car is a 1984 Nark Avenger.
    7. Re:Do not use mySQL by Ksevio · · Score: 1

      DO run all user-sourced input through "mysql_escape_string" or your DBMS' equivalent. Most DAO implementations already do this.

      ...and make sure to put user input in quotes (or back quotes) in the final query as even an escaped string can cause problems:
      Basic query: "SELECT * FROM tbl WHERE x = ?"
      Input: "1 OR 1=1"
      Final: "SELECT * FROM tbl WHERE x = 1 OR 1 = 1"

    8. Re:Do not use mySQL by Anrego · · Score: 1

      Prepared statements are a decent half-step, but they aren't easily applicable to variable-length queries such as "advanced search" or anything else with optional parameters.

      I've generally managed this by dynamically building the query, preparing it, then dynamically building the data statement. Requires a little extra work, but I'll take it any day to mucking with various escape_string methods.

      Code wise, I've found it makes it a little prettier to abstract the "search" from the SQL. So you have a "SearchComponent" object that contains say, field, comparator, value .. your advanced search is comprised of a collection of arbitrary SearchComponents.. you then iterate through this array when building your query (inserting the appropriate operation and token where appropriate) .. then iterate through the collection again when building your DATA statement. This works just as well for optional arguments.

      negating what little advantage the prepared statements offered.

      I strongly disagree with "little advantage". Personally I think decoupling query from data and essentially eliminating most injection attacks and escaping/formatting nightmares is a pretty substantial advantage. Plus you get a performance boost when executing the same insert query over and over.. as it can cache a lot of the execution plan.

    9. Re:Do not use mySQL by guybrush3pwood · · Score: 1

      DO make your database operations into stored procedures and only give your database user the execute rights on those procedures and NOTHING else

      As opposed to what, mister? Writing SQL in PHP?

      --
      Perhaps I'm trolling, perhaps I'm not.
    10. Re:Do not use mySQL by Splab · · Score: 1

      Please do not tell people to use mysql_escape_string. That function is broken and does not escape proper.

      Also, just because you need to dynamically construct a string doesn't prevent you from using prepared statements. Just need to make sure user input is always passed to the database through parameters.

      That being said - don't use MySQL in the first place; handling customer data and especially billing information (OP says customer site) in MySQL is just asking for trouble. ( http://sql-info.de/mysql/gotchas.html - note this was written for 4.0 as it says, but a lot of them are still very much a problem today).

    11. Re:Do not use mySQL by SnarfQuest · · Score: 1

      Do NOT have 'sony.com' as part of your sites name.

      --
      Who would win this election: Andrew Weiner vs Andrew Weiner's weiner.
    12. Re:Do not use mySQL by Fallingcow · · Score: 1

      DO use prepared statements with place holders e.g. "SELECT * FROM table WHERE id = ?"

      Bingo. 90% of SQL injection prevented, right there.

      DO NOT use user input as an identifier (column, table, or view name) E.G. "SELECT * FROM "+user_input+" WHERE 1=1";

      If you really need to do this, create a white-listed array of tables it's OK to access in this manner and check the input against that before running the query. Also useful if you want user input to select a class/method to use/execute. That's basically what front controllers for many web frameworks do.

      DO make users for your database that have the least amount of permissions required to run your app (Only UPDATE, INSERT, DELETE, SELECT)

      EXEC's pretty handy. Damn near necessary, IMO. Pretty safe, too, as long as the rest of the permissions are locked down.

    13. Re:Do not use mySQL by mcrbids · · Score: 1

      Prepared statements are a decent half-step, but they aren't easily applicable to variable-length queries such as "advanced search" or anything else with optional parameters. It's far too easy to hit one of these walls and fall back into sloppy coding to get around it, negating what little advantage the prepared statements offered.

      I don't like prepared statements for the very same reasons. For this reason, we've built our own prepared-statements-like tool that gives us the same advantages of a prepared statement without requiring us to register the statement first.

      A preprocessor takes two inputs: the query with string variables embedded, and an array of inputs to match the string variables. In PHP:

      $sql="select lastname from users where login = '@login'";
      $vars = array('login' => $_REQUEST['login']);
      $exec = PrepareQuery($sql, $vars);

      The PrepareQuery() function looks for the variables in the sql and replaces them with values passed in, properly sanitized. (DB_escape_string(), etc) The result is very robust and also allows for very dynamic use such as dynamically created queries with optional values, etc.

      I've yet to run into a scenario that this model didn't easily handle.

      --
      I have no problem with your religion until you decide it's reason to deprive others of the truth.
    14. Re:Do not use mySQL by dolmen.fr · · Score: 1

      Prepared statements give you performance too (the DB server caches query optimizations), which your custom solution does not.

      Also you are dependent on your PrepareQuery() code to evolve with the SQL features/quirks of the database. And if the DB_escape_string() function is not implemented by the server side of the DB server, you can't rely on it (differences between client driver and server implementation are things that can be exploited for SQL injection). So this is the way towards failure.

  6. MySQL by Anonymous Coward · · Score: 0

    While certainly there are things you should check (remote accessibility, credentials, etc)... I have to say that the vast majority of the data breaches I see are simple sql injection attacks, not people breaking into mysql by exploiting something about the service itself. If you're more of the programmer sort, I'd guess you probably know about religiously cleaning user input, etc.

  7. Some simple rules that will catch most things by sirsnork · · Score: 1

    Don't have the SQL server exposed to the internet. Firewall it so only the Web server(s) can access it.

    Only expose the web servers HTTP port(s) to the internet and keep them up to date.

    Use parameters (and stored procedures) exclusively if at all possible

    --

    Normal people worry me!
    1. Re:Some simple rules that will catch most things by mysidia · · Score: 1

      These are foregone conclusions, but they do not secure against the most common attacks. It is rare that the SQL server is attacked directly, even if it is listening on the right report -- this is MySQL he's talking about, not MSSQL. Even if you do open mysql port to the world, the footprint is not that large, and common practice is not to create users that can connect remotely.

      Use parameters (and stored procedures) exclusively if at all possible

      Using parameterized queries exclusively, will avoid most SQL injection attacks; you still have possibility XSS/CSRF issues to be concerned about; those follow right after injection, and of course..... the issue of simply failing to properly authorize queries submitted, the class of vulnerabilities called 'trusting the client'.. e.g. not preventing a user from changing a &customer_id= in the POST form and submitting that order to someone else's account, changing random form variables to enable the user to do something they aren't supposed to do that the Web UI doesn't expose, or changing an &item_id= and ordering an item that is supposed to be hidden/not listed for sale, best yet... changing a &price= or &shipping= in the post form, and revising their terms of sale when hitting the 'finalize order' button.
      Stored procedures and other extension-fu are generally a bad idea... not portable when you need to switch SQL implementations.

    2. Re:Some simple rules that will catch most things by Caladrius · · Score: 1

      Keep things like customer_id and user_id in the session instead. That way no one can change them and submit a POST.

    3. Re:Some simple rules that will catch most things by Caladrius · · Score: 1

      Use parameters (and stored procedures) exclusively if at all possible

      I think you mean prepared statements?

      Stored procedures can be useful for certain things, but if every bit of SQL is written as one, it'll be a huge pain to read the code.

    4. Re:Some simple rules that will catch most things by LordLucless · · Score: 1

      Stored procedures and other extension-fu are generally a bad idea... not portable when you need to switch SQL implementations.

      How many times have you switched SQL implementations on a project? Personally, I've never seen it done. Unless everyone involved is extremely careful to follow only very restrictive ANSI standards, chances are stuff will break. Hell, even LIMIT clauses are generally proprietary. If you think you're going to be switching database backends:
      1) Do your research first, and use the right one from the beginning
      2) Use an ORM that supports both

      --
      Just because you're paranoid doesn't mean there isn't an invisible demon about to eat your face
    5. Re:Some simple rules that will catch most things by Anonymous Coward · · Score: 0

      "I think you mean prepared statements?"

      Which you would use depends entirely on the RDBMS you are using.

    6. Re:Some simple rules that will catch most things by Yvanhoe · · Score: 1

      Sanitize all the user entered data. Expect Bobby Tables.

      --
      The Wise adapts himself to the world. The Fool adapts the world to himself. Therefore, all progress depends on the Fool.
    7. Re:Some simple rules that will catch most things by JonySuede · · Score: 1

      How many times have you switched SQL implementations on a project? Personally, I've never seen it done. Unless everyone involved is extremely careful to follow only very restrictive ANSI standards, chances are stuff will break.

      We did it with brilliant success here at work (on a code base from the middle 90) and maybe we are going to move again in the next month. When you are not a lazy slob writing compliant SQL code is not that hard. However you have to have a good dba to make it perform.

      --
      Jehovah be praised, Oracle was not selected
    8. Re:Some simple rules that will catch most things by dolmen.fr · · Score: 1

      Stored procedures and other extension-fu are generally a bad idea... not portable when you need to switch SQL implementations.

      Switching SQL implementation will be easier to manage if you only have to port the SQL procedures instead of having to search all the SQL queries in your application for the DB specific quirks.

    9. Re:Some simple rules that will catch most things by mysidia · · Score: 1

      Switching SQL implementation will be easier to manage if you only have to port the SQL procedures instead of having to search all the SQL queries in your application for the DB specific quirks.

      That only really works if your application requires a fairly small number of queries. You're better off using one SQL implementation for development, and a different SQL implementation for testing and production; e.g. MySQL for development, Oracle and Postgres for testing (test against both DBs); production DB TBD after successful testing. Then your devs can't cheat.

      Any "DB specific quirks" should be detected during testing and cause the code to be sent back for correction of the defects.

    10. Re:Some simple rules that will catch most things by DarwinSurvivor · · Score: 1

      I would highly recommend ALSO testing against MySQL since the developers will only be doing a very small set of tests against their code (since that is the testing team's job). Basic rule of thumb: If there is the SLIGHTEST possibility something will be used in production, ADD IT TO THE TESTS!

  8. simple by Anonymous Coward · · Score: 0

    Be sure the host has the word 'Sony' somewhere in their name.

  9. simple by Anonymous Coward · · Score: 0

    Just outsource it to Indians who are promising to do it cheap. They are knowing SQL!

  10. Ask them by Scott+Lockwood · · Score: 1

    Ask them what their security plan is? How often do they conduct internal and external security scans? Do they conform to any security standards, like NIST, SANS, or even PCI? Also, ensure you have permission to conduct your own security scans, and ask them if you get results where there is a CVSS score of 4.0 or greater.

    --
    But this is slashdot. A slashdoter who didn't build his own computer is like a Jedi who didn't build his own lightsaber!
    1. Re:Ask them by mysidia · · Score: 2

      Ask them what their security plan is? How often do they conduct internal and external security scans? Do they conform to any security standards, like NIST, SANS, or even PCI?

      All eCommerce sites that deal with primary account numbers such as CC numbers (and don't use PayPal for everything) are supposed to be following PCI anyways. It's not as if the PCI requirements are optional rules vendors are allowed to ignore and still process payments --- if you have a payment processor, PCI is going to be included in the contract you signed somewhere.

      So that one... should be easy to leverage to your advantage... If you are hosting your site on a shared hosting provider, ask if they comply with the PCI requirements for shared hosting providers.

      Specifically, ask if they meet the requirements including not running different users CGI/PHP scripts as the same UID as other users or as the webserver UID.

    2. Re:Ask them by Anonymous Coward · · Score: 1

      Technically, PCI are voluntary. Quite expensive to find one that will exempt you though. On the level of ~7.6%+$1000/monthly bill when I was last dealing with it.
      Some of the most annoying things ever. "We dont process orders through the website, it lists a phone number to call" "Must be PCI Compliant!" "It never even sees customer directed emails, they go through a different machine" "must be compliant!" "Oh, hey, we don't have a website" "Thank you, compliance passed"

    3. Re:Ask them by mclearn · · Score: 2

      You do realize that PCI compliance covers things like the PoS terminals and the like, right? PCI Compliance is a security guideline document that is supposed to be used if you receive customer credit card information at all.

      Period.

      Do you use a PoS to process those cards? Is it secured? Is it connected to an open network or on a dedicated line? Is the credit card number printed on the slip? Are those slips secured in a safe place? Does the minimum number of people have access to this slips? etc.

      It is NOT a system just for web e-commerce, but most people seem to think that it is.

    4. Re:Ask them by Anonymous Coward · · Score: 0

      Yes, i know it attempts to cover the entire 'credit card interaction' area.
      I also know i was on the phone with this particular processor for over 4 hours to get him to accept the machine they were demanding 'be made pci compliant' was 100% unrelated to that in any way, shape, or form.
      Wasn't in the building, didn't connect to their data in anyway, it was, basically, a splash page that said 'Call us at ######'
      Still insisted that it had to pass their certification or we could sign a 'Pci Compliance wavied contract' for the higher cash.
      Finally I dropped the DNS, told him there was no site, and hey it was approved.

      Security is important and PCI Compliance isnt a bad set of guidelines. but they have no common sense at all sometimes and it isnt strictly mandatory. just expensive; and often useless

      our checkout system is PCI compliant, doenst print cards, etc, but the security cameras can read the whole card # pretty well

    5. Re:Ask them by Scott+Lockwood · · Score: 1

      Who is your QSA? Who ever it is, they're giving you terrible advice. That should have been as simple as pointing out to them that the website was not part of the card holder environment, and as such, PCI didn't apply to it anyway. If they don't know that, you don't want to deal with them anyway.

      Also, PCI is strictly mandatory - if you want to accept credit cards. Mandatory compliance came into the picture in 2008.

      Lastly, with the new 2.0 spec, you are supposed to be taking a risk based approach to compliance, which makes pretty much everything you've posted to the contrary laughable.

      --
      But this is slashdot. A slashdoter who didn't build his own computer is like a Jedi who didn't build his own lightsaber!
  11. Common Sense by The+Bringer · · Score: 1

    From what I know, I would say that having a good password policy is first and foremost. Secondly, ensure that your MySQL server is only accessible from IP Addresses on the whitelist. Hash your passwords and make sure you salt them. No one likes a good hash without some salt. The biggest threat is an injection. Make sure you sanitize every single input on your site, don't trust cookies for security, and make sure you're regularly validating your security tokens. Oh, and don't be an idiot. There is no reason for you to store anything more than the last four digits of a customers credit card number anywhere on your server.

  12. If you don't know how... by TWX · · Score: 1

    ...then you have to go back to basic principles, which isn't compatible with a hosted site.

    In an ideal world, you'd have a public network (the Internet connection) and a DMZ/semi-private network, with the DB server. The web daemon wouldn't run on the DMZ side, and would have to forward requests through to the other server.

    It's been a really long time since I dealt with this stuff firsthand, but I suppose that on a single box one could create a virtual network or use loopback to connect the web daemon to the DB daemon, and then restrict the DB daemon to only communicate on the virtual side, but you'd probably still need local root access to set everything up.

    From what I gather, many hosting companies that offer space on a box with multiple other customers typically have a DB guy on staff to work with this kind of thing, and they typically charge for the both the cgi bin and for the DB component. As I said though, it's been a LONG time since I've dealt with this stuff personally (like, people were still using compiled-C for server-side coding), so things might have evolved from my mindset.

    --
    Do not look into laser with remaining eye.
  13. PCI Compliance Standards by Anonymous Coward · · Score: 1

    Follow these: https://www.pcisecuritystandards.org/ and profit.

    1. Re:PCI Compliance Standards by phek · · Score: 1

      pci compliance standards aren't really that good, especially for determining web application security.

  14. Penetration Testing by hugheseyau · · Score: 1

    Get your site penetration tested. Ask you host if they have had thier server's standard build (or SOE) reviewed by security experts also. I can help with these if you need, drop me a line!

  15. Encrypt your data by Anonymous Coward · · Score: 0

    Then you won't have to trust your hosting site. Someone steals your data, they get nothing.

  16. Host and manage it yourself. by Anonymous Coward · · Score: 0

    If you don't host and managed the DB yourself you will never know. What the company tells you and what they actually do may be two very different things.

    As people posted here. Not allowing the database to listen on the "public Internet" is good, but what about local access? Is this shared hosting? Can other customers on their network access the same server?

    Do they do regular security updates? How can you verify?

    Use strong passwords. Limit user privileges. Restrict IP address to localhost (or your host). Don't use the root account. Sanitize all input to the DB. Encrypt data.

  17. Make them tell you. by RichardJenkins · · Score: 5, Informative

    Ask them what their processes and policies are in regards to this. They're your supplier, make them tell you why you should trust them with your DB.

    That said....firstly understand that securing the database is a small piece of a very big complicated jigsaw made up of randomly cut pieces with an abstract painting on them. Security is hard.

    My first step is always to get the infrastructure up to something I'm happy with.

        * Set your firewall to block all incoming connections by default, only ever allow connections to port 80 (and 443 if necessary) on your web server/load balancer.
        * Designate a couple of 'management IP addresses'. IE your home, or another location. Open up SSH to these addresses only.
        * Configure SSH so the only way to access it is via certificates. Do not allow tunnelled plaintext passwords, ever.
        * Try to ensure all your secret SSH keys are password protected
        * For all server management issues use SSH. Use it for uploading, direct DB access, deploying etc. The only external connections to any of your servers happen on port 443/80/22.
        * If you are using SSL use a secure cipher suite (running SSL Digger) will tell you if you are using any weak ciphers
        * Decide on an update policy (ours is to have a human monitor all package updates daily, decide when an important one comes out, test it on stage, then update production) that ensures critical security fixes are applied quickly
        * Google "security guide app" and review what the Internet says about securing Apache/Lighttpd/Squid/MySQL/RabbitMQ/Whatever. Understand it! Pay particular attention to anything the user interacts with (ie Joomla/Drupal/Wordpress)

    Hmm, that's a pretty big list, mostly incomplete, and isn't even where your big security problems lie - most attack vectors are likely to come through flaws in your application. SQL Injection (shockingly!) is still happening, and if you give users the opportunity, someone WILL shoot themselves in the foot.

    Man, security is hard! You can hire an agency to test things for yuo and give you a report. These tend go from quite cheap (ie the firm just ran Nessus and sent you the output) to extremely ellaborate white-box penetration testing that usually comes back with practical real world advice.

    Great that you are concerned enough about this to ask Slashdot, don't work for Sony do you ;)

    1. Re:Make them tell you. by Anonymous Coward · · Score: 0

      Is there ever a reason to run SSH on port 22?

    2. Re:Make them tell you. by dolmen.fr · · Score: 1

      Yes. Security though obscurity (this what you're suggesting) is bound to failure.

    3. Re:Make them tell you. by dkf · · Score: 1

      Is there ever a reason to run SSH on port 22?

      Yes, it can make managing other parts of the system (such as the firewall of the provider) simpler. But ensure that you disable logging in with a password with it; it's otherwise just too vulnerable to distributed attacks. Also bear in mind that going from port 22 to port 2222 isn't going to help much anyway; what would be the second port that an attacker would guess? Real security is better than a miniscule amount of obscurity.

      --
      "Little does he know, but there is no 'I' in 'Idiot'!"
    4. Re:Make them tell you. by tlhIngan · · Score: 1

      Is there ever a reason to run SSH on port 22?

      Yes, it can make managing other parts of the system (such as the firewall of the provider) simpler. But ensure that you disable logging in with a password with it; it's otherwise just too vulnerable to distributed attacks. Also bear in mind that going from port 22 to port 2222 isn't going to help much anyway; what would be the second port that an attacker would guess? Real security is better than a miniscule amount of obscurity.

      If you're doing all that, why NOT move SSH to another port? Security by obscurity alone is bad, but it's not a bad thing to do as part of defense in depth. After all, a pile of crap comes from bots trying to break in via SSH on 22. You'll clean up your SSH login logs (it won't be full of "login failed" entries) to make it easier to see if it's under attack. And if you configured the firewall to restrict IPs, even better.

      It seems that everyone's jumped on "security by obscurity is bad!" bandwagon without realizing it's only bad if it's the only way you secure your system. Sure any idiot with a portscanner can find your service on another port (maybe, depending on your firewall) but most attacks happen on default ports, and eliminating 99% of the bots means you can concentrate on the 1% who really are trying to break in rather than opportunistically turning the knob to see if the door is unlocked.

    5. Re:Make them tell you. by RichardJenkins · · Score: 1

      All for security in depth, but personally I think the security benefit of running ssh on a non-standard port (which is making it so most automatic attacks miss you, as you say) is so miniscule that the increase in complexity isn't worth it.

      Or put another way - there should be a very compelling reason behind every non-standard change you make, and avoiding automated scans isn't compelling enough for me.

  18. Customer Security by Anonymous Coward · · Score: 0

    You had better check on the recent laws that have gone into effect. Both State and Federal laws requiring encryption of customer data have been enacted. I suggest finding a security expert in your state that knows the law and have him make a plan for you. If you don't have a plan and you get hacked, you can be sued for very large amounts of money. In fact, quite a few companies have been put out of business because of a hack when they did not have a plan and did not properly protect the customer data. It is more than avoiding a SQL injection.

  19. Don't be an asshat by Anonymous Coward · · Score: 0

    Just treat your customers fairly and with respect. It seems like everyone who is getting hacked has some bad karma.

  20. Uhh.... by the+eric+conspiracy · · Score: 1

    1. Read up on SQL injection attacks. Escape all parameters coming in on the pipes.

    2. Put the db on a different server and firewall it so it cannot be accessed from the internet. Ideally you would have a 3 layer design with the web host passing requests to an application running on a firewalled server not accessible to the internet, and the application would pass requests through another firewall to the db server running on a machine not accessible to the web host.

    3. Don't store anything you don't have to.

    4. If you have to store it, encrypt it.

    5. Use SSL whenever receiving or transmitting private information.

    6. Teach you end users about password security.

    7. Under no circumstances store unhashed passwords or send passwords out via email.

    1. Re:Uhh.... by gewalker · · Score: 1

      6. Teach you (sic) end users about password security.

      Seriously? On a website? I can think of no task more futile for the submitter's stated goal. People who know better often use rotten passwords out of simple laziness.

      If your site is interesting enough, hackers will gain access to user-level accounts (just ask Anthony Wiener). You must write everything so that the only damage they can do is limited to the damage that the inept users can do to themselves by using designed features,

  21. There is much to do to secure a MySQL db. by Anonymous Coward · · Score: 2, Interesting

    1. Do not use the MySQL root pass as the application password. Do not use the root user as your application user.
    2. Setup an application specific id and only give it SELECT, UPDATE, DELETE for the specific tables of the application or to the application schema only.
    3. Passwords for these ids must be 15 chars long
    4. DB Passwords stored in application files must have the correct ACLs.
    5. Learn how to use the creation of the user id to lock the db for access only from the application server. For example if your app server is at 192.168.0.4 then the application user would be applicationuser@192.168.0.4. This 'locks' the db from only accepting traffic from the server listed. If the db is colocated with the app server, then specify the user like this - applicationuser@localhost. Also assuming you need to login to the DB server to do maint then your root user would be root@localhost. This would force you to have localhost access before you could login as root.
    6. Use a Object Relational Mapping technology to front the DB, thus preventing SQL injection attacks. If you must script, NEVER EVER concatenate SQL. If no ORM is availble, use whatever languages parameterized SQL scheme.

    There is probably more here, but this should give you a fairly good start.

    Good luck

  22. audit by vldcnst · · Score: 1

    If you want I can offer you a web site security audit (specialized company), for free.

  23. PCI compliance by Anonymous Coward · · Score: 0

    If you plan on taking credit cards for payment, host with someone like Volusion or BigCommerce to make sure your shopping cart is PCI (Payment Card Industry) compliant. This means credit card information (including, but not limited to, card numbers, expiration dates, CVV2 numbers (the 3-digit number on the back of the card), and cardholder data) is thoroughly encrypted. You can be hit with MAJOR fines (and be banned by the card issuers) for having credit card numbers in cleartext, whether it's a spreadsheet on your office machine or on your website.

    1. Re:PCI compliance by zonky · · Score: 1

      you can not store CCV2 ever, even if encrypted. Read PCI and try again.

  24. PCI DSS by webbiedave · · Score: 1

    Get the documents. Have you and your host assess your setup.

    https://www.pcisecuritystandards.org/security_standards/index.php

    Also have security scan firms run scans of your site.

  25. Hire someone to check it out. by zaunuz · · Score: 1

    As mentioned earlier, hire someone to check out your security measures. Many companies do this. Sadly i can't remember any names off the top of my head, but google is probably not completely clueless.

    And obviously: Make sure that the contractors are legit and not just in it to rig the system with backdoors

    --
    this is probably the most boring sig in the world
  26. You are the... by Anonymous Coward · · Score: 0

    Only allow for the local app to access the SQL ie 127.0.0.1, and if the SQL server is separate lock down the communication. Be sure all client facing code isn't susceptible to injection. Keep your shit updated, just because everything is working doesn't mean you shouldn't update. Be sure people who shouldn't have access to the server DON'T. Always know who has access to what, you never want to inadvertently spill the beans to prying eyes. A managed hosted solution by a third party is always a security risk. All in all just have decent infrastructure, and keep tools off the innards. Audit = Audit = Audit. IMO It sounds like you are the security risk. :\

  27. Many firms specialize in site hosting by klubar · · Score: 4, Insightful

    Hosting secure, high-reliability, high-availabity web sites isn't a do-it-yourself proposition. Perhaps you should have your site hosted by a top quality vendor who has the staff and expertise to maintain the physical and software security.

    The problem is that this type of hosting isn't cheap. The bargain basement hosting firms will not provide the expertise and customer support necessary.

    Unless you're really going to scale up quickly, it's unlikely that you can hire (or become) expert in all of the domains necessary to provide top tier hosting. For example, can you accurate manage the A/C needs for your site hosting? Do you have guaranteed service contracts on the A/C units an N+1 back ups? Same with power, backups, hot off-site recovery, physical security, insurance, fuel for your generators, battery contracts?

    I'd go with a top-tier hosting firm, and be prepared to pay significantly more than $10/month.

    1. Re:Many firms specialize in site hosting by lemur3 · · Score: 1

      how will i know if a firm is top tier if i am not much of an expert on the things id need for a secure high reliability high availability site? most any hosting place claims they are super secure and great and stuff

      price alone?
      claims they make?

    2. Re:Many firms specialize in site hosting by klubar · · Score: 1

      One place to start is to look at netcraft http://news.netcraft.com/ they rate the reliability of hosting frims--companies that have been at the top for many months are probably a good recomendation. Look at the client list, and find out what services they are buying. Ask about client service--at top tier the phones should be answered in one or two rings by a extremely knowledgeable tech who can solve the issue. No call trees or escalation. Ideally you'll get an assigned customer service team that takes the time to learn your application and proactively monitors the system. Ask your team some technical question to assess whether you're comfortable with their answers.

      Also find a hosting frim that is expert in the technology that you're planning to use. If you're going the .net, MS SQL route, don't get a firm that mainly uses LAMP and vice versa.

      Also, make sure you trust their technical expertise (which is what you are paying for).

      Expect to spend 10X over ther bare-bones hosting... but hosting will be a minor cost in the grand scheme of things.

  28. Start here by Syncerus · · Score: 1

    Not to belabour the obvious, but why not start here:
    http://dev.mysql.com/doc/mysql-security-excerpt/5.5/en/security.html

    That and never, ever insert user-supplied data into a query without using the vendor approved escape mechanism, even if you've done your own safety checks.
    http://dev.mysql.com/doc/refman/5.5/en/string-functions.html#function_quote

    --
    "Man is nothing without the works of man" -- Helvetius
  29. Stick with tried-and-true by lamber45 · · Score: 1

    1. Start with a hosting service you can trust. Either look at the ads in a five-year-old edition of "PC Magazine" and choose one that's still in business, or find a brick-and-mortar business in your hometown. Do a background-check on the owners. Ask for references. 2. Use stable open-source software (Joomla, OScommerce, whatever) as much as possible instead of rolling your own. Watch out for security patches. If you do write your own code for the site, hire another set of eyes to look at it. 3. Develop a backup plan early on ... ideally before the site goes live.

    1. Re:Stick with tried-and-true by wbean · · Score: 1

      Joomla may be secure but look out for the third-party components. I've been upgrading a bunch of them to Joomla 1.6 and I can't tell you how many I've found to be open to sql injection.

  30. Backtrack? by kernelphr34k · · Score: 0

    Depending on your technical abilities, and the feedback from your host I would try backtrack (http://www.backtrack-linux.org)

  31. Wrong DBMS by leandrod · · Score: 1

    MySQL has appalling code quality, and a critical piece of proprietary technology. Use PostgreSQL: safer, more standards-compliant, more robust, totally free, more scaleable.

    --
    Leandro Guimarães Faria Corcete DUTRA
    DA, DBA, SysAdmin, Data Modeller
    GNU Project, Debian GNU/Lin
    1. Re:Wrong DBMS by Anonymous Coward · · Score: 0

      Yawwnnn. Why is it you posgresql zealots are unable to stop spouting shit? Get over it, PS flunked because it's slow, it's clunky, and it's unusable in real world sites without tearing out the engine. If you have nothing to offer the poster, go away and have a wank.

    2. Re:Wrong DBMS by tepples · · Score: 1

      If I'm tired of MySQL, how do I convince more web hosting companies to offer PostgreSQL on shared hosting or low-tier VPS?

    3. Re:Wrong DBMS by Unequivocal · · Score: 1

      It's hard b/c it seems that for many companies they perceive (maybe accurately) Postgres as more expensive to operate in a shared environment than MySQL. I believe there's been a fair bit of work to fix this over the last few years in PG, but it's still a problem in the field. Plus the demand from devs for PG is much lower than MySQL (kind of chicken and egg).

      I've found support from providers at all levels for PG. My personal web host is www.geekisp.com and they do a great job giving me the tools I want, including PG. I used EngineYard a while back (middle tier host) and they were willing to support PG b/c I and a few other people requested it and they wanted to be full service.

      So my rec is to look around - you'll probably find someplace you like supporting PG. And if you find a place you like that doesn't support it, give them a call and talk with management - they might be willing to add it to the mix..

    4. Re:Wrong DBMS by leandrod · · Score: 1

      Demand, demand, demand. It is ðe demand!

      --
      Leandro Guimarães Faria Corcete DUTRA
      DA, DBA, SysAdmin, Data Modeller
      GNU Project, Debian GNU/Lin
    5. Re:Wrong DBMS by leandrod · · Score: 1

      Can you expand on why would PostgreSQL be more expensive to operate? My experience is ðe opposite.

      --
      Leandro Guimarães Faria Corcete DUTRA
      DA, DBA, SysAdmin, Data Modeller
      GNU Project, Debian GNU/Lin
    6. Re:Wrong DBMS by Unequivocal · · Score: 1

      This is second hand info but the providers I've talked with over the years say that partitioning users, databases, rights, resources, etc in MySQL is more built from the ground up for a co-sharing environment, whereas PG isn't as easy to setup and manage in that configuration. It can be done for sure (geekisp.com does it well) but maybe it requires more expertise or care/feeding or something. I don't know, but that's what I've been told. HTH

    7. Re:Wrong DBMS by leandrod · · Score: 1

      Sounds like a poor excuse for incompetence Postgres is actually simpler to do properly.

      --
      Leandro Guimarães Faria Corcete DUTRA
      DA, DBA, SysAdmin, Data Modeller
      GNU Project, Debian GNU/Lin
    8. Re:Wrong DBMS by Unequivocal · · Score: 1

      We are talking about MySQL vs Postgres -- isn't that the general rule between the two for almost everything? The fact is that it's much easier to find shared hosting on the cheap that supports MySQL than PG. I myself never use MySQL -- agreeing with you that Postgres is better for everything I need, at least afaik.

  32. Be Prepared by Anonymous Coward · · Score: 0

    Unfortunately, since you are handing the actual management of the database and the webserver off to a third party, you probably will not have much control over their diligence or architecture. I have not seen a low cost provider that is not rickety in core elements, such as their billing, admin management interface or other threat surfaces -- and that is setting aside the possibility of compromise of their own support team.

    The worst part is, these companies will lie to you, very directly, about their threat posture and pretend that they offer ironclad security -- without offering real guarantees. If you decide to use one of these services, you should prepare for the possibility of compromise and insure for the appropriate level of risk.

  33. MySQL Reverse Proxy by Anonymous Coward · · Score: 0

    A MySQL reverse proxy would help as well as a firewall. Just Google "mysql reverse proxy". It'll require a VPS or Dedicated Server though.

  34. So you're going to beat them? by holophrastic · · Score: 1

    Given all of the public break-ins, of huge companies, don't try.

    1. Re:So you're going to beat them? by SydShamino · · Score: 1

      No no, use it. Register a domain like SonySomething.com. Put some Sony-related content on the first page and your database (filled with fake data) in the back.

      It will take a while for Sony to take your domain from your for cybersquatting. If your content remains safe the whole time, your database is probably secure. If you find the content downloadable from Lulzsec, you have more work to do.

      --
      It doesn't hurt to be nice.
    2. Re:So you're going to beat them? by techhead79 · · Score: 1

      Actually I believe it's easier for small companies to stay up to date if they are tech savvy. No red tape/paper work blocking updates/upgrades. Limited number of custom made applications make it easier to secure if they were coded right to begin with. No "who the f knows" factor when dealing with large complex systems communicating together.

      The idea that small companies don't have chance at securing themselves is probably missing the boat on why this is even a problem to begin with. Rarely are new exploits used in hacks that don't already have a fix out there for them. The condition though is secure in house code if you do stay up to date on everything in a timely manner. With these larger companies they do not have the time or resources to go back through decades or even 5 year old code to patch up software security issues they created back before it was a known issue. No code today should EVER be at risk to SQL injection...It's not really hard if you think about it.

      Oh, and I own a small one man shop and work full time at a very large company...

  35. Bounty by Anonymous Coward · · Score: 0

    Offer a bounty for security holes and then fix them, or since that is just an open invitation to get hacked, honeypot the bounty with a fake replica site.

  36. Scanning Vendor by Anonymous Coward · · Score: 0

    I used to work for an internet security firm that provides external security scans. I would recommend it as they will scan your site on a regular basis so that as new security vulnerabilities are found, those will be tested as well.

    This is a good place to start
    https://www.pcisecuritystandards.org/approved_companies_providers/approved_scanning_vendors.php

    Security Metrics is the company that I used to work for and they have a good scanning system in place

    1. Re:Scanning Vendor by Anonymous Coward · · Score: 0

      I currently work for a firm that provides these scans as well and I would highly recommend them. Since you're on a shared server a network scan may not be the best idea but many of these companies are now offering web application scans as well now. Many people here have suggested PCI scans... that's not what you want. A PCI scan is primarily a network scan. It would however be a good idea to ask your ISP if their shared servers have passed PCI compliance and if so to see proof. If they haven't attempted a PCI scan, then you should probably ask them if it's ok to run one against their servers.

      As others have mentioned, hiring a pen tester would be a great idea but this could be pricey. If you're not willing to pay anything/much there are some free and cheap tools out there to do a web app scan yourself such as burp suite but I would highly recommend against this since you probably aren't that familiar with web security. Also reading the owasp documentation for web security would be a great idea.

  37. Its called colocation... by Local+ID10T · · Score: 1

    Leasing a colocated server is a relatively inexpensive intermediate option. Most decent ISPs have the option available. Prices typically range from $50 to 200/month depending on hardware specifications/bandwidth requirements.

    The next step up is to lease space in a colocation rack from the ISP. That is your hardware in a locked rack in their server room.

    --
    "You want to know how to help your kids? Leave them the fuck alone." -George Carlin
    1. Re:Its called colocation... by hedwards · · Score: 1

      Indeed, also do yourself a favor and make sure that you have at least one set of servers that's within some sort of sane drive from your home or office. The last thing you're going to want to do is drive 6 hours because the people on site don't have a key. Sure you can allow them to have a key, just make sure that there's a sane system in place to track the keys at all times so that there aren't times when some random person has a key or worse where one key can unlock multiple sets of servers.

    2. Re:Its called colocation... by mysidia · · Score: 1

      The next step up is to lease space in a colocation rack from the ISP. That is your hardware in a locked rack in their server room.

      You mean that's your hardware hosted in a rack in their server room.

      Whether that rack is in a cage and locked or not will depend. In any case, they have the keys, not you.

      And if you have a Layer 1 (physical) issue, you are in for a lot more downtime than a professionally hosted dedicated server. With the hosted option, there will probably be spares on site. With a colocation option, you will be driving in, and waiting for an escort to let you in to try and troubleshoot your server, and then take it out with you, to hunt around your place (or some store) to buy replacement components.

      The option of colocation is only really sane for personal stuff that doesn't matter, or for large companies that rent out entire racks with 24x7 access, and have dedicated staff near the colo.

    3. Re:Its called colocation... by mysidia · · Score: 1

      I don't know what you're talking about keys for. There aren't any colocation providers I know of that will let you colocate a few U or a half rack, lock it, and take the keys off site.

      Usually such a customer doesn't even have the keys to the rack. If they have any access to the rack other than escorted-by-security during business hours only (8x5) and watched-like-a-hawk while they pull their server out/put their server in, they're paying through the nose for it.

      Things like on-site hands from the facility or remote KVM are as-available, and very expensive. Much more expensive than hosting for a small operation of just one web server and one db server.

    4. Re:Its called colocation... by mysidia · · Score: 1

      The option of colocation is only really sane for personal stuff that doesn't matter, or for large companies that rent out entire racks with 24x7 access, and have dedicated staff near the colo.

      P.S. And even with colocation, usually the provider has the right to gain entry to your server by force, if they feel they need to. And the possibility remains an unauthorized person could steal your server or use physical access to root it.

      The security risk is hardly any different from hosting a dedicated server; and just comes down to you owning the piece of metal vs a provider owning the piece of metal. What can be done with that piece of metal under either arrangement is spelled out in a contract.

      And if the contract is adequate, including things like giving you a right to buy your server or allowing you in to copy the data off the server and then format the server, in case of account termination, you're equally protected, security-wise even if a provider owns the metal.

      No matter who owns the metal, you having a server in someone else's location creates an external dependency risk that should be managed.

    5. Re:Its called colocation... by Nefarious+Wheel · · Score: 1

      It's generally considered (at least among ISP salesmen) that it's colocation if you're sharing your virtual server with someone else's virtual server on a common piece of hardware.

      Virtual servers are good, you get a lot of benefits such as low MTTR and easy scalability. But 1RU servers are relatively inexpensive, too -- you can run a single virtual image on your own individual server if you like, everything is negotiable. A variant use of the term is rack-level colocation; your server, their rack.

      --
      Do not mock my vision of impractical footwear
    6. Re:Its called colocation... by mysidia · · Score: 1

      It's generally considered (at least among ISP salesmen) that it's colocation if you're sharing your virtual server with someone else's virtual server on a common piece of hardware.

      That's not colocation. What you're referring to... a dedicated virtual server on a common piece of hardware with other people's servers is called "Virtual Private Server" or IaaS.

      In any case, colocation means you locate (host) physical hardware with your provider... hence the term co-location. With a VPS you are just issued a server, it's not yours, you're not locating anything at the hosting provider.

      A VPS/Virtually shared server is not as secure as a dedicated or colocated server, because there is a possibility of side channel attacks against your VPS from other VPSes, and a possibility of vulnerabilities in the shared OS code (you're not in control of the kernel version in say a Virtuozzo/VZ/Vserver/chroot container), or isolation breakdown vulnerabilities/root domain code execution vulnerabilities in the hypervisor in the case of Xen, VMware, or Hyper-V; not to mention the possibility the VM host you don't control might be attacked over the network or by an insider -- your VPS could in theory be copied with you being none the wiser; in container implementations its possible staff of the hosting company will enter your VPS from the root domain using admin privs, without having to compromise any security barriers or know any passwords (e.g. VZ: vzctl enter your-vid).

  38. If you cant.. by Anonymous Coward · · Score: 0

    If you can't protect it, don't collect it.

  39. Simple yet effective website security test: by nuckfuts · · Score: 4, Funny

    Post some inflammatory content concerning Anonymous. Include boasts about being invulnerable to retaliation.

    1. Re:Simple yet effective website security test: by memyselfandeye · · Score: 1

      And encrypt your passwords with DES... and login as root... and don't forget to smudge taco sauch on that post-it-note with that command "yum update" written on it.

      Seriously, don't listen to all the naysayers. Just because you call yourself smart and have a million users doesn't make you smart. And just because you don't have a million users and don't think you're smart doesn't make you stupid. Work hard, subscribe to mailing distribution and software mailing lists, and ALWAYS make it a point to check your logs. It might sound pointless, but at least you'll be logging into a shell more often than you clean your gutters.

      If that fails, there is always Plan B.

    2. Re:Simple yet effective website security test: by Anonymous Coward · · Score: 0

      Actually I did this with slashdot a few years ago and collected some really great stats as hackers all over the world tried to bring our little server down, wrote some really great tests for us and ran them for us for over 24 hours till they got bored and moved on to the next shinny object.

  40. Nope. by Anonymous Coward · · Score: 0

    Sorry, you're doomed. SQL is horribly insecure, esp. MSSQL and MySQL.
    My recommendation: NEVER keep customer data online- keep it on your own computer.
    (Or, even better, keep it on an encrypted, password protected external disk set to DBAN itself if you type the password wrong, and never access the data unless you are on a non-networked computer. Then, power down and wait about 10-15 minutes, then turn the computer back on, so your RAM is cleared and overwritten. THEN, throw the computer in a lake while it is still on, and beat the external disk with a very large hammer made entirely of strong magnets.)

    Sorry I have to be the bearer of bad news.

    Good luck! ;-D

  41. First, make sure your webapp is secure by Anonymous Coward · · Score: 0

    The webapp, not the hosting environment is typically where the vast majority of the security issues come up. Once you've covered your app, ask the hosting company what their security policies are. Then, have someone knowledgable look at them.

  42. Not possible on a shared host by pushf+popf · · Score: 2

    If you don't control everything on the box, you can't ensure security.

    Regardless of what they claim or what they do, you're essentially sharing the box with hundreds or thousands of other users who potentially have access to run whatever they feel like.

    I would suggest a Virtual Private Server on Linode. Your server is yours and security will live or die by how you configure it.

    1. Re:Not possible on a shared host by angus_rg · · Score: 1

      Amen, but if you are developing the application, encrypting the data stored in the DB is a must and in some cases a requirement for PII.
       
      It's probably just as if not more important as sanitizing input and keeping an OS up to date because you don't know who in tech support will have access, and where they store the backups.

  43. Oblig by Pop69 · · Score: 1

    Should always be posted when mentioning databases

    http://xkcd.com/327/

    1. Re:Oblig by Anonymous Coward · · Score: 0

      http://i.imgur.com/MOUfk.jpg

    2. Re:Oblig by Anonymous Coward · · Score: 0

      No, no it shouldn't. BT and Godwin parrots need to have their Internet access suspended for thirty days for each post. Discussion forums are becoming littered with "meme bots", flesh and blood bots who simply regurgitate a prepared response when certain keywords are present.

  44. potentially useful service, nothing to install by Anonymous Coward · · Score: 0

    maybe a service like Stopthehacker.com can be useful

  45. Assume you've already been hacked... by pasv · · Score: 1
    What then?? after you've taken all the steps described in the above comments it's well worth the time to design an incident response plan.

    The best security is one that admits that it can be defeated, a layered approach is best. After they've hacked the webserver where can they go from there? your SQL server will be wide open.

    Consider using a grsec patched kernel, chrooting your webserver and restricting everything that isn't absolutely necessary. Grsec supports the feature to prevent binaries from executing on a specified chroot, this may prevent many attacks that would escalate their access. Don't provide compilers, don't have perl/ruby/etc available unless you need to. They may be able to penetrate with a staged payload dropping the privilege escalating exploit at the end and in this case the chroot may restrict their access. If they do manage to break past the chroot you want a fully configured RBAC system. Root shouldn't mean ring 0 in most cases. Disable loading kernel modules, disable /dev/kmem access, disable write access to boot directory and require password at reboot (this prevents them from loading a new unrestricted kernel).

    If you can afford it put a bridged firewall/IDS between the webserver and the database. Log everything, make sure your alerts work! Alerts are extremely important in that you can detect a hack in progress and possibly prevent further data extraction! Use white-listing instead of blacklisting. Only allow the absolute minimum. The idea here is that you want to reduce your attack surface as much as possible whilst still keeping functionality.

    That is just on the IT aspect tho. Consider the scenario in which an employee goes rogue: disable firewire port (DMA attacks are easily possible), disable usb ports, lock the server room, immediately lock out/revoke IDs to an employee about to be fired (preferably before they're fired), and for god's sake screen your applicants.

  46. Secure coding? by Anonymous Coward · · Score: 0

    Besides the things mentioned above about server security, ask yourself if you have done everything to follow secure coding guidelines for your application. Keywords are: XSS, CSRF, SQL injection etc.

    Keep in mind that pen testers will typically find a subset of issues, only. This assumes a typical timeboxed engagement.

  47. Veracode by Anonymous Coward · · Score: 0

    How small a business? Veracode () can do a variety of automated scans (on the software and on the site). The cost is trivial for a large business, large for a trivial business.

  48. Depends - what's the "hosting service"? by Anonymous Coward · · Score: 0

    (1) If it's shared hosting (many clients on one system), do the world a favor and just go bankrupt before launch.

    (2) If it's something at least somewhat reasonable (VPS, etc), follow some basic precautions:

    - DON'T write shitty code that allows SQL injection. If you don't know what SQL injection is, go to (1) - seriously, this isn't something that can just get "tidied up" pre-launch, you've either got good code or you've got a future security hole.

    - DON'T store anything worth stealing. Sounds sarcastic, but this frequently comes down to (a) unsalted and/or cleartext passwords and (b) credit card / banking information. (a) is bad because users frequently reuse passwords; thankfully there's wide support for things like bcrypt that produce strong password hashes - don't roll your own, unless you've neglected to mention a degree in cryptanalysis in your posting. As for (b), there are plenty of solutions for avoiding that storage (CC tokenization, etc) - let the people who build *those* services worry about the details.

    If you *really* need to be sure about security, you're likely going to have to step beyond a generic "hosting service" and get something more dedicated (colo, etc). You may also want to consider checking out EC2, as they were certified as a Level 1 PCI Service Provider; I also suspect they've got way more datacenter security than Bob's House of Colo and Boiled P-Nuts can manage....

  49. Mod parent up by wurp · · Score: 1

    Only, chroot every service you provide that could be accessed over the network.

  50. Security through Obscurity by metalmaster · · Score: 1

    Dont do anything to piss off a vengeful hacker collective.

    Lemme draw some parallels to home burglary. Your opportune thief is going to look at one or 2 attack vectors. If he cannot get in he'll move on. Contrast this with a professional burglar. He'll watch a target for days, weeks or months all while taking precious notes about weaknesses in security like a time of day where the property is unguarded or maybe a fault in your automated garage door. He's determined to get inside for something and eventually he will. It's far better to be shrugged off by the opportune thief than grab the attention of the professional burglar.

    Truth be told, you're going to forget something or there will be an attack vector you simply cannot do anything about. There's no such thing as 100% secure. I'd rather be a target for a script kiddie whose exploiting known and patched holes than piss off a group of dedicated hackers who do their own pentests and wont give up til they've found something to bring you down.

    1. Re:Security through Obscurity by Anonymous Coward · · Score: 0

      Scriptkiddies aside, nowadays everyone is a target by organized crime looking to embed redirects to fake AVs, banking trojans/bots and other malware, they will root any rootable site, irregardless if it is obscure or not, they are not interest in the contents of your databases (at least not primarily), but in infecting your visitors, if a site shows up on a search engine it automatically becomes a target.

  51. It's not rocket science. by gellenburg · · Score: 3, Informative

    Easy -

    Request, log, and record, only that information that is absolutely necessary and nothing more, and keep it only for as long as you'll need it and not a bit longer.

    You can save yourself some heartache by not storing any PII and PFI.

    Don't store payment information.

    Don't store credentials. Consider using OpenID or Google or (shudder) Facebook Connect for accounts.

    Keep sensitive information off any internet-accessible systems.

    And last, don't trust any input from your visitors.

    Sanitize all input.

    Declare all variables.

    Don't assume anything.

    If you're expecting an integer, make sure you convert the submitted form data to an integer for that variable implicitly.

    Same for dates, strings.

    Normalize all input.

    Sanitize all input.

    Never trust any input.

    Consider using a database abstraction library with well documented and mature APIs. Don't code things yourself.

    Don't turn on ssh password authentication. Require only public/ private keys.

    Turn register globals off in PHP. Use safe mode.

    Make sure MySQL is on a separate server, with an RFC-1918 address, accessible from a dedicated NIC that is not on the Internet.

    Consider a security audit and professional code review if you're planning on taking any money.

    1. Re:It's not rocket science. by Trolan · · Score: 1

      Turn register globals off in PHP. Use safe mode.

      Yes on the first, be aware on the second. It's been deprecated, as noted at http://php.net/manual/en/features.safe-mode.php Safe mode is really a band-aid on an open wound. mod_security, suhosin, proper file ACLs, etc. are all likely better options for dealing with the sorts of things safe_mode buys you, and all but suhosin are applicable to anything that isn't PHP.

      Aside from that, a good list. The one thing that can't be said enough: NEVER TRUST CLIENT INPUT. VERIFY, VERIFY, VERIFY.

    2. Re:It's not rocket science. by Shoten · · Score: 1

      You know that just about none of this information is at all helpful or relevant, right? It's a hosted solution; he has no control over any of this. Furthermore, he's asking about database security from the perspective of the hosting provider; 'sanitize all input' isn't something they can do for him. And finally, if your PHP hardening advice consists of "Turn register globals off in PHP. Use safe mode," I really have to wonder if you are just quoting something you heard in a seminar once during your 3-year stint as a web developer...oy.

      --

      For your security, this post has been encrypted with ROT-13, twice.
  52. Bottom up by Jaime2 · · Score: 1

    Draw out the communications architecture of your system and only allow those communications paths that are necessary. For example, users won't need to send packets to database servers.

    Look through the OWASP guidelines, make notes, and do a thorough code review. No matter how secure the systems are, the application must be secure too. There is a lot more knowledge out there on securing OSes and Web Servers, leave that to your hosting company. You need to concentrate on your application.

  53. Abandon hope, all ye who enter here by Anonymous Coward · · Score: 0

    Encrypt, then pray.

  54. depends on the data by Anonymous Coward · · Score: 0

    For certain kinds of data (health records, credit card numbers) there are published standards you can look at. [Hint: You are not going to comply with them hosting your app on a shared server.] You also need to know about the physical security of the hardware and (always hardest) the physical security of any backup media with your data on it.

    If you asking the question, the risk is high. You don't even know the scope of your ignorance. But risk is meaningless by itself; what you really need to figure out is the risk * your potential loss, I.e. the expected value.

  55. Employees = weakest link for most companies by garyebickford · · Score: 1

    Consider the scenario in which an employee goes rogue: disable firewire port (DMA attacks are easily possible), disable usb ports, lock the server room, immediately lock out/revoke IDs to an employee about to be fired (preferably before they're fired), and for god's sake screen your applicants.

    Beyond the many war stories, I went to a security conference back in 1999 (yes, that early) where the then-primary IT security guy for the Navy told us that in real-world penetration testing 'red team' exercises, the average cost to bribe a systems administrator to let you into the machine room and do whatever you want was just $7000.

    --
    It's easier to be a result of the past, but more fun to be a cause of the future! http://www.spacefinancegroup.com/
    1. Re:Employees = weakest link for most companies by JumpDrive · · Score: 1

      Shoot , they don't have to bribe anyone here. All they have to do is put on a hard hat and have a clip board and say they need to check the phone and data lines. They will let them right in.

  56. Add 2FA authentication by Mattpw · · Score: 1

    You should consider adding 2FA authentication token such as a Yubikey which has lots of great extensions or for more security a ShieldPass access card which has the mutual authentication capability.

  57. Who are you hosting with? by varmittang · · Score: 1

    What type of hosting are you getting? Shared hosting where you don't have the ability to do anything but setup a database, or you getting bare metal hosting where you can choose the OS and how to setup every detail of it, or you supply the hardware and routing equipment to a hosting facility . I suggest getting the bare metal or sending your own hardware, then using the docs you can get from the NSA on securing the servers. http://www.nsa.gov/ia/guidance/security_configuration_guides/operating_systems.shtml Like many people have said, make sure that you don't have direct access to the MySQL server from the outside, and that it only talks to the webserver to give data from the database. Even setup a management server where you can do WSUS and remote desktop stuff from if you are going Windows, or another Linux box that you can SSH into to then access all the other servers. If you do your own hardware you can supply your own firewall and setup VPN connection to it. Blah Blah Blah, you are getting the idea from what everyone is posting. So you should hopefully have a good starting point.

    --
    -----BEGIN PGP SIGNATURE-----
    12345
    -----END PGP SIGNATURE-----
  58. Poor Programming Practices by Oxford_Comma_Lover · · Score: 1

    > Poor programming practices opens you up to SQL injection.

    Insecure programming practices, you mean. They're poor only in 99.9% of situations, i.e. where the need for security justifies the brief additional time. You may not need them, for example, in an in-house diagnostic script you're using for a small company that only two admins can use--provided that you are disciplined enoight not to let that spill over into your more secure coding.

    --
    -- IANAL, this isn't legal advice, and definitely isn't legal advice for you. Also, Squee!
  59. Legal Issue by lonecrow · · Score: 1

    The OP specifically mentioned that he is in a hosted environment. So any pen testing he is doing at the OS level or against a multi-teneted MySQL environment means that he is very possibly committing a crime unless he seeks permission. Testing your website it self for vulnerabilities might be safe waters, running an aggressive Nessus scan against the server could be construed as attempting to breach 50 other websites and their databases.

  60. The best solution by Anonymous Coward · · Score: 0

    Fling poop whenever possible.

  61. Need to know by purplie · · Score: 1
    The first step is to think very hard about whether you really need to persist that data. Even when there's a clear need you can often scale back.

    Next, think about whether you need reversible encryption. If you're just validating passwords, use a one-way function. Similarly, if you only need the data for infrequent audit or forensics, you can encrypt it asymmetrically, where the system does not contain the private key. (Secure the private key somewhere else for emergency use.) The data goes into a black hole unless you manually intervene.

  62. Looking inside a virtual machine by thogard · · Score: 1

    The real problem with shared hosting (virtual or otherwise) means you have to trust the real host not to let someone else at your raw data. Since the real host can see into all the virtual machines, you have to trust it and secure it as well. If your not doing that, who is?

  63. There is only one way. by cuban321 · · Score: 1

    Best way, hire a good 3rd party auditor sign an NDA with them. You get another set of eyes on the setup. Plus they will use a number of tools to scan your product and the servers you host it on that you may not have easy access to. For example, IBM's AppScan is designed to scan web applications and test for SQL injections, XSS vulnerabilities, etc.

    At some point you may want to look at purchasing a copy of AppScan, however that would all depend on how often your code/environment will be changing. WatchFire was recently (last couple of years) purchased by IBM, which is how they acquired AppScan. I've tried most of the tools out there, AppScan is light years ahead of any others and it's priced that way too.

    Good luck!

  64. Email me the root password by blanchae · · Score: 1

    And I'll check it out for you...

  65. PCI Compliance by musicmaker · · Score: 1

    If you're holding customer credit card info, you'll need to meet PCI compliance regs. If you're not, you should look at PCI compliance regs anyway, because they're a good guideline.

    Then, when that has scared you enough, wake up look up prepared statements, and then don't use MySQL, especially if you are using PHP. Views don't work properly, subqueries bite, and you can't have joins in a delete statement that makes doing compound deletes virtually impossible without serious pain and suffering. If you were planning on using Amazon RDS, know that if you're tables are MyISAM based, the backups don't work.

    Have a nice life.

    --
    Everyone is living in a personal delusion, just some are more delusional than others.
  66. If you don't own the iron ... by dbIII · · Score: 1

    If you don't own the iron you can't stop anybody who does doing anything they like with it. Even if you can trust them (and you shouldn't even contemplate it if you don't) you have to rember the warning that was put in big letters on the QEMU web site years ago - "virtualisation is not security". It can't be trusted with full seperation as much as Solaris zones or even different user accounts on the same machine because security was never the aim and is only an afterthought. If somebody else is running their stuff in a virtual container on the same machine there may be flaws that can give them access to yours, since less thought has gone into preventing that than seperating the users on a simpler multi-user system. The odds are that you would have to be very unlucky to have somebody malicous and aware of such flaws on the same hardware as your virtual machine - but it's going to happen to somebody somewhere and is likely to get some press and get people asking you questions when it does.
    Then there's the simple resource issues where somebody else on the same box could be hammering the disk or taking all the bandwidth.
    Your own box in somebody else's rack is a different story. If you can trust everything on it, virtual machines or not, then the only others you have to trust are the people with keys to the door.

  67. skipfish by ludwigf · · Score: 1

    There are some automated tools like skipfish . They help finding possible problems but can't replace the eyes of someone with security expertise looking over the code and setup.

  68. A strong security foundation/front-end by Seferino · · Score: 1

    Have you considered using Opa? I may be biaises on this topic (I'm a member of the Opa team), but it sounds to me like it's a very good match for your issue. It's an open-source web development platform designed for security - it's an Owasp project, btw. Among other things, it guarantees that your application is invulnerable to XSS and SQL injection, and it performs a large number of analyses on your code, on the inputs, etc. to greatly improve security.
    Depending on the current status of your code, you can either use this as a foundation for the whole application, or just as a front-end.
    More info on the teaser website, on my blog, or on IRC (freenode, channel #opalang).

  69. Server User by Bert64 · · Score: 1

    One thing to check is the userid that your application code (php, jsp or whatever it is) runs under... Many shared hosting providers run all this stuff under a single shared user, which means that user needs to be able to read things like your database config including password... So if someone compromises another customer, they now have the ability to read all your files...

    --
    http://spamdecoy.net - free throwaway anonymous email - avoid spam!
  70. Websecurify by Karasuni · · Score: 0

    One tip I can give you is to do a vulnerability pentest on a copy of your system or before you launch. http://www.websecurify.com/ is a greyhat tool specifically built do a thorough testing (really, it's impressive software) of your site and it's extremely easy to use.

  71. It's Not Them, It's You by jman.org · · Score: 1

    The hosting company is the apartment complex. All they do is allow traffic to your door.

    What you do in the apartment is your concern.

    You may wish to involve a web programmer, or learn a whole bunch. ;)

    -rant-
    If the site will be taking money, beware PCI compliance. Experience shows most of the companies offering this "service" are just scammers. Just last night one of my sites failed due to alleged existence of a file that in reality is not even on the server. Not even the directory exists, yet it was flagged for this brand new "critical problem", and supposedly Visa can financially penalize the client due to "failure".

    They're mostly a bunch of lazy crooks cashing in on FUD.
    -/rant-

  72. You must be *this* tall to go on this ride. by ResidentSourcerer · · Score: 1

    Good advice previously.

    In general, if you aren't the sole admin user on the box, you shouldn't play. You can co-locate, sure. But you must be the person who is responsible for everything on that box. The ONLY access the co-location provider should be able to have is the ability to execute a shutdown script to protect themselves from your rogue processes.

    If you are not the sole owner, then you are dependent on their security being up to snuff.

    If your application is small, you may be able to work with a virtual cluster of machines running on a single box.

    I would give serious consideration to encrypting all sensitive information in the database. Even if the keys are wired into the application, it means that data extraction has to work through the application to get data.

    I would also give serious consideration to putting large quantities of meaningless information into the database allong with some means of filtering for your own use. A Black hat who gets 2 million email addresses from your machine, but finds that 99% of them are bogus will not earn the gratitude of his client.

    --
    Third Career: Tree Farmer Second Career: Computer Geek First Career: Teacher, Outdoor Instructor, Photographer.
  73. Expect to be hacked. Have a plan. Tell the client! by Anonymous Coward · · Score: 0

    If Google can't secure their servers, what make you believe that you can?

    a) Expect to be hacked.
    b) Have a plan for when it does.
    c) Tell the client that is will happen, eventually.
    d) Hope for the best.

    Keep as much data off that host as possible. Transactions over 30 days old probably don't need to be online on that web host. Limit the customer data stored there to only what is necessary to perform a specific task. Limit all public access as much as possible. Use a filtering, reverse proxy, if you must have a SQL DB, lock it down, only allow transactions from known locations. Enable encryption of the DB records. Most of your servers shouldn't be available to the public at all.

    I've sat down with multiple CEOs and had this same discussion. "We will be hacked. There isn't anything that can be done and you can't afford to do everything necessary to prevent it. Having a plan for dealing with a hack is the best we can accomplish."

    Get them to sign a peice of paper saying that and provide them with a mitigation plan.

    If you are only deploying a single server, you sir, are an idiot. Clearly, this is just a troll's opinion, but most PHP programming types simply do not have the appropriate background and experience for system design roles.

  74. Focusing on the real question... by Shoten · · Score: 1

    So, from what I saw, you're asking about the security of the MySQL backend, which is the place where the hosting provider has the most control and you have the least. All the talk about hardening standards that you should read up on is rubbish; you don't get to harden the systems, they're already as hard as they will ever be (whether hard or not) because of the way the hosting provider has provisioned the system. So what you're really into is a situation where you need to know how to spot a secure architecture and good standards, and then get them to show you their architecture and provisioning standards so you can see for yourself how solid they are.

    All the talk about PHP hardening, pen-testing, etc. is fine, but the main concern I would have is about what happens if someone gets to their backend database(s) via someone else's insecure website...becuase that website exists today among their customers, has been there already, and will continue to be there in the future. What protections are there to ensure that an attacker who gets through to the database backend of "Insecure Website Inc." won't also be able to leverage their way laterally to your backend? This is as much an architectural design question as a security hardening standards question; both come into play. I'd look for things like reuse of passwords (if they provision every MySQL database separately, are there any credentials that are common to all of them?) and ways they make sure that getting control of the database won't result in gaining access to the things like the underlying operating system or provisioning infrastructure.

    Oh, another thing...the security guidelines that a lot of people are bandying about in earlier responses aren't necessarily enough. There are a whole set of other concerns for a multitenant environment, as found in a hosting center...so make sure that whatever you work with contains that bit of awareness. They'll call it out explicitly, if they cover it.

    --

    For your security, this post has been encrypted with ROT-13, twice.
  75. Perfect World by visionbeyond · · Score: 1

    While any server that is not completely within your level of control opens up possibilities of having it compromised, there is also no 100% guaranteed secure configuration that you could do even if it were 100% in your control. I would knock out the obvious first by doing a port scan on the server address to see what services may be running that aren't needed. Also make sure that MySQL is bound to the loopback IP and not the public IP (unless you have multiple servers accessing a central database server, in which case setup SSH secure tunnels with permission restrictions limiting only those servers - although it would be better to just install a second NIC on each server and also run a private network link between the servers). Code wise, I'd make sure that you are validating all submissions and are protected against SQL injection attacks. You can also change settings in PHP to be restrictive in memory usage, file upload size, and handling of requests by setting the minimum required value that your code base would need or use. This can be done in the Apache virtual host configuration, if they don't want to use those settings globally on a shared server. Lastly, when all else that can be done is handled, make sure to encrypt any sensitive data in the MySQL tables. Sure, if the server is compromised, the hash key string or other methodology key is contained either in the code base or in the unique key to the MySQL install, but it's one additional step and would require them to have much more data downloaded - which if nothing else, buys you time that they would need and for you to find them in the process. Oh, and depending on if your running in your own chroot setup, you can use non-standard ports for services like MySQL. Let's face it, the majority of hacking is done by script kiddies that are executing code or things they don't even fully understand. Protecting against the other 5% is a bit more involved, but also unlikely if you protect against the common automated attacks.

    Good luck with your new site, and hope you have great success. If you take pride in your product, regardless of what it is, and make it as well as can be made and sold for a fair price - you may not make a boatload of cash overnight that screws the consumer like every other company in the world, but you will have steady and long lasting profit, as well as providing a value to the world. At least that's my two cents on a world with declining business ethics. 8-)

  76. The 3 most important things about web app sec by rgviza · · Score: 1

    1. MySQL SQL injection. Every single parameter fed to the database needs to be run through the mysql_real_escape_string function. To be future proof, queries should be sent as prepared statements. If you don't know what this stuff is, go to php.com and start reading. mysql_real_escape_string() is a good stopgap measure you can easily implement to scrub your parameters, however, long term you should be using prepared statements. Prepared statements tell the database "This parameter is to be treated as data and not interpreted as SQL". They separate the meat from the milk so to speak. This is the future proof way to secure your SQL queries. Stored procedures do NOT secure your code simply by being stored procedures, although, strongly typed input helps a great deal. No matter what you will be accepting strings/char etc in your database and that's where you'll be vulnerable. Prepared statements when used within stored procedures help, but you can SQL inject your way out of a non-prepared stored procedure call too, even if the sql within is a prepared statement. Make your stored proc calls with prepared statements, then the SQL within the stored procs should also be prepared statements. Do some reading about this stuff. Read it til you understand.

    2. XSS. Every variable you get from GPCS (get, post, cookie, session) or database should be wrapped with htmlentities() before display on a web page. This prevents people from phishing your users by neutralizing javascript code they may try to inject. Javascript will simply display on your page and not get executed, making it harmless. If your regexes aren't the greatest, javascript can be sent to your db, then displayed as content. That's why even if it's coming from your db, you should htmlentities() it before displaying it.

    3. Scrub your input. Input should only consist of printable characters. scrub it before processing to remove binary data, nulls and other potentially harmful stuff (unless you are handling binary such as a file upload or something). There are regex recipes all over the place for doing this for removing javascript, sql etc. None of them are perfect and that's why you absolutely must adhere to rules 1 and 2. You should also limit the length of the input to prevent buffer overflows that your scripting language people may have missed in their language.

    Naturally the usual stuff about securing your server etc apply. Admins are really good at this stuff. However the average off the shelf app will have a lot of vulnerabilities. Almost all of them will be one of the 3 listed above. They are easily fixed. The hard part is finding them. Use grep.... look for "insert, GET, POST, update) etc and other keywords related to sql inserts, updates, delete, create and select.

    If the app you are thinking of using doesn't do this stuff, walk away. Find another one. It's also good to force your users to use strong passwords and all that other stuff people mentioned, but you can have the most secure box in the world but if the application running on it is insecure, you will be pwned.

    Security is more than just web app security but web app security is where 99.9999% of FAIL occurs and 99% of that happens in items 1-3.

    --
    Don't kid yourself. It's the size of the regexp AND how you use it that counts.
  77. Get it in writing by Vrtigo1 · · Score: 1

    Well, the short answer is that if you're in a shared hosting environment, you probably can't do much and in that situation I probably would not recommend storing sensitive information. Assuming you are on a dedicated server or VPS, you can secure your server, but what you need to worry about is what type of security do they have in the network as far as IDS/IPS, network segmentation, and firewalling, as well as what type of physical security they have. I.E. where are the machines physically located, who has access to them, are they under NDAs, what type of background checks have been run on these people, etc. Unfortunately, the truth is that a lot of this stuff may be spelled out in a service agreement, but it may not actually be practiced. If you care about CYA, then get it in writing. If you actually care about not having a breach so you can keep your customers, then the answer is probably something more along the lines of host it yourself in a secure physical environment, or colo a box that you own at a place that you trust, do not give root priviliges to the colo provider, and hash/encrypt the sensitive data on it.

  78. SQL operator IN without concatenation? by tepples · · Score: 1

    If you must script, NEVER EVER concatenate SQL. If no ORM is availble, use whatever languages parameterized SQL scheme.

    I'm looking for an easy-to-use alternative to concatenation in cases like these. For the example, the right side of SQL operator IN is a 1-column table:

    SELECT username, joinDate FROM dxt_users
    WHERE username IN ('filbert', 'bluebear', 'chief')

    But some DBMS APIs do not support table-valued parameters, only scalar-value parameters. I could parameterize the values in the table on the right side of IN, but only if I have to know in advance how many placeholders to use (for example, username IN (?, ?, ?)), and I almost never do. So without concatenation, how do I build the right side of an SQL IN expression? Or do you recommend CREATE TEMPORARY TABLE with one column, executing a parameterized statement to INSERT values into this table one at a time, and then using this table as the right side of an IN or JOIN?