All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

An Inspector Calls

28 April 2003

I was reading this great article about the Mozilla DOM Inspector. The Inspector enables developers to make on-the-fly manipulations to a page in order to debug and try out ideas and solutions. If you haven’t discovered the DOM Inspector yet, it’s worth reading the article as it’s another useful tool to have at your disposal. (It inspects JavaScript and CSS as well as HTML/XML).

This article demonstrates the power of the Inspector by asking you to manipulate a link on that very page by changing its href to one of your own choosing. It occurred to me that this could have quite an impact on web applications and those who write them. Whilst developers always have to be conscious of the fact that anything client-side is open to variance, the DOM inspector makes it pure childsplay.

Consider the common scenario of credit card payment gateways. Basic gateway accounts usually function by the vending site posting a form to a script at the gateway telling it how much to charge in the transaction. The value is usually kept in a hidden field in the standard HTML form. It doesn’t take a genius to realize that a local copy of the page can be saved and edited to hold a different transaction value and then posted to the gateway. However, this is usually accounted for by maintaining application sessions and the gateway only accepting posts from a recognized referrer. If you save a local copy of the page the referrer HTTP header shows the page is not part of the vendor’s site and the gateway rejects the post.

Even this isn’t perfect, as it’s not too hard to spoof HTTP headers. It does, however, prevent opportunist theft to a reasonable extent.
Consider the fact that with a powerful tool like the Mozilla DOM Inspector you can change the value of that hidden field with just a few clicks and still have it pass the referrer check performed by the gateway. So easy that any kid can do it. Ouch.

It may sound grave, but this case isn’t too serious. No one who is concerned with ecommerce security to any valid extent relies on hidden fields in HTML forms. They may be used as a convenience but nothing more. All the calculations are backed up by secure server-side processing and ratification. It’s easy to secure a known point of weakness.

The real concern is with day to day web applications that pass data and meta-data around and collect user input from forms. If the page can be messed with by any average user whilst still maintaining an application session and any referrer or other checks, how is a web application supposed to cope with that? Building in that level of validation and contingency routines is a mammoth task likely to render many web apps uneconomical.

Whatever the risks, it’s certainly not the fault of the excellent DOM Inspector, but just the intrinsic nature of the web. The risk has always been there. I think the difference now is that as a web application developer I am forced to consider the risk and not simply excuse it as improbable.

What do you think?

- Drew McLellan

Comments

  1. § Mike: I’m finding that the balance between just completing a project and allowing for both the idiot user and the attacker seems to be getting harder. As a ’good programmer’ you want to add for example validation routines in your code to stop the rogues or idiots bombing your database server but when you’ve got a project manager on your back saying things like ”does it actually stop the application from working NOW?” you find yourself under pressure to just deliver. They move on and you end up with some irate support desk person on your case as to why the system keeps crashing.
    Another thing that adds to the pot is new technologies like the .NET initiative. People are still programming in main frame languages because they’ve been around for so long and the development processes are so well documented that its a stable environment. Its the same with web technology... I’m reluctant to do loads of .NET stuff because I know the combination of some good stored procedues, a debugged COM object, wrapped in a small chuck of VBScript works! Yes there are flaws in those technologies but they are often documented and avoidable which makes for happy clients.

Photographs

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Follow me

Recent Links

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

I made

Perch - a really little cms

About Drew McLellan

Photo of Drew McLellan

Drew McLellan (@drewm) has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Cadburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.