Follow Slashdot stories on Twitter


Forgot your password?
Security Open Source Programming Games

Security For Open Source Web Projects? 105

PoissonPilote writes "I'm currently developing a multi-player, browser-based game, using the good old HTML, JavaScript, PHP, and MySQL combination. Progress is good so far, and the number of players is slowly but steadily increasing. At the beginning of the project, I decided to put the entirety of my game under the MIT license, so that anyone could study the code or even start their own server for the game. However, with the increasing popularity of my project, I am starting to worry about security issues. Even though I consider myself decent at web development and am pretty sure I'm not making any classic mistakes (SQL injection, cross-site scripting, URL forgery, etc.), I am no web security expert. I didn't find any relevant examples to compare my game to, as most open source games are written in a compiled language, and no web server is at stake in those cases. Some web developer friends told me not to release the source code at all; others told me to release it only when the game will be shut down. Naturally, I'm not satisfied by either of these solutions. What approach would you recommend?"
This discussion has been archived. No new comments can be posted.

Security For Open Source Web Projects?

Comments Filter:
  • Solution: (Score:5, Funny)

    by Anonymous Coward on Sunday June 27, 2010 @01:30PM (#32709816)

    Use VB 6.0 MS-SQL Server 2000 and IIS 5.0, can't go wrong there.

  • by Nadaka ( 224565 ) on Sunday June 27, 2010 @01:34PM (#32709832)

    The entirety of the game state should be stored on the server and all user inputs should be validated on the server.

    This won't stop people from botting your game, but it will keep the major chunk of blatant cheating to a minimum (at least on unmodified servers).

    • Re: (Score:3, Informative)

      by Mad Merlin ( 837387 )

      That's pretty much the best advise you can get — never trust the client. But as with everything in technology, there's no silver bullet. You also need to consider what you're passing back from the client, try to pass as little as possible, the less you pass back, the less you need to validate and the less chances you have to make mistakes. Also consider what form the data you're passing the data back from the client is in... validating integers is trivial, validating freeform text (especially if you'r

    • Re: (Score:2, Informative)

      by Anonymous Coward

      The entirety of the game state should be stored on the server and all user inputs should be validated on the server.

      Actually, there's a really nifty trick you can do: make the client store your data for you, but signed with your key. That scales cleanly with the number of clients and keeps the security.

      You can expect that if people are going to get the source code, then they're going to set up their own instances and then run a standard web security scanner on it. You can do that first. Skipfish [] will hammer

      • by Nadaka ( 224565 )

        No there is no such trick.

        Any game state you store on the client in encrypted form will either require the client to have a key to decrypt it, defeating the security you want. Or it will be inaccessible to the client and will have to be retransmitted to the server with every action, and that defeats the purpose of having it on the client in the first place.

        • You're both right.

          You are right: there is no such "trick" in the sense that there's not really anything to be gained by storing swathes of game state client-side.

          He is right: presuming you implement your crypto correctly, you could (in theory) store bits of game state client-side without the fear of tampering by cheaters.

          I'm afraid I can't see any real benefit in doing so -- it seems like a lot more trouble than it's worth, and I'm not sure it's a good solution to any problem -- but you could certainly do i

        • Wrong. He's talking about crypto *signing*, not encryption.

          Alice is playing Bob's game, and storing some game-state data. Bob signs the data with his private key, and Alice can read the data no problem. But were she to modify it, the signature would no longer be valid (which anybody can check) and the state would be re-downloaded.

          The game state isn't a secret, it just needs to be invalidated if modified. Signatures are perfect for this, just sign any changes that your server accepts.

          • by Nadaka ( 224565 )

            My point: store all state on the server, validate all user input.

            His point: you don't have to store all state on the server, you can store some on the client if it is signed and you don't have to validate the input.

            I get that, and its wrong.

            1: there is no way to fix invalid state if the client is the one storing the state and not the server. This goes to my original point, the server must store all state and ensure that every request is valid.
            2: The context is a multi-player browser based game. Yes, some as

  • Depends... (Score:3, Interesting)

    by hkmwbz ( 531650 ) on Sunday June 27, 2010 @01:35PM (#32709838) Journal
    That depends a bit on your resources, now doesn't it? Is it just a game you are working on as a hobby? Or are you expecting to commercialize it and make money? Do you expect a lot of users, or is it just something for your friends and acquaintances to play?

    If you have the resources, you can always hire someone who might know more about it. If not, you could try relying on people's goodwill, and tell them upfront that "I need help with security".

    Finally, didn't Google develop a system to test web application security? I'm pretty sure there was a story about it on Slashdot. There may be other solutions out there that will help you to at least plug the most obvious holes.

    • If you pay a qualified expert, they ought to be able to point you in the right direction. I would want to meet them physically though.

      That story you mention sounds like the Jarlsberg one. The idea is you learn to secure your web application by exploiting a demonstrably weak one, so you learn your lesson. If you have the time, I definitely recommend working through it all. (story [] Jarlsberg homepage [])

      Another area to look at is simply your web server configuration. Your web application never runs in isolation.

  • sandbox it maybe? (Score:5, Insightful)

    by roman_mir ( 125474 ) on Sunday June 27, 2010 @01:35PM (#32709844) Homepage Journal

    Probably you want to sandbox your webserver, put it into a VM, run it as some user other than root obviously, have a HW or OpenBSD/PF based firewall sit in front of it and redirect requests to your VMs network, make sure no other services are running that can be accessed from the outside excluding the VM, probably add SSL to it (we just had a discussion on self signed certificates [] a little while ago here and what kind of POS it is to work with browsers in that case). I mean, it's a game, nobody is going to point and laugh at you if it has some web security issues, but you are not exactly explaining your architecture here either, you probably would be better off sandboxing it into a VM like that.

    • also <?php include("security.php"); ?>

    • Re: (Score:1, Insightful)

      by Anonymous Coward

      Useless. You are completely missing the point. The problem is protecting the security of the PHP webapp - good luck with that - not preventing attacks against other services.

      • Re: (Score:1, Offtopic)

        by roman_mir ( 125474 )

        Useless you say? When the server gets rooted and will have to be reinstalled from scratch it won't seem as useless.

    • by ksandom ( 718283 )
      Something that occured to me as you said this, was VM + external logs. So if the VM gets trashed, you still have a pretty good idea what the last thing to happen was. Most HW basd firewalls will give you a log of URLs, but even that can be like finding a needle in a haystack.
      • write log files to a dedicated partition maybe?

        • Doesn't help if whatever writes is compromised.

          Sending over the network to some dedicated server which allows only appending to the log, and no other access from that particular network (management network only, or from a whitelisted list of servers) is definitely secure. Even better if 2 of such hosts are used where another is in another network completely, and automatic cross comparison are they the same :) (Just make sure their logs are exactly synced)

  • by Anonymous Coward on Sunday June 27, 2010 @01:41PM (#32709880)

    Don't make the mistake of thinking that obscurity (that is, making your code secret) guarantees security.

    Also note that there are very secure projects (such as OpenBSD) which are released under the MIT license.

  • by PrecambrianRabbit ( 1834412 ) on Sunday June 27, 2010 @01:52PM (#32709932)
    Closing the source does not make security holes go away. It may make them *marginally* harder to find, but probably not much harder for experienced attackers. What closing the source does do is make it harder or impossible for people who know something about securing such things to help you.
    • Re: (Score:1, Redundant)

      Mod parent +n, no shit!
    • by Quirkz ( 1206400 )
      Yes, absolutely true. Though if you're lucky, especially in a game scenario, that "experienced attacker" might also be a friendly, curious player who will provide great services by finding the bugs and alerting you about them.

      I run a game with a nearly identical setup. I do not reveal my code--not for security purposes, but to maintain the game's secrets. My players have been one of my greatest assets in terms of testing and bug reporting.

      Yes, you also occasionally get someone who wants to just game
  • Disaster Planning (Score:5, Interesting)

    by Anonymous Coward on Sunday June 27, 2010 @01:58PM (#32709946)

    Disaster Planning has nothing to do with the code base (thought the code can make recovery easier) but it has much to do with security. If you can prevent security breaches with good coding, great but most of us have to suppose that we missed something so being able to deal with problems once they arise is just as crucial as preventing them in the first place.

    For example: keep backups (snapshots) of player state on a separate machine unreachable from the webserver. ie the other machine logs into the webserver and copies data out. This way should the unfortunate happen you zap the webserver instance and restore from backup loosing at most the snapshot interval worth of game play. Yes some players will be upset but they won't all be starting over from scratch.

    Some times this is called depth or security beyond a crunchy shell, but I like to think of it in terms of the big picture model where great gameplay, security, and disaster recovery are all pieces of the picture and without all the pieces the product is incomplete. (Kinda like Windows not having an ssh command line client, it's not a usable OS for me until I've installed an ssh client)

  • by noidentity ( 188756 ) on Sunday June 27, 2010 @01:59PM (#32709952)
    You didn't make clear what you were trying to secure in the first place. Are you securing against someone doesn't exploit your game in order to get control of the server itself? Are you securing against someone cheating within the game? Securing user data from tampering? Each of these has different costs when breached.
    • by fishexe ( 168879 )

      Each of these has different costs when breached.

      Not to mention, different countermeasures.

  • by Surt ( 22457 ) on Sunday June 27, 2010 @02:03PM (#32709976) Homepage Journal

    Assume your server will be rooted. Minimize the damage that can be caused, and maximize the information you can get to defeat the next attack. So:

    Have everything backed up to something physically separated from the target.
    Have lots of logging to analyze in the event of an attack.
    If you have other more conventional stuff you want to keep up, have a spare server with everything minus the game ready to switch in after an attack.

    • Re: (Score:3, Informative)

      by ashridah ( 72567 )

      I'm with this guy. If you can afford to, separate the web tier and the database tier physically. Provide extra layers of security on essential stuff at the database tier (additional validation via procedures, etc). Make sure the app keeps a secure write-once log of every transaction that occurs for all players. I'd direct that off to another machine as well, if you can.

      You might remember some time back that there was a case where EVE players found a way to essentially cheat to create more resources than the

    • I have no points to mod you up, but I was planning to make a similar post if noone else had (till I read yours just now).
      I used to run a MUD []. This was back in the '80s.
      This is actually where I started programming. I learned C and rewrote the codebase from the ground up.
      Then, in the 90's I ported it all into PHP to run on the web. This was how I got started in PHP
      I haven't worked on it since the 90's, I'm currently a fulltime web developer working in PHP, with all the regular associated technologies: Jav
  • For every person out there who finds a hole in your code and tries to exploit it, there will be someone who will help and patch any holes - if they exist.
  • mod security (Score:2, Informative)

    by voot ( 609611 )
    i would definitely check out mod security. it has injection detection which is good for any web application and a open source one is no different.
  • A few things (Score:5, Informative)

    by raddan ( 519638 ) * on Sunday June 27, 2010 @02:09PM (#32710016)
    • Never pass unvalidated input to your database
    • Never pass unvalidated input to the system
    • Always validate on the server-side; client-side validation should only function as a convenience to the user
    • Validate data coming from other servers (if you're doing any web services stuff).
    • Encrypt connections to the server
    • Enforce inactivity timeouts
    • Do not allow multiple logins to the same account (unless you want your game to application to work that way)
    • Always authenticate users; consider using two-factor authentication (CAPTCHA + password, etc)
    • Allow administrators to revoke accounts
    • Make it easy for administrators/force administrators to sandbox/chroot your application
    • If your applications needs to use server storage, consider DoS attacks (a user uploading lots of stuff)
    • Make sure all privileged actions hit the same authentication class/function; if you change your authentication code, this ensures that the changes are applied across the board <-- I catch newbie programmers making this mistake all the time!

    If you do all of the above, your app might still not be "secure", but breaking it will be a PITA.

  • by ducomputergeek ( 595742 ) on Sunday June 27, 2010 @02:14PM (#32710060)

    I worked on an OSS browser based MMOG in the late 1990's up until 2003 when someone compromised the OpenBSD server it was being hosted on. As many people who play to win the game, there are more who pride themselves on beating the system. And folks take these games way too seriously.

    Not only do you have to keep up with security with your programming, you have to keep on top of your system security. Being a good programmer is almost secondary to being a good systems admin as I learned. That means subscribing and reading all the US-CERT warnings that come out, updated to the latest version of PHP/MySQL as security patches are released, and paying attention to any subsystem/process that is running on the server as well making sure that DNS/BIND, Apache, and anything else running is also up to date.

    When my system was compromised, it was one of the other system utilities that was the angle of attack. Something I didn't even bother to notice at the time. Not the game or any of the core software that was being used. After 3 years of constantly battling the people trying to beat the system, the 20 - 30 hours of my free time it was taking to manage it wasn't worth the modest revenue coming in so I put the code up on sourceforge and walked away.

  • by PatPending ( 953482 ) on Sunday June 27, 2010 @02:17PM (#32710080)

    For a start, consider using LIDS []

    (The name is a misnomer because it prevents alteration of protected components (even as root).)

  • by TSHTF ( 953742 ) on Sunday June 27, 2010 @02:55PM (#32710298) Homepage
    I highly recommend you read the announcing security vulnerabilities [] section of Producing Open Source Software [] book. You'll probably want to read the whole thing, however!
  • by twistah ( 194990 ) on Sunday June 27, 2010 @02:56PM (#32710312)

    You got me before my morning (afternoon) coffee so here are some haphazard thoughts:

    1) You're writing a PHP/MySQL app. It doesn't matter if it's a game or the next big social networking site. There are holes common to all web apps (check out the OWASP Top 10 []). There are also holes common in PHP code, such as remote file inclusion. There are things you can do wrong with JavaScript. Learn about them, learn about how to prevent them and write your code accordingly. Security should be part of development, not something you tack on afterward. This means using good coding convention (i.e using parametrized queries instead of concatenation, always encoding output, etc) and ensuring that any design decision you make does not compromise the security of your application. Make sure security is multi-layered as well. For example, even if you think your app is 100% free of SQL injection (wrong assumption!), you still need to make sure you've properly hashed user passwords in the database in case they're exposed. (Side note: please don't use MD5 for this; look into bcrypt, or at least many rounds of SHA-256 or such.)

    2) Harden your environment. No amount of hardening will stop all attacks, but it may help mitigate their impact, and if you're lucky, it may thwart some script kiddies or automated scripts. Running PHP? Harden the crap out of your php.ini (magic_quotes_gpc, turn off fopen() for URLs, etc). Think about installing the Suhosin patch []. Just don't get complacent; there are ways around all these protections and they are not a substitute for secure code! You may also consider a web-app firewall (WAF), in the vein of mod_security, but don't fully rely on these either. If you're publishing code for others to use, don't ever count on your users to implement these same protections in their environment.

    3) Web app scanners can help, especially if you're a novice with security, but once again, they will not catch everything (probably not even a lot of things.) There's skipfish, NetSparker and free versions of some of the more commercial scanners.

    4) I know your question was whether to publish your code. I say "Yes", but this is a personal opinion -- I just happen to think it will give security dudes more of a chance to audit your code, and attackers will find your vulnerabilities anyway, through poking at your app and fuzzing even if nothing is published.

    I hope that helps a little!

    • Re: (Score:2, Informative)

      by Daem0nX ( 718135 )
      For encryption check out []
      "LGPL-licensed pure-PHP implementations of an arbitrary-precision integer arithmetic library, fully PKCS#1 (v2.1) compliant RSA, DES, 3DES, RC4, Rijndael, AES, SSH-1, SSH-2, and SFTP."
      Great to have if you're not sure others will have mcrypt or other options installed on their server.
    • If you decide to go the route and publish your code, you could at least make an effort to set up the infrastructure to handle bug reports and issue reports from those who discover vulnerabilities. As long as you are proactive in following up any reports, people filing security-related bug reports will feel that they are being listened to, and won't be discouraged from reporting again. Because you want to use a MIT licence, there are plenty of free open-source hosting solutions who will be happy to host your

  • We could probably have a more detailed discussion looking at the actual source. That's one of the advantages of Open Source. There's some good advice here already, but for what you're doing I would lean heavily on making it as easy and painless as possible to recover from an incident. Let's say you have a major incident.

    If you run it all in a VM you'll lose some performance, but you can snapshot it, kill it and ship the snapshot to a local machine for forensics while directing everyone to a "Maintenance in

  • This is my approach (Score:1, Interesting)

    by Anonymous Coward

    I trust nothing the user sends
    I trust nothing the user sends
    I don't trust the SAs as I was one
    I dont trust the NAs as I was one
    I don't trust the DBAs as I was one

    After I have all the functionality I need
    My to do:
    I keep everything sensitive _encoded_ to increase effort (not encrypted, performance for the end user is balanced against the privacy)
    I dont keep logs or any information not needed as an attacker can use those logs against you, the system and the users (contrary to what other posters said)
    I try to a

  • While we all appreciate your aversion to slashvertisement, I'm sure some of us would enjoy seeing what you've put together and/or contribute. Since it's in response to an explicit request for the information, can you point us at your project?

  • by Anonymous Coward

    Security solution doesn't need to mean zero vulnerabilities. In addition to preventing attacks, you should focus on detection and recovery aspects.

    Assume you will be attacked, will you be able to notice it? Write statistics systems to display player progress over time (or income per day, etc) and make sure you can spot unusual cases. Keep logs of events to track down what exactly happened so you can figure out how the suspicious players did what they did, etc...

    Also, something will go wrong eventually. Can

  • Use the OWASP Application Verification Standard - this gives you an insight to the controls you need to work on first. A game should be at Level 2B. []

    Don't worry about the language snobs - ANY language and ANY framework can be secured as long as you do the right thing in terms of design. Where you can go wrong is trusting untrustable data - such as that obtained from the browser without first canonicalizing, valida

  • 1) First, you have to protect your users. I'd say there are three things to worry about here:
    - SQL Injection. "Little Bobby Tables". This one is easy - use bind variables for all sql, and don't -ever- have dynamically interpreted sql with user inputs.
    - Cross Site Scripting ("XSS"). This one is harder. If you ever display something to one user that could have been entered by another user, user b can own user a with some html. It's very hard to check for bad html because it can be disgui

  • Here are a few pointers, mostly around PHP web app security:

    - [] - the Open Web Application Security Project has a comprehensive list of things to cover - see their [] (top 5 PHP issues) in particular

    - [] Top 7 PHP security blunders - use =htmlspecialchars= for output of variables to page and do MySQL string escaping

    - [] - ensure include fil

  • Well, having been an open source developer for almost the 10 years, I know a bit about this. Firstly you need to code as securely as you can. Do the research, make sure you know whats going, and audit your own code thoroughly.

    Don't believe no one else is looking, because they are. I've had one person ask me a few innocent questions about my code, then email a back a week later to say I'd passed their security audit just fine. I've also been unlucky enough - just once - to have the full disclosure emai

  • Does your game really require a server? Servers increase cost for open source projects, so I would run as much code as possible on the clients. Granted that you need the server to set up the games, but all actions could be refereed indepently by several clients. If they don't agree, this may mean that someone is using a hacked client, and a warning should be displayed. The more players participate in such a peer-to-peer game, the more clients would have to be hacked in order cheat, but of course a single vu
  • I do security code reviews for PHP/mysql projects in my day job. I like to help with open source projects in my spare time.


"Hey Ivan, check your six." -- Sidewinder missile jacket patch, showing a Sidewinder driving up the tail of a Russian Su-27