Comment On Solution Injecting

The Entity Manager will present all business entities in a common format, the Big-5 consultant raved, allowing any application within the enterprise to access the CRM system. That, and the bargain-basement rate of £1000/developer/day, made the Entity Manager-based CRM system an install sell to management. A year and a few million pounds later, Mike Barker's company was the proud owner of a somewhat-functioning, fairly buggy CRM system. [expand full text]
« PrevPage 1 | Page 2Next »

Re: Solution Injecting

2006-01-30 14:09 • by God
XML blows.





Re: Solution Injecting

2006-01-30 14:09 • by ammoQ
Alex Papadimoulis:

The Entity Manager will present all business entities in a common format, the Big-5 consultant raved, allowing any application within the enterprise to access the CRM system.
That, and the bargain-basement rate of £1000/developer/day, made the
Entity Manager-based CRM system an install sell to management. A year
and a few million pounds later, Mike Barker's company was the proud owner of a somewhat-functioning, fairly buggy CRM system.

But none of this really impacted Mike; his group had nothing to
do with the CRM system. That is, until his system was required to
interface with the CRM. Fortunately, working with the Entity Manager
wasn't too bad. It was simply XML-in, XML-out ...


In order to retrieve an EntitySet, you will need to create an
EntityQuery and pass it to the EntityManager. An EntityQuery can
request any number of different Entities to retrieve and will return
zero or more of each type requested based on the parameters. The
EntityQuery must be in the following format:

<EntityQuery>

<Entity Name="{ENTITY_NAME}">
<Fields>
<Field Name="{FIELD_NAME}" Value="{FIELD_VALUE}" />
<!-- ... More Fields ... -->
Fields>
Entity>
<!-- ... More Entities ... -->
EntityQuery>

But as he read further in the Entity Manager documentation, Mike learned the CRM was a bit more WTF than he thought ...


To query a date field over a range, the value of the query field must be exactly
"{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}".
For example, to retreive all ClientContacts from the month of April,
2003, simply use the following query:

<EntityQuery>

<Entity Name="ClientContact">
<Fields>
<Field
Name="ContactDate"
Value="2003-04-01' OR ContactDate BETWEEN '2003-04-01' AND '2003-04-30"
/>
Fields>
Entity>
EntityQuery>




Any chance this was designed by the same creators like the WMF file format?

Re: Solution Injecting

2006-01-30 14:12 • by John Bigboote
58320 in reply to 58319
public class DropTableCommand : EntityQuery

{

    //TODO: implement

}

{COMMENT_SUBJECT}

2006-01-30 14:12 • by Bob
{COMMENT_TEXT}

Re: Solution Injecting

2006-01-30 14:15 • by DiamondDave
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....



what's the reason for this madness?







Re: Solution Injecting

2006-01-30 14:16 • by YAYitsAndrew
58323 in reply to 58322
xml!

run!

Re: Solution Injecting

2006-01-30 14:19 • by H23
ahh.... xml-abuse!



Enjoy. You'll be seeing crap like this until you retire.



Re: Solution Injecting

2006-01-30 14:20 • by e.thermal
58325 in reply to 58322

DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....

what's the reason for this madness?




Cause they are taking the input and building a SQL statement, so the first 'date' welds well with 'WHERE DATE =' + passed in value.  and then the 'OR Fieldname BETWEEN Then and Now'  does the real work.  Basically they are teaching their users to do SQL injection attacks against their own system.


Good WTF, nice and subtle as a Tuba.

Re: Solution Injecting

2006-01-30 14:21 • by jsumners
Awesome! An XML SQL client. Why didn't anyone think of this before?

xml is scary

2006-01-30 14:22 • by John DeHope 3
58328 in reply to 58324
Whenever anybody says how great XML is, I just remind myself that XML is just a text file format. So if you take out "XML" and replace it with "text files" it sounds much less exciting and revolutionary.

Re: Solution Injecting

2006-01-30 14:22 • by John Bigboote
58329 in reply to 58322
DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....



what's the reason for this madness?










My guess is that it's distressingly simple. The badass query engine is
nothing more than a SQL concatenator. It's designed to append elements
to the WHERE clause by field. The sub-WTFery comes about because the
concatenator was designed to concatenate " where " + fieldNameParam + "
= " + valueParam; that is, searches by value, not range.



The {START_DATE} at the beginning is designed to ensure there's no SQL
error, otherwise you'd have something like " WHERE create_date =
BETWEEN '1/4/2005' AND '1/7/2005' ". This is what tips the gaff and
indicates that the Emperor is nekkid.

Re: Solution Injecting

2006-01-30 14:23 • by John Bigboote
58330 in reply to 58329
Me slow.

Re: Solution Injecting

2006-01-30 14:24 • by ammoQ
58331 in reply to 58322
DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....



what's the reason for this madness?






Because they didn't really implemented a range search; it's done by SQL injection.



Put simply they have code like that:



String sqlstmt = "select * from "+entityName+" where "+fieldname+"='"+value+"'";

resultset = stmt.execute(sqlstmt);


Normally, you give it "customer", "id" and "123", and it does


select * from customer where id='123'



With that special style, you give it "customer", "id" and "123' or id between '123' and '456"; it results in



select * from customer where id='123' or id between '123' and '456'


This style of programming is not only ugly, it allows for various attacks by evil users.


Re: Solution Injecting

2006-01-30 14:24 • by ChiefCrazyTalk
58332 in reply to 58322

DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....

what's the reason for this madness?




 


 


I ran into this situation  before myself - the problem is with the database and, if you specify a query > a certain date without specifying a time (i.e. is the comparison vs. the beginning of the day, or the end of the day?).  Looks like this was just a hack work around.  A better solution IMO  is to have the code add a time of 0:00:00 (or something similar) to the date so it is no longer ambiguous.

Re: Solution Injecting

2006-01-30 14:24 • by Jeff S
58333 in reply to 58322
DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....



what's the reason for this madness?










My guess:



It creates dynamic sql strings based on the XML params passed in, but
the XML format is so strict and poorly implemented that simple things
like selecting a range of dates is not possible (since the format of Field Name/Value doesn't allow for ranges or anything fancier than a Field=Value criteria).

The hard-coded sql is probably generated like this:

"Where Date = ' " + Value + "'"

So, essentially, this system *requires* performing Sql-injection to pull out the data needed.  And this is apparently the standard way to query the data, documented and everything!

Re: Solution Injecting

2006-01-30 14:24 • by limelight
58334 in reply to 58322

DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....

what's the reason for this madness?




I'm guessing that it constructs a SQL statement based on the field and value by simply saying:


   where {field_name} = {value}


thus putting "between {start_date} and {end_date}" will result in:


   where {field_name} = between {start_date} and {end_date}


which obviously will not work. The proposed solution produces:


   where {field_name} = {start_date} or {field_name} between {start_date} and {end_date}

Re: Solution Injecting

2006-01-30 14:24 • by ammoQ
58335 in reply to 58330
John Bigboote:
Me slow.


me slower

Re: xml is scary

2006-01-30 14:26 • by Xargon
58336 in reply to 58328
Anonymous:
Whenever anybody says how great XML is, I just remind myself that XML is just a text file format. So if you take out "XML" and replace it with "text files" it sounds much less exciting and revolutionary.

Or you could insist on using the proper acronym and calling it "EML".  EML doesn't sound as interesting as XML; maybe then it will lose some appeal...

Re: Solution Injecting

2006-01-30 14:28 • by DiamondDave
58337 in reply to 58335
ammoQ:
John Bigboote:
Me slow.


me slower




me slow too....

Re: Solution Injecting

2006-01-30 14:29 • by merreborn
58338 in reply to 58322
DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....



what's the reason for this madness?




That's basically a SQL WHERE clause.  Which is the WTF:  they're letting the user write raw SQL in the xml.  They could probably do something like:


'{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}' UNION SELECT password FROM users WHERE username = root; TRUNCATE TABLE sensitive_application_table;

Re: Solution Injecting

2006-01-30 14:40 • by DiamondDave
58339 in reply to 58338
merreborn:
DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....



what's the reason for this madness?




That's
basically a SQL WHERE clause.  Which is the WTF:  they're
letting the user write raw SQL in the xml.  They could probably do
something like:


'{START_DATE}' OR {FIELD_NAME} BETWEEN
'{START_DATE}' AND '{END_DATE}' UNION SELECT password FROM users WHERE
username = root; TRUNCATE TABLE sensitive_application_table;




Ah... it all makes sense now.  Apparently adhering to basic security rules wasn't a requirement for the EntityMisManager

Re: Solution Injecting

2006-01-30 14:45 • by Mark
Is it me or is the real WTF the '£1000/developer/day'?



I could quite happily sustain myself (and my degree) on about £5000 a
year. Just let me work hacking some ex-ML monster together for a week
and I'll be sorted!



Where do I sign?

Re: Solution Injecting

2006-01-30 14:46 • by cconroy
Is that XMSQL or SQXML?  I can never tell the difference.  Should've use JavaVBScript instead.

Re: Solution Injecting

2006-01-30 14:49 • by sammybaby

I realize that the deeper significance of this snippet of code is that there are likely several million SQL injection attacks just waiting to swarm over this piece of software, that it's probably representative of even greater horrors lurking just beneath the surface, etc, etc.


But there's a part of me that can't help but think, "You know, this entire system was probably designed due to some know-nothing executive's decision that absolutely every last thing in the CRM be represented as XML, even though he has no idea what XML is or why it might be useful."  And then I think that he was probably perfectly happy with this result, because he has no idea why it's bad.  And then I think, some people get the code they deserve. And I'm happy again.

Re: Solution Injecting

2006-01-30 14:55 • by ptomblin
58345 in reply to 58341
Anonymous:
Is it me or is the real WTF the '£1000/developer/day'?



What the conslutant charges the client and what the conslutant pays his developers are two entirely different things.  When I was young and niave and not too long out of school, I was making $36,000 a year.  My employer was charging me out to clients at $1000/day.   Quick, work out the profit margin on *that* little transaction.

Re: Solution Injecting

2006-01-30 14:56 • by Randolpho
58346 in reply to 58338

merreborn:
DiamondDave:
...To query a date field over a range, the value of the query field must be exactly "{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}"....

what's the reason for this madness?



That's basically a SQL WHERE clause.  Which is the WTF:  they're letting the user write raw SQL in the xml.  They could probably do something like:


'{START_DATE}' OR {FIELD_NAME} BETWEEN '{START_DATE}' AND '{END_DATE}' UNION SELECT password FROM users WHERE username = root; TRUNCATE TABLE sensitive_application_table;


I concur.


Good WTF!

Re: Solution Injecting

2006-01-30 15:00 • by mjan
58347 in reply to 58343
cconroy:
Is that XMSQL or SQXML?  I can never tell the difference.  Should've use JavaVBScript instead.



It's obviously SEXML, the database penetration and SQL injection tool for discriminating idiots everywhere!

Re: Solution Injecting

2006-01-30 15:02 • by BtM

You know "The Scream", that famous Heironymous Bosch painting that appears everywhere (including the cover of "The Unix Hater's Handbook")? 


I'm doing that right now.


I understand how crap like this happens.  You need to get a solution working, and doing it the Right Way would take more time/money/talent than you have available, so you throw up something simple and dirty and pray no one notices.


Even so, someone should get sued over that.


"Hello, I'm a security hole.  Please take advantage of me."


 

Re: Solution Injecting

2006-01-30 15:10 • by Stern
58350 in reply to 58348
BtM:
You know "The Scream", that famous Heironymous Bosch painting
Bosch? Now that's a WTF for you.

Re: Solution Injecting

2006-01-30 15:15 • by Onan
58351 in reply to 58348
BtM:

You know "The Scream", that famous Heironymous Bosch painting that appears everywhere (including the cover of "The Unix Hater's Handbook")? 


I'm doing that right now.


I understand how crap like this happens.  You need to get a solution working, and doing it the Right Way would take more time/money/talent than you have available, so you throw up something simple and dirty and pray no one notices.


Even so, someone should get sued over that.


"Hello, I'm a security hole.  Please take advantage of me."


 




s/Heironymous Bosch/Edvard Munch/

Re: Solution Injecting

2006-01-30 15:21 • by Runtime Error
58352 in reply to 58350
Anonymous:
BtM:
You know "The Scream", that famous Heironymous Bosch painting
Bosch? Now that's a WTF for you.




Yea, he said the wrong artist.  But to be honest, Bosch would be
appropriate here too.  "... and this paiting shows the developers
being cast into XML hell, note the demons injecting them with SQL
queries shapped like spears"





Re: Solution Injecting

2006-01-30 15:22 • by ammoQ
58353 in reply to 58348
BtM:

You know "The Scream", that famous Heironymous
Bosch painting that appears everywhere (including the cover of
"The Unix Hater's Handbook")? 


I'm doing that right now.


I understand how crap like this happens.  You need to
get a solution working, and doing it the Right Way would take more
time/money/talent than you have available, so you throw up something
simple and dirty and pray no one notices.


Even so, someone should get sued over that.


"Hello, I'm a security hole.  Please take advantage of me."






The Real WTF (tm) is not that they have this kind of vulnerability in
their system. This kind of bug is unfortunately often made. The Real
WTF (tm) is that they are documenting it as a feature.
Should they ever fix it, they will have to include a workaround for
exactly this kind of search string, so to keep it compatible with
existing "queries".

Re: Solution Injecting

2006-01-30 15:30 • by John Bigboote
58354 in reply to 58352
Anonymous:
Anonymous:
BtM:
You
know "The Scream", that famous Heironymous Bosch painting
Bosch? Now that's a WTF for you.




Yea, he said the wrong artist.  But to be honest, Bosch would be
appropriate here too.  "... and this paiting shows the developers
being cast into XML hell, note the demons injecting them with SQL
queries shapped like spears"








SELECT * FROM artist aWHERE a.artist_name IN ('Edvard Munsch', 'Hieronymous Bosch')

OR a.genre_id = 'AAAGH_IT_BURNS_IT_BURNS'

Re: Solution Injecting

2006-01-30 15:34 • by Gene Wirchenko
58355 in reply to 58345
ptomblin:
Anonymous:
Is it me or is the real WTF the '£1000/developer/day'?


What the conslutant charges the client and what the conslutant pays his developers are two entirely different things.  When I was young and niave and not too long out of school, I was making $36,000 a year.  My employer was charging me out to clients at $1000/day.   Quick, work out the profit margin on *that* little transaction.


We need more data.  What happened on days when you did not do any work for a clients?  What other expenses were there?  Sales/marketing, admin, office space, etc.?

Sincerely,

Gene Wirchenko

Re: Solution Injecting

2006-01-30 15:37 • by R.Flowers
58356 in reply to 58345

ptomblin:
Anonymous:
Is it me or is the real WTF the '£1000/developer/day'?


What the conslutant charges the client and what the conslutant pays his developers are two entirely different things.  When I was young and niave and not too long out of school, I was making $36,000 a year.  My employer was charging me out to clients at $1000/day.   Quick, work out the profit margin on *that* little transaction.


At the end of the day, did he come to you and say "Where my money, BEE-YATCH!? You holdin' out on me?"[;)]

Re: Solution Injecting

2006-01-30 15:37 • by marvin_rabbit
58357 in reply to 58352
Anonymous:


Yea, he said the wrong artist.  But to be honest, Bosch would be
appropriate here too.  "... and this paiting shows the developers
being cast into XML hell, note the demons injecting them with SQL
queries shapped like spears"



<While trying to get the rest of the milk out of my nose.>
Hightlight, Copy, Paste to favorite quotes.
File / Save.

Re: Solution Injecting

2006-01-30 15:39 • by Runtime Error
58359 in reply to 58355
I have changed my mind, this isn't a WTF at all.  It just a
standard implementation using the well known SQL Injection design
pattern.

Re: Solution Injecting

2006-01-30 15:42 • by Tom
58360 in reply to 58324

I don't get the "xml-abuse" comment - there's nothing in this WTF that is dependent on, or even encouraged by, XML.   If I owned this code, knew nothing about SQL injection attacks, and my boss told me "no more XML!", I could reimplement it using a different text format, or COM, or .NET, and leave the security hole wide open.


BTW, if you had to maintain the API and fix the security hole, what would you do?   I can imagine trying to do it by just changing the backend code to submit the dangerous query under a user account with really restricted permissions.

Re: Solution Injecting

2006-01-30 15:44 • by OneFactor
58361 in reply to 58345

ptomblin:
Anonymous:
Is it me or is the real WTF the '£1000/developer/day'?


What the conslutant charges the client and what the conslutant pays his developers are two entirely different things.  When I was young and niave and not too long out of school, I was making $36,000 a year.  My employer was charging me out to clients at $1000/day.   Quick, work out the profit margin on *that* little transaction.


Reminds me of when my company sent me to the states billing at $125 US / hour while still paying my regular salary in Canadian dollars. And then when you add the overtime hours that get billed to the client without any effect on my compensation, it must have worked out quite well. The lead developer put in 80 hours a week for two weeks straight billing at $125 / hour. The company bought him a T-shirt to recognize his hard work. The company also told us that expensing shampoo and soap was unethical.

Re: Solution Injecting

2006-01-30 15:50 • by kipthegreat
58363 in reply to 58356
R.Flowers:

ptomblin:
Anonymous:
Is it me or is the real WTF the '£1000/developer/day'?


What the conslutant charges the client and what the conslutant pays his developers are two entirely different things.  When I was young and niave and not too long out of school, I was making $36,000 a year.  My employer was charging me out to clients at $1000/day.   Quick, work out the profit margin on *that* little transaction.


At the end of the day, did he come to you and say "Where my money, BEE-YATCH!? You holdin' out on me?"[;)]



If he did I would have shot him in both knees and told him to get the money on Friday.

Re: Solution Injecting

2006-01-30 15:56 • by Maurits
The correct way to deal with a SQL Injection vulnerability is to FIX IT, not write it up as an interface!!!

Re: Solution Injecting

2006-01-30 16:04 • by Dan

Value="1 ; shutdown --"

Re: Solution Injecting

2006-01-30 16:24 • by Gene Wirchenko
58368 in reply to 58360
Anonymous:
I don't get the "xml-abuse" comment - there's nothing in this WTF that is dependent on, or even encouraged by, XML.   If I owned this code, knew nothing about SQL injection attacks, and my boss told me "no more XML!", I could reimplement it using a different text format, or COM, or .NET, and leave the security hole wide open.


True enough.  The WTF is cutting corners on a conversion between two data formats.

BTW, if you had to maintain the API and fix the security hole, what would you do?   I can imagine trying to do it by just changing the backend code to submit the dangerous query under a user account with really restricted permissions.


1) I would parse the query data and make very sure that anything submitted that way did fit the format.  If it did not, I would bounce it with an error message.  The spec already says that the data must follow the format exactly.

It is even possible that the spec is enforced now.  If so, this is not so much a WTF as lazy design.  I doubt this though as since the designer/coder got lazy one way, he may well have gotten lazy another way and not written code to enforce the spec.

2) Then, I would design another way of specifying date ranges.  The format would be friendlier, not requiring SQL knowledge.  I would make sure to parse everything fully.

3) Lastly, I would deprecate the first usage.  If I could do it, I would obsolete it.

Sincerely,

Gene Wirchenko

Re: Solution Injecting

2006-01-30 16:27 • by ptomblin
58369 in reply to 58361
OneFactor:

ptomblin:

What the conslutant charges the client and what the conslutant pays his developers are two entirely different things.  When I was young and niave and not too long out of school, I was making $36,000 a year.  My employer was charging me out to clients at $1000/day.   Quick, work out the profit margin on *that* little transaction.

Reminds me of when my company sent me to the states billing at $125 US / hour while still paying my regular salary in Canadian dollars. And then when you add the overtime hours that get billed to the client without any effect on my compensation, it must have worked out quite well. The lead developer put in 80 hours a week for two weeks straight billing at $125 / hour. The company bought him a T-shirt to recognize his hard work. The company also told us that expensing shampoo and soap was unethical.



It was very similar for me.  The other WTF was that I was staying at a very expensive hotel in Madrid, where the hotel laundry charged 2500 Pesatas (about $2.50) to wash my underwear, but I could have bought new underwear for 2000 Pesatas ($2)/pr just down the street.  But the company wouldn't allow me to expense buying new underwear, even though it was a net savings for them.  So I came home with a lot of old underwear and socks with laundry tags on them, and a huge expense claim.


Re: Solution Injecting

2006-01-30 16:38 • by lucky luke
58370 in reply to 58366
Anonymous:

Value="1 ; shutdown --"



ahh the sweet mayhem to be had by being allowed to inject my own sql statements through a hole in the API...

Value="1; drop database if exists main"

just cause I don't like people using the "main" database

Re: Solution Injecting

2006-01-30 16:45 • by mrsticks1982
58371 in reply to 58343

cconroy:
Is that XMSQL or SQXML?  I can never tell the difference.  Should've use JavaVBScript instead.


 


They be richer now, new invention ... go and buy up the domain names so they will have to pay you

Re: Solution Injecting

2006-01-30 16:49 • by John Bigboote
58372 in reply to 58369
ptomblin:


It was very similar for me.  The
other WTF was that I was staying at a very expensive hotel in Madrid,
where the hotel laundry charged 2500 Pesatas (about $2.50) to wash my
underwear, but I could have bought new underwear for 2000 Pesatas
($2)/pr just down the street.






An enterprising businessman would buy both the laundry and the
underwear store, and then hire people to break into your hotel room and
crap in your underwear.

Re: Solution Injecting

2006-01-30 16:49 • by maldrich
Folks seem to miss the subtle logic at work here:

1. Security flaws are worse because so many people are blissfully unaware of them.

2. Therefore: if more people knew about them, more people would know to avoid them.

3. Ergo: we should teach all users about SQL injection.

4. What better way to spread the word than a system that _operates by_ SQL injection. No-one can claim ignorance now!

Brilliant!

Re: Solution Injecting

2006-01-30 16:53 • by R.Flowers
58375 in reply to 58372

John Bigboote:
ptomblin:


It was very similar for me.  The other WTF was that I was staying at a very expensive hotel in Madrid, where the hotel laundry charged 2500 Pesatas (about $2.50) to wash my underwear, but I could have bought new underwear for 2000 Pesatas ($2)/pr just down the street.




An enterprising businessman would buy both the laundry and the underwear store, and then hire people to break into your hotel room and crap in your underwear.


Good plan, but I think I'll save money and do the crapping myself.

Re: Solution Injecting

2006-01-30 16:56 • by BtM
58376 in reply to 58350

Anonymous:
BtM:
You know "The Scream", that famous Heironymous Bosch painting
Bosch? Now that's a WTF for you.


This episode of "Geek Bloopers and Practical Jokes" has been brought to you by an excess of caffeine, sugar, and UML.  Tune in next week when we see the geek blow a wedding toast by getting the bride's name wrong. 

« PrevPage 1 | Page 2Next »

Add Comment