Comment On One-and-a-Half-Tiered Application Design

There are several types of bad code; there's lazy code, frantic code, unaware-of-a-better-way code, and aware-of-a-better-way-but-too-apathetic-to-do-it code, to name a few. Then there're amalgamations of different types of bad code. [expand full text]
« PrevPage 1 | Page 2Next »

Re: One-and-a-Half-Tiered Application Design

2007-05-29 11:53 • by CorporateFelon
I really wanted to believe that this monumental failure in security couldn't have been done by accident. I am actually at a loss for words.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 11:53 • by SSilver2k2 (unregistered)
first post?

wow. Ive seen people coding open ended sql injections like this (i even did it on a few of my own first lesson websites), but to not know that you can view javascript from a browser, that's scary

Re: One-and-a-Half-Tiered Application Design

2007-05-29 12:00 • by Cyrus (unregistered)
Showing this to a DBA got a long silence, a gasp, then a long groan, pretty cool to watch.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 12:12 • by Thief^
Could we stop unregistered users posting in the first 3 comments? Would cut out the majority of the "fist!" posts.

And back on topic: Ugh, that code makes my skin crawl.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 12:23 • by ForcedSterilizationsForAll (unregistered)
Here's an idea for those "first" posts, how about their IP gets blocked. :)

And that code is just sad. Maybe it was a contractor that did it. :)

Re: One-and-a-Half-Tiered Application Design

2007-05-29 12:24 • by Ares (unregistered)
Wait wait wait... you view javascript code from the browser? Next thing you are going to tell me is that you can do the same thing with HTML.

Nice try guys, but April Fools was last month.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 12:54 • by Ctrl_Alt_Kaboom (unregistered)
Someone should be beaten with a two by four for doing something *that* stupid.

What if this had been discovered by someone with malicious intent?
*looks at self*
Muhahahaaa!

Captcha: craaazy. how appropriate.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 12:56 • by Zemyla
139097 in reply to 139092
Ares:
Wait wait wait... you view javascript code from the browser? Next thing you are going to tell me is that you can do the same thing with HTML.

Nice try guys, but April Fools was last month.

It's true.

And you know all those images on your web site? Someone can save those to their own computer as well. Even if you put in an anti-right click script.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 12:58 • by Badger (unregistered)
The "Real WTF" is surely that he complained to the company and they realised he knew what he was talking about and put him through to someone who could do something about it.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 13:14 • by J (unregistered)
Not long ago, I was given the task of rewriting an ASP (VBscript) site created in 2003 that had been the victim of SQL injection attacks. The pages were passing querystrings like "user.asp?action=edit&id=1234" and "user.asp?action=add&username=foo". That was the worst SQL injection invitation I'd ever seen until today.

Just months before I was given this task, they were giving me a hard time about how my insistence on using things like type declarations and stored procedures was slowing down development time.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 13:15 • by diaphanein (unregistered)
139101 in reply to 139097
Zemyla:
Ares:
Wait wait wait... you view javascript code from the browser? Next thing you are going to tell me is that you can do the same thing with HTML.

Nice try guys, but April Fools was last month.

It's true.

And you know all those images on your web site? Someone can save those to their own computer as well. Even if you put in an anti-right click script.


Those always piss me off. Its kind of fun to disable script, reload, save the file and then email the photo to the site's admins with "Your kung fu is weak."

Re: One-and-a-Half-Tiered Application Design

2007-05-29 13:24 • by dolo54 (unregistered)
139102 in reply to 139097
Ares:
And you know all those images on your web site? Someone can save those to their own computer as well. Even if you put in an anti-right click script.


Nothing's worse than a client who insists that you make their site un-stealable. I've had "I don't want anybody lifting my copy. Put all the text in images so they can't copy and paste it." "But they could still ocr it, or have a secretary copy it." "Well that makes it harder, so do it anyhow."

Btw - fortunately due to the current market I don't have to take jobs like that anymore. Whew, glad 2000 came and went.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 13:30 • by Ben4jammin (unregistered)
Not long ago, we were in the process of implementing some HR software. Part of this was on a front end server that acted as a public web server (connecting to confidential HR data in the back end database mind you). Long story short, they were having problems and decided the best way to fix it would be to put the IUSR_Servername (Internet guest account for anonymous access to IIS) in the local admin group on the web server. In a related story, our security guy now has a facial tick. Thankfully, we decided against using their software.
Moral of the story: Never assume someone wouldn't do something THAT stupid. Whatever THAT may be (SQL injection, escalated rights, etc)

Re: One-and-a-Half-Tiered Application Design

2007-05-29 13:51 • by SpiritOfGrandeur
IBM's manage now does this... or at lest and older version did. I haven't looked into the most recent one.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 13:53 • by BiggBru
Maybe they should just give users direct access to the database. "If you are placing an order, you must fill out the following tables with your information..."

And another step is taken towards 100% user-modifiable content. This is the future, folks.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:00 • by Aaron (unregistered)
Moving JavaScript to a .NET back-end? That's so Web 1.0! I'll bet that delivery system has almost no Ajax at all now.

The "status" vs. "theStatus" differentiation is also a nice touch. I've seen people try to differentiate between classes and locals this way ("Session theSession = ..."), and that's bad enough, but doing it with two locals takes the cake. That should be a joy for anybody to maintain.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:05 • by comejoyo (unregistered)
case "Unconfirmed":
dateSQL= ""
var modeSQL = ""
modeSQL = " AND (J.JBCompanyID=31337) "
status = " GlobalJobStatusView AS J WHERE J.JBCollectDate=''
" + theDate + "'' AND J.JBConfirmed=''No''" +
modeSQL + " ORDER BY Convert(int, J.MIJobID)"
break;
case "Complete":
dateSQL= ""
var modeSQL = ""
modeSQL = " AND (J.JBCompanyID=31337) "
status = " GlobalJobStatusView AS J WHERE J.JBCollectDate=''
" + theDate + "'' AND J.MIStatusCode=5" +
modeSQL + " ORDER BY Convert(int, J.MIJobID)"
break;
case "Unconformed":
dateSQL= ""
var modeSQL = ""
modeSQL = " AND (J.JBCompanyID=31337) "
status = " GlobalJobStatusView AS J WHERE J.JBCollectDate=''
" + theDate + "'' AND (J.MIConformance IS NOT NULL
AND J.MIConformance<>'''') " + modeSQL + "
ORDER BY Convert(int, J.MIJobID)"
break;



...... what the suck???? sucking culo

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:06 • by evanm
Really, I gotta say that, Alex, this is one of your lesser editing jobs. Really, the entire code section could have been taken out, and replaced with the phrase "And Moshe discovered that the SQL queries for the site were created using client-side javascript and were wholly vulnerable to SQL injection attacks".

A lot of code reading there for no purpose.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:19 • by shakin
This sort of reminds me of when I first learned how to create ASP pages. I used an MS Access database and promptly placed it sans-password onto the server in the root web directory. Then in my ASP database include file I wrote a nice HTML comment: <!-- get database from c:\www_root\db.mdb -->

There, now everyone who views the HTML source will know exactly how to download my open database. Perfect.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:20 • by john doe (unregistered)
139121 in reply to 139118
evanm:
Really, I gotta say that, Alex, this is one of your lesser editing jobs. Really, the entire code section could have been taken out, and replaced with the phrase "And Moshe discovered that the SQL queries for the site were created using client-side javascript and were wholly vulnerable to SQL injection attacks".

A lot of code reading there for no purpose.


You're not acutally reading all that code, right?
To me, being confronted with this code greatly enhanced the "shock and awe" effect (i.e. my jaw dropped to the ground completely, instead of halfway only).

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:21 • by Leo (unregistered)
139122 in reply to 139118
evanm:
Really, I gotta say that, Alex, this is one of your lesser editing jobs. Really, the entire code section could have been taken out, and replaced with the phrase "And Moshe discovered that the SQL queries for the site were created using client-side javascript and were wholly vulnerable to SQL injection attacks".

A lot of code reading there for no purpose.


And where's the shock and awe in that ? You can't get a moan from a DBA with a text line...

Seriously, I find most of the stories fun, even if I can't read the code. I'm an engineer, most my work is in C or assembly, so SQL/javascript/<put-your-new-favorite-fancy-tecnology-here> is forein to me.

CAPTCHA: alarm - That should ring a bell, eh ?

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:47 • by bobbo (unregistered)
139126 in reply to 139120
shakin:
This sort of reminds me of when I first learned how to create ASP pages. I used an MS Access database and promptly placed it sans-password onto the server in the root web directory. Then in my ASP database include file I wrote a nice HTML comment: <!-- get database from c:\www_root\db.mdb -->

There, now everyone who views the HTML source will know exactly how to download my open database. Perfect.


Is your CV online? We're hiring at the moment.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 14:57 • by SuperousOxide
139128 in reply to 139097
Zemyla:

And you know all those images on your web site? Someone can save those to their own computer as well. Even if you put in an anti-right click script.


It's worse than that. Most browsers save that image to disk without even asking the user. Someone needs to do something about all these copyright violating "caches"

Re: One-and-a-Half-Tiered Application Design

2007-05-29 15:00 • by nobody (unregistered)
139129 in reply to 139097
Zemyla:
Ares:
Wait wait wait... you view javascript code from the browser? Next thing you are going to tell me is that you can do the same thing with HTML.

Nice try guys, but April Fools was last month.

It's true.

And you know all those images on your web site? Someone can save those to their own computer as well. Even if you put in an anti-right click script.

I like how IMDB does it. They make the real image the background and put a transparent image over it, so if you right-click and save you get a blank image.
View source and a short effort finds the real image URL; cut and paste into a browser, and save the picture.
Only worth it for the hottest women, though.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 15:20 • by Feyr (unregistered)
i'm not even surprised.

one of the developper here was surprised you could see the password in the html source because he had set the field type to "password", that should have prevented it in his mind :\

Re: One-and-a-Half-Tiered Application Design

2007-05-29 15:32 • by B (unregistered)
139135 in reply to 139129
nobody:
Zemyla:
Ares:
Wait wait wait... you view javascript code from the browser? Next thing you are going to tell me is that you can do the same thing with HTML.

Nice try guys, but April Fools was last month.

It's true.

And you know all those images on your web site? Someone can save those to their own computer as well. Even if you put in an anti-right click script.

I like how IMDB does it. They make the real image the background and put a transparent image over it, so if you right-click and save you get a blank image.
View source and a short effort finds the real image URL; cut and paste into a browser, and save the picture.
Only worth it for the hottest women, though.


Hmm... where do they do that? Will it work if one uses Firefox+Adblock and block off the upper transparent image?

Re: One-and-a-Half-Tiered Application Design

2007-05-29 15:38 • by Random832
139136 in reply to 139091
Here's an idea for those "first" posts, how about their IP gets blocked. :)

The problem there is false positives. Fark.com turns any occurence of "First post" to "Boobies" and knocks the timestamp to 24 hours in the future, and inevitably you see the occasional post that would make sense, in context, if the reverse transform is made to it. What you're suggesting is an even more severe negative consequence to something which, on a site where "ss" is converted to "B", will almost certainly be implemented in a "clbuttic" manner.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 15:44 • by James Schend (unregistered)
>> I like how IMDB does it. They make the real image the
>> background and put a transparent image over it, so if you
>> right-click and save you get a blank image.
>> View source and a short effort finds the real image URL;
>> cut and paste into a browser, and save the picture.
>> Only worth it for the hottest women, though.

Every browser but IE has an easy way to get a hold of media embedded in the page without using right-click. In Firefox, it's called "Page Info" in Tools. Click Tools -> Page Info -> Media, and there's all the images laid out neatly for you. As well as any SWF or MP3s or whatever other media the page might have.

In Safari, it's called "Activity" in the Window menu, IIRC.

Point is, disabling the right-click menu, even if it wasn't easily circumvented, only works in IE in the first place.

(The "Real WTF" is how few people seem to know about the Page Info window in Firefox.)

Re: One-and-a-Half-Tiered Application Design

2007-05-29 16:11 • by MaGnA

modeSQL = " AND (J.JBCompanyID=31337) "


Hey this code is in fact 31337!

Re: One-and-a-Half-Tiered Application Design

2007-05-29 16:14 • by henke37
139142 in reply to 139138
To be fair, even Gecko based browsers can have their context menu hijacked, if they allow it.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 16:19 • by theteapot (unregistered)
Anyone heard of a browser detection script?
Disabling right-click can be done in all browsers:
http://hyperdisc.unitec.ac.nz/materials/javascript/top10/disablerightclick.htm
But, it's nice to know that the author of this script doesn't like right-click disabling as well!

But, as far as I know, the major browsers all let you view HTML source, so it's entirely useless, unless you don't know anything about webpages. Oh.

Probably the best way to hide images is to send a link via ajax, and then set it as the background-image. Then it's not in the HTML source, and can't be found easily (like IMDB and flickr). But even then, it can be picked up by Web Developer https://addons.mozilla.org/en-US/firefox/addon/60.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 16:23 • by Andrew (unregistered)
139145 in reply to 139083
SSilver2k2:
first post?

wow. Ive seen people coding open ended sql injections like this (i even did it on a few of my own first lesson websites), but to not know that you can view javascript from a browser, that's scary


Who would write a SQL client in Javascript?!? That developer had to know less than nothing. Anyone around for 5 years knows the joys of Javascript. First, it wasn't mature enough. Then, IE and Netscape fought over setting standards. Now, everyone knows how (and why) to turn Javascript off in the browser.

Also, the SQL strings make it harder to maintain the application. They waste bandwidth when only a few form values are really needed. Worse, every browser-cached Javascript page has to be changed when the SQL rules do, which the server can't control.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 16:44 • by SuperousOxide
139154 in reply to 139143
theteapot:
Anyone heard of a browser detection script?
Disabling right-click can be done in all browsers:
http://hyperdisc.unitec.ac.nz/materials/javascript/top10/disablerightclick.htm
But, it's nice to know that the author of this script doesn't like right-click disabling as well!


Don't believe every thing that you read. It works in Firefox and IE, but Opera will cheerfully pop up the context menu, even if you change your javascript settings to let javascript see the right click.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 16:48 • by rjnewton
139157 in reply to 139091
ForcedSterilizationsForAll:
Here's an idea for those "first" posts, how about their IP gets blocked. :)

And that code is just sad. Maybe it was a contractor that did it. :)


Not a bright idea. For one thing, many people move around to different publicly-accessible wireless networks, so blocking a particular IP would not block the poster for long. Secondly, many ISPs issue connections out of a shared IP pool, so blocking would block others on the same system, while blocking the offender only by chance.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 16:48 • by serhei (unregistered)
139158 in reply to 139086
> Showing this to a DBA got a long silence, a gasp, then a long groan, > pretty cool to watch.

They probably committed suicide by holding their breath.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 17:05 • by nixen (unregistered)
139160 in reply to 139145
Andrew:

Now, everyone knows how (and why) to turn Javascript off in the browser.


Oh, please then, enlighten me. 'Cause I sure don't know "why".

Andrew:

Also, the SQL strings make it harder to maintain the application. They waste bandwidth when only a few form values are really needed.


Really sharp point you got there. It might waste an entire 100 bytes! Heretics!!

Andrew:

Worse, every browser-cached Javascript page has to be changed when the SQL rules do, which the server can't control.


Most semi-decent frameworks contain ways of controlling the script tags, and thereby client caches.
Just informing you, since you don't seem to know.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 17:22 • by RON (unregistered)
I am seriously hitting my head really hard right now.


I can't believe that I have to compete with these people for jobs.


Worse yet: Management almost never knows what kind of WTF code these people are writing since they don't know what code does anyways, and they are happy if the devs just say "yes!" and do it, even if it's in a completely retarded way.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 17:55 • by nwbrown
139167 in reply to 139101
diaphanein:
Zemyla:
Ares:
Wait wait wait... you view javascript code from the browser? Next thing you are going to tell me is that you can do the same thing with HTML.

Nice try guys, but April Fools was last month.

It's true.

And you know all those images on your web site? Someone can save those to their own computer as well. Even if you put in an anti-right click script.


Those always piss me off. Its kind of fun to disable script, reload, save the file and then email the photo to the site's admins with "Your kung fu is weak."


Or you could take a screenshot of the page, print it out, put the printout on a wooden table, take a picture with a camera, scan in the picture, and then email it to them!

But yeah, disabling javascript is probably easier. Unfortunately I use the noscript firefox extension, so normally I never know the anti-right click script is even there in the first place.

As for this particular wtf, this is why we need to start insisting on some sort of certification for web developers instead of allowing the 15 year old nephew of the VP of marketing get the job. Its easy enough to learn enough web development to put together what appears to be a functional website, its much harder to make one that actually does work.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 18:54 • by Matthew (unregistered)
139172 in reply to 139101
diaphanein:
Those always piss me off. Its kind of fun to disable script, reload, save the file and then email the photo to the site's admins with "Your kung fu is weak."


I guess I never noticed this little anti-rightclick "trick" because I always just dragged the images I want to my desktop. Doesn't that work on Windows?

captcha: kungfu (no, seriously)

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:06 • by Mr Steve (unregistered)
139176 in reply to 139140
Someone's been playing too much counterstrike ;D

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:09 • by DKO (unregistered)
139178 in reply to 139143
theteapot:
Disabling right-click can be done in all browsers:
http://hyperdisc.unitec.ac.nz/materials/javascript/top10/disablerightclick.htm


Doesn't work on Firefox 2.0.0.3 with dom.event.contextmenu.enabled=false. (at least some) Distros provide Firefox with this set by default.


UPDATE: oh yeah, if I release the button over the page and NOT over the menu option (which is where I would release it, I opened the context menu for that reason after all), it pops up a message box. For a moment I forgot the fact that the Mozilla developers are still retards; you still can take down the browser with an infinite loop of alert().

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:11 • by nwbrown
139179 in reply to 139160
nixen:
Andrew:

Now, everyone knows how (and why) to turn Javascript off in the browser.


Oh, please then, enlighten me. 'Cause I sure don't know "why".


Yeah, you are right. He probably should have written "anyone with half a brain knows how and why to turn off Javascript by default".

nixen:


Andrew:

Also, the SQL strings make it harder to maintain the application. They waste bandwidth when only a few form values are really needed.


Really sharp point you got there. It might waste an entire 100 bytes! Heretics!!


100 bytes times how many millions of requests?

nixen:

Andrew:

Worse, every browser-cached Javascript page has to be changed when the SQL rules do, which the server can't control.


Most semi-decent frameworks contain ways of controlling the script tags, and thereby client caches.
Just informing you, since you don't seem to know.

No, no framework controls client caches. Because no server side code can control the client (ie, the browser). The best they can do is request the browser do something. Whether they abide by that request or not is up to the browser.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:14 • by Daniel Beardsmore
139180 in reply to 139172
Matthew:
I guess I never noticed this little anti-rightclick "trick" because I always just dragged the images I want to my desktop. Doesn't that work on Windows?


It does work, yes.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:27 • by Sigh (unregistered)
Hm, not even ten posts to get the requisite "First post!", "Captcha = who gives a crap", and of course, "the real WTF is that I'm a pompous know-it-all"

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:41 • by Jon (unregistered)
139183 in reply to 139179
nwbrown:
nixen:
Andrew:
Worse, every browser-cached Javascript page has to be changed when the SQL rules do, which the server can't control.
Most semi-decent frameworks contain ways of controlling the script tags, and thereby client caches.
Just informing you, since you don't seem to know.

No, no framework controls client caches. Because no server side code can control the client (ie, the browser). The best they can do is request the browser do something. Whether they abide by that request or not is up to the browser.
Oh no! The Cache-Control header is a lie! :(

But seriously, nixen's idea here is that if you need to update "mylib.js", you instead create a new file, "mylibv2.js" and send back all new pages pointing to the new file. Just because you can't "control" browsers doesn't mean you can't trigger the desired behaviour in the ones that people use.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:42 • by chrismcb
139184 in reply to 139118
evanm:
Really, I gotta say that, Alex, this is one of your lesser editing jobs. Really, the entire code section could have been taken out, and replaced with the phrase "And Moshe discovered that the SQL queries for the site were created using client-side javascript and were wholly vulnerable to SQL injection attacks".

A lot of code reading there for no purpose.


Since when did Alex start spelling his name "J A K E?"

Sure there was probably more code there than needed to get the point across... But it REALLY gets the point across. How are the eyes now? Did the goggles do anything?

Re: One-and-a-Half-Tiered Application Design

2007-05-29 19:51 • by htg (unregistered)
That is just horribly stinky, but sadly I can see how the barely educated and zero common sense programmers you see all too often could think that it was cunning. What happened to security courses, and best practices courses, and architecture courses, etc, at university?

The sad fact is, this just should not be happening, full stop. SQL Injection aside, forming SQL statements is so clearly and obviously not a client-side behaviour that you'd have to be retarded to go down that path. I can understand server side code that has SQL Injection flaws - a brief demonstration and education about prepared statements usually sorts the people out and they never make the mistake again. However I don't think there's any redeeming for someone who forms SQL in client-side Javascript.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 20:42 • by Sir Brialliance
139191 in reply to 139143
theteapot:
Disabling right-click can be done in all browsers:
http://hyperdisc.unitec.ac.nz/materials/javascript/top10/disablerightclick.htm


I think the right-click script war ended when someone discovered
<body oncontextmenu="return false;">

I feel sad for the customers that want it - very sad.

Re: One-and-a-Half-Tiered Application Design

2007-05-29 21:01 • by Kris (unregistered)
function sendLinkVal(theDate,theStatus,MainTitle,PageTitle){
var dateSQL = " AND J.JBDeliveryDate=''" + theDate +
"''"
var status = ""
var newSQLTag =""
var PageTitle = PageTitle
var MainTitle = MainTitle

*bangs head through table*

Re: One-and-a-Half-Tiered Application Design

2007-05-29 22:41 • by icelava
This developer was equally shocked to learn that it was even possible to view a web page's JavaScript code, let alone that his architecture was open to SQL injection attacks from virtually any angle. He took immediate and decisive action; all queries were moved to the .NET backend.

You mean his immediate and decisive action wasn't to quit and flee the country?
« PrevPage 1 | Page 2Next »

Add Comment