Blog | RSS | Photo Gallery | Wish List     Eric's Blob
Mind Your Mother Posted at 15:48 by Eric

Remember what your mother used to tell you about validating parameters in web applications? That it was a good idea to do some checks via JavaScript to save a round trip to the server, but that these same checks must be done on the server as well?

Well, here is why. You only need a really crappy web app, greasemonkey, and a hard drive to save (and edit) and HTML file on.

The really crappy web app I use is one at work which we use for help desk / task management.

The problem is simple. The entire security scheme for the app is based in HTML and JavaScript. There are two parts to this security problem.

One is a series of JavaScript variables, which decide what queues you're allowed to read and write to, whether you are allowed to close tasks, and the like.

The other part is a Java Applet, defined with HTML parameters which decides silly little things like whether or not you are considered a support representative, or a user.

There was a day when, in order to mess around with all this, you'd have to go through a lot of hassle by saving the HTML, modifying it, and later loading it. With this particular app, doing that for the entire thing is a bit tough, due to it's rather complex usage of frames and Java.

But no worries, GreaseMonkey is here to the rescue. See, with GreaseMonkey, instead of having to bother with stuff like saving and reloading documents, we can simply instruct GreaseMonkey to change variables after they're loaded.

Really, GreaseMonkey is just a FireFox extension that runs user defined JavaScript on any given page. So, to start messing with this crappy web app, all we need is the following one line script loaded into GreaseMonkey:

    write_perms_on_queue2 = true;

Well, the variable names in this app weren't quite that obvious, but you get the idea. That's all you need. Now repeat for all variables you want to modify.

There were also some JavaScript functions they had loaded that I considered annoying. They yelled when I clicked things they didn't think I was supposed to. They'd keep returning "false" (ie, failing) until I clicked things the way they wanted. No problem. Add this to your GreaseMonkey script:

    document.annoying_function = function() { return true }

So far, we're on the first security problem. Lets talk about the second one. They have a Java applet which loads all the menu's. I dug around in the source a bit, and discovered tags like this in the applet definition:

Okay, good, I'm considered a 'Rep', but I think I'd like some more permissions.

Now, hard as I tried, I couldn't get GreaseMonkey to fix this. I think the Java Applet loads too early for it to do anything. So, I just saved the page which defines the permissions to my hard drive, and changed it to a more suitable number.

With the monotony of frames they had, I had to jump through a few other little hoops to make this work with this particular app. But, a couple of tweaks later, I load this app using the file on my hard drive, and viola, there it reads:

    H4x0r3d Helpdesk Web Interface

There's not a whole lot I really gain by all this aside from some amusement (though, they should still be told about their lax coding, any of our users could do this as well... I guess I'm really not all that concerned though).

Moreso, I think this is a warning of where things are going. Where there used to be at least some hoops to jump through to change data on web pages we've loaded, there's now a mechanism for doing this automatically. There's a repository of such scripts online. I don't think most or maybe even any are bending any security; moreso, most are tweaking websites to better work for us. Which I think is great.

What I think we need to watch out for though is the ease with which one can bypass such poor security mechanisms. There may have been a day where coders could get away with such things, but thats long gone.

| |

     Posted at Tue Aug 23 20:29:59 2005 by Don Spidell
You could also decompile the .class file of the Java applet and change how that works too. I ran across a password protected page recently. I saw that it was using a Java applet to accept a user/pass and that there was no reload of the page to validate the credentials. That told me that the key to getting the user/pass was in the .class file. I decompiled it and was able to figure out a valid user/pass combo for accessing the site. (This applet was on a friend's website, so I was doing it for his own protection.... and my own amusement.)

Java Decompiler      Posted at Tue Aug 23 20:36:18 2005 by Eric Andreychek

Hey, that's pretty cool.

Funny you mention that, I had ended up using one called jad (http://kpdus.tripod.com/jad.html) to take a look at the ones included with the helpdesk package we use, in the hopes of figuring out what the privilege numbers meant.

It helped a bit -- and it was interesting to see what else was going on -- but in this particular case some trial and error turned out to be quicker :-)

You're absolutally right in that now, we could modify the class any which way we want.



     Posted at Wed Aug 24 19:51:22 2005 by Don Spidell
Could you use greasemonkey to remove the stupid "autocomplete=off" attribute from form fields? If I'm going to use Autocomplete for stuff, I'd like to decide when to use it and when to not use it, not the webmaster of a site I'm visiting.

Rewriting Attributes      Posted at Wed Aug 24 20:23:20 2005 by Eric Andreychek

Sure Don. You could do it a few ways. The quickest would probably be just to do a "getElementsByTag('FORM')", and loop over the results... you could test to see what attributes each has, and reset the attribute if it exists: if (element.autocomplete == "off") { element.autocomplete = "on"; }



that's funny because...      Posted at Fri Aug 26 12:55:09 2005 by Nathan
...my mother always told me to do validation server side. Hmmmm.


Post a Comment
    Name:
    URL/Email: [http://... or mailto:you@wherever] (optional)
    Title: (optional)
    Comments:
      Use HTML for formatting. Allowed HTML: <a> <p> <b> <i> <u> <hr> <br> <ol> <ul> <li>

trackback

TrackBack ping me at:

http://www.openthought.org/blosxom.cgi/Blog/Computers/Organizations/Home/mind_your_mother.trackback