The defense that does work is to keep code and data in separate places. Then there is no way to compromise code by playing tricks with data. Garbage-collected languages like Perl and Lisp do this, and as a result are immune from buffer overflow attacks.
What. Am I slow today, or does that make zero sense?
On a slightly related note, Paul Graham's "Hacker News", a reddit-like site for hackers, uses a totally awesome approach to user sessions: every time you visit a page, a closure/continuation is created for every button that needs state (it is lisp, and lisp is all about closures and continuations, didn't you know), which is then run if you click it.
Now and then a garbage collector runs and removes stale closures, also they restart the server when it gets too slow.
Now you would think, that's sort of DoS-prone, those closures being fruitful and multiplying, but surely that only happens with pages shown to logged-in users, so they can ban abusers or something? Well, inspect source http://news.ycombinator.com/submit while not logged in (btw it's down again right now) reveals two of these closures created for every and each page view.
There's nothing stopping you from creating sessions for users who aren't logged in. Photobucket does it for sure.
Except for sanity. Are you sure they do it with server-side sessions, and not with cookies, like every other sane site out there?
I mean, all right, different strokes for different folks, but I would never associate a heavy as shit non-reified persistent activation record of a function with each of several buttons on a page that I show to everyone. That's a fun think to do for your pet rat's homepage, it's "elegant" (in a certain totally divorced from reality kind of way), but that's not how you do things with a public forum dedicated to sucking less at programming, as a community. In my humble opinion.
69
u/the-fritz Mar 11 '13
That's the Lisp and 9/11 bit he's talking about in the beginning: http://www.paulgraham.com/hijack.html