openSUSE Forums > Soapbox » another newbie who forgot to sanitise user input

Go Back   openSUSE Forums > Soapbox
Forums FAQ Members List Search Today's Posts Mark Forums Read


Soapbox Strong opinions about mostly anything (no political or religious content)

Reply
Page 1 of 2 1 2
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 15-Jul-2009, 19:38
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,222
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default another newbie who forgot to sanitise user input

http://imgur.com/QHKXu.png

I hope the programmer has realised now why his participation figures are so low.
Reply With Quote
  #2 (permalink)  
Old 15-Jul-2009, 22:22
caf4926's Avatar
Global Moderator
 
Join Date: Jun 2008
Location: The English Lake District. UK - GMT/BST
Posts: 12,894
caf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputation
Send a message via MSN to caf4926
Default Re: another newbie who forgot to sanitise user input

Moved to a seemingly more appropriate part of the forum
__________________
Box: openSUSE 11.2 | (KDE4.3.3) | M2N4-SLI | AMD 64 X2 5200+ | nVidia 8500GT | 4GB RAM
Lap: openSUSE 11.2 | Celeron 550 | (KDE4.3.3)"3" | Intel 965 GM | Lenovo R61e | 3GB RAM
Reply With Quote
  #3 (permalink)  
Old 16-Jul-2009, 01:52
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,222
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: another newbie who forgot to sanitise user input

I'm not really fussed about it, but it actually is relevant to the Programming and Scripting forum. It's a good demonstration of a SQL injection attack on a web app and not my opinion.
Reply With Quote
  #4 (permalink)  
Old 16-Jul-2009, 02:35
caf4926's Avatar
Global Moderator
 
Join Date: Jun 2008
Location: The English Lake District. UK - GMT/BST
Posts: 12,894
caf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputationcaf4926 has a brilliant future with this reputation
Send a message via MSN to caf4926
Default Re: another newbie who forgot to sanitise user input

Quote:
Originally Posted by ken_yap View Post
I'm not really fussed about it, but it actually is relevant to the Programming and Scripting forum. It's a good demonstration of a SQL injection attack on a web app and not my opinion.
6 of one and half a dozen of the other...
Not really a question, that's all. No offence intended
__________________
Box: openSUSE 11.2 | (KDE4.3.3) | M2N4-SLI | AMD 64 X2 5200+ | nVidia 8500GT | 4GB RAM
Lap: openSUSE 11.2 | Celeron 550 | (KDE4.3.3)"3" | Intel 965 GM | Lenovo R61e | 3GB RAM
Reply With Quote
  #5 (permalink)  
Old 16-Jul-2009, 05:02
Wise Penguin
 
Join Date: Jun 2008
Location: United Kingdom
Posts: 1,026
consused hasn't been rated much yet
Default Re: another newbie who forgot to sanitise user input

Err... I'll take 4 from your dozen as I think it belongs in chit-chat since it is somewhat light-hearted and a bit of a joke.
Reply With Quote
  #6 (permalink)  
Old 16-Jul-2009, 05:06
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,222
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: another newbie who forgot to sanitise user input

Ok! Put a copy in each forum. Just kidding.

Yes, I thought it was a bit of a joke. Even sounded like a ethnic family name: Robert Drop-Table Names.

But not so funny if there's more important data in on the machine at stake. Wannabe PHP programmers pay attention!
Reply With Quote
  #7 (permalink)  
Old 01-Aug-2009, 09:22
Puzzled Penguin
 
Join Date: Aug 2009
Posts: 33
CanOfWires hasn't been rated much yet
Default Re: another newbie who forgot to sanitise user input

Wait, how's this bad input sanitizing? It seems sanitized to:

"Robert\'); DROP TABLE Names;"

as in

INSERT INTO Names (name, nameid) VALUES ('Robert\'); DROP TALBE Names;', 123);

Otherwise the string would be executed as SQL, not returned to page as data.
Reply With Quote
  #8 (permalink)  
Old 01-Aug-2009, 11:47
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,222
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: another newbie who forgot to sanitise user input

Look at the number of visitors: 1

Probably because the DROP TABLE was executed and cleared all the previous entries. The programmer probably wrote something like this:

Code:
$db->query("INSERT INTO Names VALUES($id,'$name')");
Now think, what happens to the argument to $db->query() if $name happens to contain this string, entered at the web interface:

Code:
Robert'); DROP TABLE Names; ('
I put in the (' just to make the single quotes balance, but I think the DROP TABLE would get executed even without them and the last statement isn't syntactically valid.

The moral of the story is, the input value $name should have been sanitised to escape special SQL characters, or statements with placeholders should have been used.
Reply With Quote
  #9 (permalink)  
Old 01-Aug-2009, 11:59
Puzzled Penguin
 
Join Date: Aug 2009
Posts: 33
CanOfWires hasn't been rated much yet
Default Re: another newbie who forgot to sanitise user input

Drop table does not clear a table, it drops it. Therefore a select from it would result with an error, missing the table.

So I'm guessing either there was no SQL injection, or the site carries the name through session/cache to the next page.

The number of certificates issued (#1) suggests there was a SQL injection, but:

- table would be dropped, not truncated
- would result with an SQL error selecting from non-existent table
- dropping the table would make it impossible to COUNT and get #1, UNLESS the site automagically recreates missing tables which I doubt. In which case, the name would be empty.
Reply With Quote
  #10 (permalink)  
Old 01-Aug-2009, 18:14
Flux Capacitor Penguin
 
Join Date: Jun 2008
Location: GMT+10
Posts: 5,222
ken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud ofken_yap has a reputation to be proud of
Default Re: another newbie who forgot to sanitise user input

You don't know what else the application does after that particular part of the code, maybe it recreates the table if it doesn't exist. Or maybe the code simply assumes that no rows is 0, even though SELECT COUNT(*) fails and continues to increment that by 1. That welcome message could be code doing something like this:

Code:
echo "Welcome $name, you are visitor $count";
thus making the injection obvious. You may speculate about the exact details, and since neither you nor I have seen the code, anything goes. You may even argue that this is a faked screenshot. However there's no arguing that SQL injection does exist as a hazard to programmers who don't take care.
Reply With Quote
Reply
Page 1 of 2 1 2

Bookmarks


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




 

Search Engine Friendly URLs by vBSEO 3.3.0 RC2