GIDForums  

Go Back   GIDForums > Computer Programming Forums > MySQL / PHP Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 01-Jul-2003, 06:33
misunderstood misunderstood is offline
Member
 
Join Date: Jun 2003
Posts: 121
misunderstood is on a distinguished road

MySQL Security


I have had the contents of a couple of tables disappear from my database and I was wondering if there are ways that people can access your database remotely without knowing the user name and password. All the tables were not emptied so it seems very strange. It may just be a problem with the database and not a security problem?

Also what security precautions can I make to protect my database if there are ways that determined people can access it?
  #2  
Old 02-Jul-2003, 02:38
Garth Farley Garth Farley is offline
Invalid Email Address
 
Join Date: May 2002
Location: Ireland
Posts: 638
Garth Farley is a jewel in the roughGarth Farley is a jewel in the roughGarth Farley is a jewel in the rough
Through a webinterface, SQL injection can be the biggest threat to your data. If you don't check all the input that goes into your SQL query, it's possible to "inject" a custom query to your database.

For example, say your PHP script used this query:

SELECT * FROM $tablename WHERE Article = $article;

If you don't check the values of $tablename and $article, it's possible for a hacker to figure out the SQL query you're using, by manufacturing a query string ?tablename=something_wrong&article=1;
(assuming register globals is on)

This would throw mySql, as there is no table called "something_wrong", and it'll report something like this straight to the hackers browser:

Cannot execute query:
SELECT * FROM something_wrong WHERE Article = 1;
Reason: No table named 'something_wrong'

Now the hacker knows your query. Now he can try setting the query string to this:
?tablename=valid_table; DROP TABLE valid_table; #

See what it'll try to do? It'll run these 3 requests:
SELECT * FROM valid_table;
DROP TABLE valid_table; //uh oh
# WHERE Article = 1 //i.e. commented out


If your database is set up with too lenient permissions, this can work.

Aside:
Actually not quite. mysql_query() only can run one query at a time, and will return an error if you try this. But with mySql's newest versions, sub-selects are supported, which can be injected, and mysql_query() won't complain.

See these for a great real-world examples:
www.wiretrip.net
www.wiretrip.net

Garth Farley
 
 

Recent GIDBlogLast Week of IA Training by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
A problem Between MySQL <> phpBB mirable MySQL / PHP Forum 3 10-Sep-2003 05:31
MySQL Syntax Error DropZite MySQL / PHP Forum 3 09-Jul-2003 04:00
Windows: From only £20p/y,Linux: from $10p/m. ASP, ASP.NET, PHP, Free MySQL, +More EyotaHosts Web Hosting Advertisements & Offers 0 28-Jun-2003 13:54
can mysql run on a separate server? zabell MySQL / PHP Forum 6 06-Jun-2003 13:32
MySQL Adds Subselects, Upgrades Performance and Security JdS MySQL / PHP Forum 4 22-Jan-2003 17:42

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 17:57.


vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.