The Hazards of Exposing Business Logic on the Client

Via Ajaxian we get an object lesson in the dangers of exposing business logic in the browser:

Beau Hartshorne of Snipshot (formerly Pixoh) says “massive chunks” of Cellsea code are identical to Snipshot. “This is not an accidental inspiration. Check out the cropping code, the resizing code, and so on. We’ve also noticed that portions of their website are also stolen directly from ours … We are contributors to MochiKit open source project. However, the code in question is proprietary and was taken directly from out site.”

Can I say “I told you so?” I’ve blogged about the danger of Ajax and Leaky Business Logic before. What is the danger here and the lesson the be learned?

  • Don’t put your crown jewels in the browser. See if you can’t lock a fair bit of your business logic on the server side by using a server-side component framework like Echo2 or ZK.
  • If you’re going to deploy meaningful applications in Javascript, do what people have been doing with script source code for decades: obfuscate. You can do something simple like renaming all of your variable to one or two character names, or you can use a code generation framework like GWT or Morfik that produce unreadable code from the beginning. Be forewarned that code generators can be vulnerable to decompilers — in short, if someone knows how GWT generates it’s code, you could possibly reverse the process and produce the original source code.
  • Build in anti-theft mechanisms. This could be something as simple as a method that checks to see that the url the application is running on is the correct one, otherwise display a nasty message. You could make this as tricky and complicated as you like, all the way to encrypting big chunks of code with the website url and only decrypting them at runtime.
  • Hold out for “byte compiled” Javascript.

A combination of all of these may be what we end up with. I’m not sure I’d want to run any script in my browser, though, that I can’t understand. Still, you would hate to be the victim of code-theft as has apparently happened to Snipshot.

How similar are these two programs? Well, Cellsea offers a bunch more functions, but they do look very similar, both in terms of the UI and the underlying code. The original Snipshot is here and the knock off here. You be the judge.

If you are really hungry for a good AJAX image editing app, the best of the bunch of them may be Phixr, which gives you preview, the ability to marquee select for certain operations, etc. Slick, even if the UI is a bit jumpy.


  1. caricature Reply

    this is a great post! interesting conversation…. Thank you very much for this.

Leave a Reply


captcha *